Executing Alias from plugin loaded using ImportXML

Posted by Apriebe on Thu 29 Sep 2011 04:08 PM — 4 posts, 15,141 views.

#0
Hi everyone,

On install, my plugin creates a bunch of aliases for directions from an xml file. These directions are then displayed in a miniwindow and given a hotspot, when a user clicks on the hotspot, the plugin should call the alias.

I have got it working right now like so:


function goto_area(flags, hotspot_id)
  iStatus, alname, almatch, alresponse, alflags, alscriptname = GetAlias(hotspot_id)
  Execute(almatch)
end -- function


The hotspot_id is the string name of the alias. I can execute aliases that already exist (ones setup through the GUI) by simply doing "Execute(alias_name)", why does this not seem to be possible for aliases loaded via ImportXML? I would I think I could simply do the above code like so:


function goto_area(flags, hotspot_id)
  Execute(hotspot_id)
end -- function


Thanks for the help!

Andrew
Australia Forum Administrator #1
Huh? The alias name is not what calls it. That is the match text. For example:


Name: foo
Match: Nick eats chocolate


If you do:


Execute "foo"


That isn't the same as:


Execute "Nick eats chocolate"

#2
It seems the reason for my confusion is that my almatch variable is returning the send text. For example I have an alias:


<alias enabled="y" group="directions" name="Along_The_Forest_Path" match="Along_The_Forest_Path">
    <send>#7 w;sw;s;s</send>
  </alias>


alname is set to the name variable, but why is almatch returning the text between <send></send>?
Australia Forum Administrator #3
Looks like the documentation is wrong, sorry.

It should read:


local iStatus
local almatch
local alresponse
local alflags
local alscriptname


iStatus, almatch, alresponse, alflags, alscriptname  =
   GetAlias ("myalias")

print (iStatus, almatch, alresponse, alflags, alscriptname)


In other words, it doesn't return the name. After all, you ask for it by name, so it hardly needs to return the name to you.