Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Can you help me figure this error out?

Can you help me figure this error out?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rivius   (99 posts)  Bio
Date Thu 16 Dec 2010 11:28 PM (UTC)
Message

<triggers>
  <trigger
   enabled="y"
   group="Test"
   keep_evaluating="y"
   match="^You step up to (an energy collector|a battle turret)\, locking yourself into the module and linking your mind to the controls of the ship\. After a moment\, you begin to sense your command of the module in your own brain\.$"
   name="Link_up"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

aethership_module= %1

if aethership_module=="an energy collector" then
	if (GetVariable("treant_auto_Siphoning")=="true") then 
	--If siphoning is already on, it'll let us know.
	Execute("AUTO Siphoning ON")
	else
	Execute("AUTO Siphoning OFF")
	end
elseif %1=="a battle turret" then
	EnableTriggerGroup("Aethership Gunning",true)
	SetVariable("treant_auto_Siphoning", "false")
else SetVariable("treant_auto_Siphoning", "false")
end
</send>
  </trigger>
</triggers>

I'm confused! And I just can't see what's wrong. Here;s the error message:

Compile error
World: Treant
Immediate execution
[string "Trigger: Link_up"]:1: '=' expected near 'collector'
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Thu 16 Dec 2010 11:45 PM (UTC)

Amended on Thu 16 Dec 2010 11:46 PM (UTC) by Twisol

Message
"%1", not %1. Quotes are important. %1 isn't part of Lua itself: MUSHclient pre-processes the contents of the Send box each time the trigger fires, replacing %1 with the associated data. So if %1 is an energy collector, your code will look like this before Lua can run it:
aethership_module= an energy collector

Lua has no idea what this is supposed to mean. But if you use "%1", it looks like:
aethership_module= "an energy collector"

And then Lua knows that "an energy collector" contains data.

EDIT: Same goes for every other place you're using %1.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Rivius   (99 posts)  Bio
Date Reply #2 on Thu 16 Dec 2010 11:59 PM (UTC)
Message
Oh! Such an simple stupid mistake. Thanks a bunch, I was under the impression that it didn't need to be quoted since it was already a string.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #3 on Fri 17 Dec 2010 12:16 AM (UTC)
Message
The trick is that it's not anything until the script runs. :)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,612 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.