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
➜ General
➜ Can't figure this out
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| David Berthiaume
(202 posts) 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 > 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Larkin
(278 posts) 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. | Top |
|
Posted by
| David Berthiaume
(202 posts) 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="^\<(.*)\%HP\|(.*)\%Mana\|(.*)\%Move\> \<(.*)\>$"
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>
| Top |
|
Posted by
| Meerclar
USA (733 posts) 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 | Top |
|
Posted by
| David Berthiaume
(202 posts) 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Ked
Russia (524 posts) 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:
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
| 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.
31,503 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top