[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Can't figure this out
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Can't figure this out

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


Posted by David Berthiaume   (202 posts)  [Biography] bio
Date Mon 21 Feb 2005 07:11 PM (UTC)

Amended on Mon 21 Feb 2005 07:12 PM (UTC) by David Berthiaume

Message
<triggers>
  <trigger
   enabled="y"
   match="You gained a level!"
   name="GainLevel"
   send_to="12"
   sequence="2"
  >
  <send>levelold = CInt(GetVariable ("level"))
if GetVariable ("level2") = "subhero" then
level = (levelold + 1)
if level &gt; 100 then
SetVariable ("level2", "H")
level == (level - 100)
SetVariable ("level", level)
else
SetVariable ("level", level)
end
else
level = (levelold + 1)
SetVariable ("level", level)
end
</send>
  </trigger>
</triggers>



Lua Scripting, keep getting this error:
Error number: 0
Event:        Compile error
Description:  [string "Trigger: Hunger"]:5: `=' expected near `=='
Called by:    Immediate execution

I've changed all the "=" to "==" but that didn't fix it.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Mon 21 Feb 2005 08:03 PM (UTC)
Message
Your if statement should have == in it. And all the assignments need simply a =.
You (at least what you pasted) have a == in your second assignment (when you subtract 100).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #2 on Tue 22 Feb 2005 05:18 PM (UTC)
Message
Not sure if this matters or not, but it doesn't even look like the error message was for this trigger. I mean, this trigger has errors in it, too, but the message appears to be for a "Hunger" trigger.

In Lua (as in C), you use "==" for logical comparison and "=" for variable assignment. The main difference is that in Lua you'll get an error when you try to swap them around. In C, it's legal, though the logic may not be what you wanted.
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] bio
Date Reply #3 on Fri 25 Feb 2005 03:22 AM (UTC)
Message
Doh! I copy/pasted the wrong trigger...
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] bio
Date Reply #4 on Sat 26 Feb 2005 06:31 PM (UTC)
Message
Error number: 0
Event:        Compile error
Description:  [string "Trigger: Hunger"]:5: `=' expected near `=='
Called by:    Immediate execution


Ok, lets try this again.


<triggers>
  <trigger
   enabled="y"
   group="InfoBarScript"
   ignore_case="y"
   keep_evaluating="y"
   match="^\&lt;(.*)\%HP\|(.*)\%Mana\|(.*)\%Move\&gt; \&lt;(.*)\&gt;$"
   name="Hunger"
   omit_from_output="y"
   regexp="y"
   repeat="y"
   send_to="12"
   sequence="1"
  >
  <send>SetVariable ("aaHP", "%1")
SetVariable ("aaMana", "%2")
SetVariable ("aaMove", "%3")
SetVariable ("aaHunger", "%4")
hunger == GetVariable ("aaHunger")
if (hunger == "H") or (hunger == "T") or (hunger == "HT") then
for count == 1 to 2
SendImmediate ("drink soup")
next
else
end</send>
  </trigger>
</triggers>
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #5 on Sun 27 Feb 2005 04:49 AM (UTC)
Message
Based on what it looks like you're trying to do (no documentation leaves us guessing a little)
hunger == GetVariable ("aaHunger")
should be
hunger = GetVariable ("aaHunger")
so the variable is being set instead of evaluated. The rest of the logic looks right as far as I can tell.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] bio
Date Reply #6 on Mon 28 Feb 2005 12:47 PM (UTC)
Message
Tried that, Tried a lot of things. Can't get it to work.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #7 on Mon 28 Feb 2005 04:59 PM (UTC)

Amended on Mon 28 Feb 2005 05:03 PM (UTC) by Flannel

Message
Your for statement should also have a = instead of a ==, since it's an assignment, not a comparison.

Why do you have the else statement?

And your end should be an "end if".

The difference between == and = is not trivial, use = when youre assigning a value, use == when you're comparing them. You had this same problem in the other script you posted, why that hasn't given you problems is just luck.

With all these syntax errors, you should download the VBScript scriptdocs (alright, so its really called Windows Script docs, but still) and reference it often (especially when debugging).
You would've seen that it says 'for counter = start to end' and that if statements have optional elses and require an 'end if' instead of merely an 'end'. So download that (you can download it from the same section as the 'script functions you can download' on the first inbuilt function page).

It's also quite possible that your trigger is wrong, or that you have leading/trailing spaces in the variable.
You also don't need to use getvariable to get the contents of aaHunger, since you have it as %4 already, that will save you time in your script. But check your hunger variable (MC variable, or even just note %4) and see if it is indeed H T or HT (without other whitespace or anything else) when you think it should be firing.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #8 on Mon 28 Feb 2005 08:25 PM (UTC)
Message
Oh yeah, and it just occured to me that we're in VBscript, and we dont ever use ==. So change all those (comparisons and assignments) to =. That's probably the problem that started this all.

We're all just confused as to what language we're actually writing in.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] bio
Date Reply #9 on Thu 03 Mar 2005 01:39 AM (UTC)
Message
I'm writing in Lua
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #10 on Thu 03 Mar 2005 09:53 PM (UTC)
Message
The error is still clearly pointing at the "==" operator. So change:

hunger == GetVariable ("aaHunger")


to:

hunger = GetVariable ("aaHunger")


As Meerclar already said. Next, your for loop looks fishy, I think you are confusing vbs and Lua here. According to the Lua docs it should be:


for count=1,2 do
  ...
end


Not what you have:


for count == 1 to 2
   ...
next


So the script should be:


SetVariable ("aaHP", "%1")
SetVariable ("aaMana", "%2")
SetVariable ("aaMove", "%3")
SetVariable ("aaHunger", "%4")
hunger = GetVariable ("aaHunger")
if (hunger == "H") or (hunger == "T") or (hunger == "HT") then
   for count=1,2 do
      SendImmediate ("drink soup")
   end
end


Or better yet:


SetVariable ("aaHP", "%1")
SetVariable ("aaMana", "%2")
SetVariable ("aaMove", "%3")
SetVariable ("aaHunger", "%4")
hunger = "%4"
if (hunger == "H") or (hunger == "T") or (hunger == "HT") then
   for count=1,2 do
      SendImmediate ("drink soup")
   end
end
[Go to top] 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.


8,866 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]