How do you remove the comma from a wildcard variable and use it?

Posted by Commissar on Wed 13 Jun 2012 08:16 AM — 3 posts, 14,494 views.

#0
Ok, so im really new to scripting. Im used to "brute force" triggering, which is making many, many triggers to get done what i want done. After looking around on here and figuring out how to use a simple script trigger or two, my gaming has improved immensely. The help files around here have been really great, but im stuck at a point where i think its time i give up searching, and just ask. Hopefully everything comes through clear.

Ok, so, what i want to do is basically get rid of a comma in a wildcard varible.

This is what my prompt looks like:
[Hi: 129][Vi: 238][Ti: 1,087][Exp: -106]>
This is what i changed it to look like, for my trigger:

[Hi: *][Vi: *][Ti: *][Exp: *]>

The third variable (Ti, %3) is what i want to work with. My original script was simple enough, i thought:


<triggers>
<trigger
enabled="y"
expand_variables="y"
group="training stats"
match="[Hi: *][Vi: *][Ti: *][Exp: *]&gt;"
send_to="12"
sequence="100"
>
<send>if %3 > 1000 then
Send "wake"
Send "stand"
Send "train dop"
end -- if
</send>
</trigger>
</triggers>


With that, I get this error message when triggered:
Compile error
World: advent
Immediate execution
[string "Trigger: "]:1: 'then' expected near ','


Im pretty certain the problem is that darn "comma". I tried playing around with string.gsub, but i kept getting error messages stating that i was trying to compare a string with a number. I even tried number.gsub but couldnt get it to work. Right now im using this for the first line as a temporary patchup:

If "%3" == "1,087" then

But the problem with that is, if I advance any further ill have to constantly update the "1,087" bit.

I bet this is extremely simple but im not catching how to do it. Thanks for your time and effort!



Hm, as a separate question, is there a way to send the script only once per trigger? For example in the trigger above, when I "wake" it shows the prompt, which triggers the trigger again, and then when "stand" the prompt is show again, which, again triggers it.

Is there a way to only activate the entire trigger once every few minutes and not delete or deactivate the trigger permanently?
Amended on Wed 13 Jun 2012 08:28 AM by Commissar
USA Global Moderator #1

local numstr = string.gsub("%3",",","")
if tonumber(numstr) > 1000 then
  Send("wake")
  Send("stand")
  Send("train dop")
end


Quote:
I even tried number.gsub
Which doesn't exist.

Quote:
but couldnt get it to work
Because it doesn't exist.

Quote:
Is there a way to only activate the entire trigger once every few minutes and not delete or deactivate the trigger permanently?

Deactivate it immediately and also use DoAfterSpecial to reactivate it in a few minutes.
Amended on Wed 13 Jun 2012 12:18 PM by Fiendish
#2
Awesome! Thankyou so much! So much neater than what I eventually came up with, and many less triggers to do the same thing! I appreciate it!

lol on the number.gsub, i had a feeling when i decided to try it that it didnt actually exist, but i said what the heck!

When I first copy and pasted your code I got endlessly spammed for about 5 minutes until I realized send to script wasnt selected!

Instead of using DoAfterSpecial, im using

EnableTrigger("name" false)

in the If statement, and then at the final trigger that
activates the rest mode i have

EnableTrigger("name", true)


Whew, I spent about 7 hours scrapping code together to get a frankenstein halfway approach to that, so, once again, Thankyou!