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
➜ Trigger to call a function to get info to see if ok to fire trigger
Trigger to call a function to get info to see if ok to fire trigger
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Warbit
USA (47 posts) Bio
|
Date
| Fri 19 Aug 2011 07:57 AM (UTC) Amended on Fri 19 Aug 2011 08:03 AM (UTC) by Warbit
|
Message
| I have been looking on forum for information on how to do this for 4 hours.
I found this
http://www.mushclient.com/forum/?id=6030
I tried this
<triggers>
<trigger
enabled="y"
match="You are thirsty."
script="my_stats"
send_to="12"
sequence="100"
>
<send>if cma > 20 then
Send ("cast 'freshwater'")
endif</send>
</trigger>
</triggers>
>
<triggers>
<trigger
enabled="y"
match="<*/*hp */*ma */*mv>"
script="my_stats"
send_to="12"
sequence="100"
>
</trigger>
</triggers>
function test_alias (name, line, wildcards)
Note "Hello, world!"
end -- function test_alias
function my_stats (name,line,wildcards)
local chp = wildcards [1]
local mhp = wildcards [2]
local cma = wildcards [3]
local mma = wildcards [4]
local cmv = wildcards [5]
local mmv = wildcards [6]
end--function my_stats
How I wanted it to work was. It would see You are thirsty. It for check my_stats. It would see if I had 20 or more mana available. If the answer was yes, then it would cast the freshwater spell.
I get:
Error number: 0
Event: Run-time error
Description: [string "Trigger: "]:1: attempt to compare number with nil
stack traceback:
[string "Trigger: "]:1: in main chunk
Called by: Immediate execution
| Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 19 Aug 2011 10:04 AM (UTC) |
Message
| Here's one problem:
function my_stats (name,line,wildcards)
local chp = wildcards [1]
local mhp = wildcards [2]
local cma = wildcards [3]
local mma = wildcards [4]
local cmv = wildcards [5]
local mmv = wildcards [6]
end--function my_stats
Variables declared "local" like that cease to exist at the end of that function. But from what you described you want global variables. So delete the word "local" from each line.
Local means "local" like "only here". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
10,410 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top