Simple trigger....

Posted by Bigirish1991 on Tue 11 Aug 2015 04:40 AM — 9 posts, 29,383 views.

#0
So basically, I'm trying to make a trigger to navigate rooms, casting a spell once per room. The rooms are not linear, so I thought I would use a variable "Location", then specify the "gonext" variable, in line with "Location" via a planned route. The trigger I am matching, is the message I get after casting the spell in the room. Basically I want to go south, south, south, southeast. The "gonext" variable does not seem to be getting changed to southeast? What am I doing wrong? OR is there a better way for me to do this?


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="*You can't isolate any more viable spores in this mess.*"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ( "Location", @Location + 1 )
if Location == 2 then
SetVariable ( "gonext", "south" )
Send ( "@gonext" )
Send ( "c myco" )
elseif Location == 3 then
SetVariable ( "gonext", "south" )
Send ( "@gonext" )
Send ( "c myco" )
elseif Location == 4 then
SetVariable ( "gonext", "south" )
Send ( "@gonext" )
Send ( "c myco" )
elseif Location == 5 then
SetVariable ( "gonext", "southeast" )
Send ( "@gonext" )
Send ( "c myco" )
end</send>
  </trigger>
</triggers>
Amended on Tue 11 Aug 2015 04:56 AM by Bigirish1991
Australia Forum Administrator #1
Better read/watch this:

http://www.gammon.com.au/forum/?id=10863
#2
So I might be an idiot but, after watching that, this is what I came up with.... The trigger fires, but doesnt enter the "if location == 1 then"?? Sorry if I'm being a real slow learner.


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="*You can't isolate any more viable spores in this mess.*"
   send_to="12"
   sequence="100"
  >
  <send>if location == 1 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 2 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 3 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 4 then
gonext = "southeast"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
end
</send>
  </trigger>
</triggers>
Australia Forum Administrator #3
There are two sorts of variables, which is what that tutorial was saying.


if location == 1 then


That's a Lua variable.


SetVariable ( "Location", @Location + 1 )


That's a client variable. Also, capitalization is important in Lua, so these are different:


location
Location


Can you show how you are setting up this location/Location variable?
#4
Basically, I'm trying to navigate a route. Location is the "room" im in, and "gonext" is the next direction I have to go. So I am in room one and I need to go south, in room two I want to go south, room three south, and room four I have to go southeast. Maybe there is an entirely better way for me to do something like this? The room are all different, nothing about them is always going to be the same so. Oh and I was using an alias, to just create the Lua variables, and set them to 1/south. What is required, for the first room.
#5
bump
The second post I made, was the trigger that I came up with, after I watched the video.
Australia Forum Administrator #6
Can you post both triggers again please? Using your current code? In the original you have "location" and "Location" which are different variables.

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
#7
Sorry for the missunderstanding. It's 1 trigger, with the current code. Here is what I have, right now.


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="*You can't isolate any more viable spores in this mess.*"
   send_to="12"
   sequence="100"
  >
  <send>if location == 1 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 2 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 3 then
gonext = "south"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
elseif location == 4 then
gonext = "southeast"
location = location + 1
Send (gonext)
Send ( "cast mycomancy" )
end
</send>
  </trigger>
</triggers>


And I have 1 alias, I was planning on using to set/reset the variables each use. Here it is.


<aliases>
  <alias
   match="reset"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>location = "1"
gonext = "south"</send>
  </alias>
</aliases>
Australia Forum Administrator #8

location = "1"
...
if location == 1 then


There's a big difference in Lua between 1 (a number) and "1" (a string). They won't be equal.

If you are going to test for equality to 1, you have to assign 1.


location = 1
...
if location == 1 then