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
➜ Setting an int-variable
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| tobiassjosten
Sweden (79 posts) Bio
|
Date
| Mon 25 Apr 2005 05:51 PM (UTC) |
Message
| I'm having problem setting a numeric variable with LUA. If I leave out the "'s, it complains that the variable is nil. If I include them, it says it's a string. I need it to be an int-type variable, how can I do this?
Code:
<alias
match="^pres (?P<amount>.*?) (?P<toxin>.*?)$"
enabled="y"
regexp="y"
send_to="12"
omit_from_output="y"
sequence="100"
>
<send>presToxin = "%<toxin>"
presAmount = "%<amount>"
print("Preserving:", presToxin, " (", presAmount, ")")
world.Send ("prepare toxin ", presToxin)</send>
</alias>
|
Simplicity is Divine | http://nogfx.org/ | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #1 on Mon 25 Apr 2005 06:25 PM (UTC) |
Message
| You can set an integer variable easily. I think the error message you got may have been referring to your call to world.Send (and the "world." part is optional in Lua, which is one reason I like it).
You use .. to concatenate strings in Lua, so try changing your print and Send commands to use that instead of commas. Convert numbers to strings (for concatenation, for example) with the tostring() function.
presToxin = "%<toxin>"
presAmount = %<amount>
print("Preserving: " .. presToxin .. " (" .. tostring(presAmount) .. ")")
Send("prepare toxin " .. presToxin)
You might also want to change your regular expression to match more specifically a number and then a string:
^pres (?P<amount>\d+) (?P<toxin>\w+)$
| Top |
|
Posted by
| tobiassjosten
Sweden (79 posts) Bio
|
Date
| Reply #2 on Mon 25 Apr 2005 06:43 PM (UTC) |
Message
| Worked like a charm, thanks alot! Now, to mix balances into this.. |
Simplicity is Divine | http://nogfx.org/ | Top |
|
Posted by
| tobiassjosten
Sweden (79 posts) Bio
|
Date
| Reply #3 on Mon 25 Apr 2005 07:44 PM (UTC) |
Message
| Remade the whole plugin to work more off of LUA functions. Debuged and removed most of the errors, but I just can't seem to find what's causing: [string "Trigger: "]:1: `=' expected near `<eof>'
The plugin is up at: http://www.crox.org/cxPreserve.xml
Could anyone more experienced with LUA please help me decipher this? |
Simplicity is Divine | http://nogfx.org/ | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #4 on Mon 25 Apr 2005 08:02 PM (UTC) Amended on Mon 25 Apr 2005 08:05 PM (UTC) by Flannel
|
Message
| Your first trigger should have < > instead of brackets, but that's just an annoyance (can't view in webbrowser).
When are you getting that error? |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| tobiassjosten
Sweden (79 posts) Bio
|
Date
| Reply #5 on Mon 25 Apr 2005 08:05 PM (UTC) Amended on Tue 26 Apr 2005 05:26 AM (UTC) by tobiassjosten
|
Message
| I get it whenever the plugin calls presPrompt.
Edit: Removed annoyance.. ;)
Edit2: Fixed it by adding () after the function calls. Now I get another error..
[string "Trigger: "]:1: attempt to call global `presPrepared' (a nil value)
stack traceback:
[string "Trigger: "]:1: in main chunk
Not sure if I get it when presPrepared is called, or when presPrompt is called. I'm still trying to learn.. Is this a good way of setting up a plugin?
Edit3: Now it's fully operational again, with added balance checks. Tried to call my functions from the send-part of the triggers, which I think Larkin said was oogley (didn't work that well either). |
Simplicity is Divine | http://nogfx.org/ | 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.
22,108 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top