Unknown2009-03-05 20:41:22
I dunno how to phrase this question, but like what are the specific jobs of Scripts and triggers. I know Triggers do y after x but how does that separate the two.
For example, the answer to the question might be, "Triggers change variables, and Scripting does the actual curing!" If that were true (It may be I don't know.)
Dunno if I asked my question clearly enough ~_~
For example, the answer to the question might be, "Triggers change variables, and Scripting does the actual curing!" If that were true (It may be I don't know.)
Dunno if I asked my question clearly enough ~_~
Unknown2009-03-05 20:44:24
Triggers are the means to execute the scripts. Triggers typically contain script code that runs when a specific pattern is matched from the game text. You see "XYZ" match a trigger pattern and you execute "do ABC" as your trigger script. The two are interconnected, usually very closely.
Scripts can also be run from timers, aliases, etc. It all depends on what you're doing and how it makes sense to you to do it. Not everyone's brain works the same way, so we end up with lots of different solutions to the same sorts of problems.
Scripts can also be run from timers, aliases, etc. It all depends on what you're doing and how it makes sense to you to do it. Not everyone's brain works the same way, so we end up with lots of different solutions to the same sorts of problems.
Unknown2009-03-05 20:47:36
So, lets say my Trigger matches XYZ, and it says execute "Do ABC"
Does it go to whatever Script file I have loaded and then.. What? Like.. How does that interaction work? Is the Script file Grouped in such a way that the trigger can actually Look INTO the file, and find what i'm talking about?
Does it go to whatever Script file I have loaded and then.. What? Like.. How does that interaction work? Is the Script file Grouped in such a way that the trigger can actually Look INTO the file, and find what i'm talking about?
Isuka2009-03-05 23:15:14
QUOTE (Tau y'Kaliath @ Mar 5 2009, 12:47 PM) <{POST_SNAPBACK}>
So, lets say my Trigger matches XYZ, and it says execute "Do ABC"
Does it go to whatever Script file I have loaded and then.. What? Like.. How does that interaction work? Is the Script file Grouped in such a way that the trigger can actually Look INTO the file, and find what i'm talking about?
Does it go to whatever Script file I have loaded and then.. What? Like.. How does that interaction work? Is the Script file Grouped in such a way that the trigger can actually Look INTO the file, and find what i'm talking about?
When you have a script file loaded into memory, it's all dropped into a sandbox that MUSH can access at any time. Thus if your script file has function doABC() and you have a trigger that needs to use doABC(), all you need to do is call that function from the script field in the trigger. It's all executed in the same place.
Daved2009-03-06 06:25:59
In your script file Tau, you will define variables and you will define functions. In Lua this is done like so:
defining variables:
variable = value
table = {(optional initial declarations)}
defining functions:
then in your trigger, you will call a function like so:
yourfunction("localvalue")
here's a practical example
put the following in your script file:
and make this trigger:
^A prickly stinging overcomes your body\\, fading away into numbness\\.$
Send:
addaff("paralysis")
Send to: Script
check the regular expression box
Now you have a trigger that executes a function which it searches your script file for.
defining variables:
variable = value
table = {(optional initial declarations)}
defining functions:
CODE
function yourfunction(localvars)
your
script
goes
here
end
your
script
goes
here
end
then in your trigger, you will call a function like so:
yourfunction("localvalue")
here's a practical example
put the following in your script file:
CODE
afflictions = {}
function addaff(affliction)
afflictions = true
Note("You are afflicted with " ..affliction)
end
function addaff(affliction)
afflictions = true
Note("You are afflicted with " ..affliction)
end
and make this trigger:
^A prickly stinging overcomes your body\\, fading away into numbness\\.$
Send:
addaff("paralysis")
Send to: Script
check the regular expression box
Now you have a trigger that executes a function which it searches your script file for.