So I'm trying to make a function for my script to track my various balances in the mud. So I set up a trigger to go off my prompt, from which I can see my balances like so:
1957h, 2799m, BpP-
Where "1957h," represent's my health, "2799m," represents my mana, and "BpP-" represents my balances. "B" is my balance, "p" is my potion balance, and "P" is my pipe balance.
My trigger is set to match:
"*h, *m, *-"
and in the send field I put:
SetVariable ("health", "%1")
SetVariable ("mana", "%2")
SetVariable ("prompt_balance", "%3")
I have scripting enabled box checked as well as the keep evaluating and trigger enabled box's checked(though I only checked the keep evaluating box hoping for some reason it might fix my problem).
I selected send to script. in the script box I put:
prompt_balance
Because that was the name of the function I put in the script file. In the "group" field I put "prompt"
I have variable's named:
prompt_health
prompt_mana
prompt_balance
balance_balance
balance_potion
balance_pipe
and all of them are in lowercase as shown above.
My script look's like this:
function prompt_balance (name, line, wildcards)
if "prompt_balance" == "B*" then
SetVariable ("balance_balance", "true")
elseif "prompt_balance" == "[^B]" then
SetVariable ("balance_balance", "false")
end
if "prompt_balance" == "*p*" or "p*" or "*p" then
SetVariable ("balance_potion", "true")
elseif "prompt_balance" == "[^p]" then
SetVariable ("balance_potion", "false")
end
if "prompt_balance" == "*P" or "P" then
SetVariable ("balance_pipe", "1")
else
SetVariable ("balance_pipe", "0")
end
end
The reason for the inconsistancy in the function's code is due to me trying a variety of differant things before coming here for help. Each "if" was at one point the standard for all three. I'm posting them in this manner in the hopes that it will limit the response questions by demonstrating the various ways I tried to do this function already.
<triggers>
<trigger
enabled="y"
group="prompt"
keep_evaluating="y"
match="*h, *m, *-"
script="prompt_balance"
send_to="12"
sequence="100"
>
<send>SetVariable ("prompt_health", "%1")
SetVariable ("prompt_mana", "%2")
SetVariable ("prompt_balance", "%3")</send>
</trigger>
</triggers>
<variables>
<variable name="balance_balance">true</variable>
<variable name="balance_potion">true</variable>
<variable name="balance_pipe">1</variable>
<variable name="prompt_balance">BpP</variable>
<variable name="prompt_health">1957</variable>
<variable name="prompt_mana">2799</variable>
</variables>
Now once all of this was put together and not showing any errors, it did successfully change my variables. However it seems to only change them to true, since even when they aren't there they seem not to set them to false or 0. So I'm guessing I got part of this right, but I can't seem to figure out what part I need to change to make it work properly all around?
Also as a bit of an after thought, I want to clarify that if I don't have balance for say potions my prompt shows that by simply removing the associated letter like so:
1957h, 2799m, BP-
And if I have no balance, potion balance or pipe balance:
1957h, 2799m, -
So thats about all I can tell you about the matter, please help me, and thanks in advance. |