[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]  Lua
. . -> [Subject]  Trigger to call a function to get info to see if ok to fire trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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] Refresh page


Posted by Warbit   USA  (47 posts)  [Biography] 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 &gt; 20 then

Send ("cast 'freshwater'")

endif</send>
  </trigger>
</triggers>
>


<triggers>
  <trigger
   enabled="y"
   match="&lt;*/*hp */*ma */*mv&gt;"
   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


[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] 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
[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.


2,432 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]