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
➜ how do I ignore scripting?
how do I ignore scripting?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Caeser
(22 posts) Bio
|
Date
| Wed 21 Jun 2006 03:40 AM (UTC) |
Message
| Lately, I switched over to Aetolia, another IRE MUD, as was wondering.
In the game, there is a skill that allows you to detect illusions, which are primarily used by the stealthy class in order to throw off their combatant's system for healing.
Basically, it gives the line ****Illusion****. It has a 25% chance of coming before the actual illusion, and a 25% of coming after.
Now, what I would like to do is this: When the first ****Illusion**** comes in, I would like to to completely ignore the next lines until I receive the prompt. When I mean ignore, I mean everything. Gags and stops it from doing the script I want those lines to do.
I figure I can do the same thing for the 2nd ****Illusion**** line, but it'd work through a different multi-line trigger.
Any help is appreciated. I have been wracking my brains, and what limited programming I know, for at least a week.
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 21 Jun 2006 03:51 AM (UTC) |
Message
| You could make a trigger to detect the Illusion line and turn off all triggers:
SetOption ('enable_triggers', 0) -- disable all triggers
Of course, the problem is now you can't make a trigger to turn them on again. :P
Or, put all your triggers into a group, and disable the group:
EnableTriggerGroup ('groupname', 0) -- disable the group
The trigger that detects the prompt line would, of course, not be in that group. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #2 on Wed 21 Jun 2006 04:15 AM (UTC) |
Message
| I'm sitting in shame right now... I didn't even *THINK* to use that.
The only downside to that though, would be that I couldn't do that for the second ****Illusion**** line. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 22 Jun 2006 08:57 AM (UTC) |
Message
| I don't see how you can make the 2nd one work - that is a line that occurs after the things you have already seen? You can't retrospectively ignore stuff, unless you batched it up, and processed it later. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Caeser
(22 posts) Bio
|
Date
| Reply #4 on Thu 22 Jun 2006 10:08 PM (UTC) Amended on Fri 23 Jun 2006 11:55 PM (UTC) by Caeser
|
Message
| Well, I had an idea just now to write a function that would find the trigger for the last two lines... say I get:
You are stupid.
Your arms are broken.
****Illusion****
prompt
Well, when it gets the second illusion, I could have it do a search to see what the triggers for the lines before it did, scripting wise, and then do the reverse.
I'm going to be taking a Java programming class, so it can wait until after I'm better at programming. I figure that if I can get decent at one language, I'll be able to program in a different.
I'm just wondering, if that type of function even possible?
Thanks for the help though. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sat 24 Jun 2006 12:24 AM (UTC) |
Message
|
Quote:
I could have it do a search to see what the triggers for the lines before it did, scripting wise, and then do the reverse.
Yes, but how? Say the trigger did "drink green potion", how do you undrink something? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #6 on Sat 24 Jun 2006 02:16 AM (UTC) |
Message
| As long as you want to guard a specific class of messages (i.e. affliction ones) it is definitely possible.
You could set up a table of patterns that you want to safeguard against illusions, with patterns as keys and "action names" as values. Action names could be whatever, for example affliction names. Then you make all your affliction triggers record what afflictions they save or remove on/from your character in another (array) table. That table would function like a stack - you push an affliction name when saving an affliction, pop when removing it. It would need to push only when a save was successful, meaning that you didn't have that affliction already at the time of saving it. Otherwise, someone could afflict you, make you save an affliction, and then illusion the same affliction - making you remove it.
Then you use a multiline trigger like "^prompt\n(?:\*Illusion\*\n)?(.*?)\*Illusion\*\n" to call a function that would split the captured wildcard around newlines, loop on the resulting table (in reverse), take each line and match it against every pattern in the first table. As soon as you get a match, take the value associated with the matched pattern, compare it with whatever is in the last position of the stack table, if they compare true, then remove the affliction. Move on to the next line. Something like that should work. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #7 on Sat 24 Jun 2006 02:39 AM (UTC) |
Message
| On a second thought, pushing/popping like that would be a bad idea. Then someone could afflict you and illusion you curing that affliction, resulting in trouble.
But any problem can be solved by making its solution more complicated :) Create a third table with "action names" as keys and function as values. These functions would be called whenever one of the "action" patterns matches. For afflictions and their cures you'd need only one such function, as long as you choose the naming scheme wisely. Supposing that you store afflictions in a table "afflicts" and name afflictions "affl_name" and cures "cure_name", such a function could look like:
function (name)
local t = utils.split(name, "_")
if t[1] == "affl" then
afflicts[t[2]] = false
elseif t[1] == "cure" then
afflicts[t[2]] = true
end
end
Then a function for saving/removing afflictions - presuming that the stack table is called "stktab", and you name your affliction/cure triggers the same way as above (for simplicity's sake) - would be:
function (name,...)
local t = utils.split(name, "_")
if t[1] == "affl" then
if not afflicts[t[2]] then
table.insert(stktab, name)
afflicts[t[2]] = true
end
elseif t[1] == "cure" then
if afflicts[t[2]] then
table.insert(stktab, name)
afflicts[t[2]] = false
end
end
end
That would basically push messages for both afflictions and cures, leaving you with the task of preventing the stack from bloating up with values, which task can be fairly easily solved by limitting its length. I think PIL has examples of doing that.
The rest of the mechanics remain the same: the multiline trigger still calls a function that parses the captured lines, only when a match occurs it would pop the value and use the name to call the function saved in the third table. | 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,770 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top