Greetings,
Maybe other people asked this, but I didn't know what to search in the forum.
I have the following prompt when I type hp:
HP: 173/197 SP: 210/242 EP: 92/ 92
1. How I can save each value in in the variables hp, sp, ep?
2. How can I get only the hp variable when I type hp, and gag the prompt?
3. How can I get the hp variable's value when I hit f2, sp variable when I hit f3, and sp variable when I type f4?
Sorry, but I'm really new to this
Thank you in advance, Sorin
So, after digging a bit, I think I found out how I can save the values to a variable, and I got this code:
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="HP: */* SP: */* EP: */*"
send_to="12"
sequence="100"
>
<send>SetVariable("hp", "%1")
SetVariable("sp", "%3")
SetVariable("ep", "%5")</send>
</trigger>
</triggers>
Now, I have a little problem. I created an alias that it is supposed to give me the values of the hp variable, but it doesn't work:
<aliases>
<alias
match="checkhp"
enabled="y"
send_to="12"
sequence="100"
>
<send>GetVariable("hp")</send>
</alias>
</aliases>
What I'm doing wrong?
Thanks in advance, Sorin
It's almost perfect, except you are discarding the results of getting the variable. That is, this works:
<aliases>
<alias
match="checkhp"
enabled="y"
send_to="12"
sequence="100"
>
<send>print (GetVariable("hp"))</send>
</alias>
</aliases>
Note the use of "print".
Getting a variable in itself just returns the variable. You need to put it somewhere and use it.
eg
hp = tonumber (GetVariable("hp"))
if hp < 20 then
print "ohno!"
end -- if
Also, you don't need "expand variables" here:
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="HP: */* SP: */* EP: */*"
send_to="12"
sequence="100"
>
<send>
SetVariable("hp", "%1")
SetVariable("sp", "%3")
SetVariable("ep", "%5")
</send>
</trigger>
</triggers>
That just converts things like @hp into (almost) the equivalent of:
However be warned that the expansion is done
before the script is compiled, so you can't expand a variable you have only just set (in the same trigger/alias).
Oh, it finally worked! Thank you