I would like to set up a generic function that will check for balance/equilibrium then, if i don't have it, wait until it comes back and then continue with the alias/trigger/whatever that called the function. I have triggers to set variables bal and equil to 0 when i use it and 1 when it's recovered. However, if i do a simple loop that loops and does nothing until bal or equil = 1, It basically just assumes it is 1 and goes on.
I can't show what i've tried because copying from mudlet doesn't work on my system, but i was wondering if anyone could show me how to do this.
Thanks,
Mordocai
Balance and Equilibrium checker
Re: Balance and Equilibrium checker
Well, this is possible... but are you sure you want to go with this architecture? I can see it being messy when things start getting queued up / not finishing in time and etc.
The typical way to do this is to have your triggers set flags for the actions you'd need to do, and when you get both balance and eq back, run a check over all the flags, and do the things you need.
ie, when you fall down, you do
prone = 1
and when you get balance or eq back, you'd to this:
The typical way to do this is to have your triggers set flags for the actions you'd need to do, and when you get both balance and eq back, run a check over all the flags, and do the things you need.
ie, when you fall down, you do
prone = 1
and when you get balance or eq back, you'd to this:
Code: Select all
if balance ~= true and equilibrium ~= true then return end
if prone == 1 then
send ('stand')
end
Re: Balance and Equilibrium checker
So, would i have a trigger that goes off when i get my equilibrium/balance back and then checks to see what it needs to do based on variables set by other triggers? I'm sorry, fairly new to coding in general... and really new to coding for a MUD.
Re: Balance and Equilibrium checker
By the way, i originally came up with this because i wanted one alias that would set up all my defenses in order and not have to be run multiple times.
Re: Balance and Equilibrium checker
Yep.So, would i have a trigger that goes off when i get my equilibrium/balance back and then checks to see what it needs to do based on variables set by other triggers?
Well that's a nice idea, but what if you want to pause the defup? And how will the alias not defup stuff you already have? and suchBy the way, i originally came up with this because i wanted one alias that would set up all my defenses in order and not have to be run multiple times.
Re: Balance and Equilibrium checker
If it's really just for a defup alias and isn't supposed to keep defences up all the time, then a coroutine might be a suitable implementation for this, yes? (I'm may be wrong since I'm a total Lua noob and only learned about coroutines yesterday ). Start with the defup, after putting up the first defence, yield and wait till you get balance or equilibrium back, then resume the coroutine, and repeat this for all defs. This would also allow you to pause it.
Re: Balance and Equilibrium checker
Heh, well... having an alias that has a whole bunch of ifs and yields instead of if, elseifs would do I guess. But unfortunately Mudlet doesn't support coroutines yet, it requires some special implementations which we'll get to later.
Re: Balance and Equilibrium checker
Assuming this is for an IRE mud.
In your prompt trigger, capture the part of your prompt stats that tells you whether you have balance/equilibrium or not. For example, the bolded part:
[pcsdb eb]
or for Lusternia:
-ex
You want to match the eb, --, e- and -b
Use: ([eb-]{2}) in the appropriate part of your prompt trigger pattern.
In your prompt script:
In a script object:
In your prompt trigger, capture the part of your prompt stats that tells you whether you have balance/equilibrium or not. For example, the bolded part:
[pcsdb eb]
or for Lusternia:
-ex
You want to match the eb, --, e- and -b
Use: ([eb-]{2}) in the appropriate part of your prompt trigger pattern.
In your prompt script:
Code: Select all
eqbal = matches[5] -- assuming "5" is the capture group the above matches
-- Check if time to raise onEqbal --
if eqbalcheck == 1 then
eqbalCall()
end
Code: Select all
eqbalcheck = 0
function eqbalCheck()
x=0
if eqbal == "eb" then x=1 end
return x
end
function eqbalCall()
if eqbalCheck() == 1 then
eqbalcheck = 0
onEqbal()
end
end
function onEqbal()
-- here you have your commands to check for actions that require balance/eq, such as lighting pipes, ordering entities, blah blah
-- here you have your commands to check for actions that require and use balance, like rejecting people, or putting back critical defences such as spirit bonding
-- here you have your commands to execute actions from a queue, such as your next attack.
end
Re: Balance and Equilibrium checker
another way to do it, the 'mudlet' way: http://forums.imperian.com/index.php?sh ... t&p=392581