Register forum user name Search FAQ

Gammon Forum

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 you remove the comma from a wildcard variable and use it?

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

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Commissar   (2 posts)  Bio
Date Wed 13 Jun 2012 08:16 AM (UTC)

Amended on Wed 13 Jun 2012 08:28 AM (UTC) by Commissar

Message
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?
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Wed 13 Jun 2012 12:17 PM (UTC)

Amended on Wed 13 Jun 2012 12:18 PM (UTC) by Fiendish

Message

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.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Commissar   (2 posts)  Bio
Date Reply #2 on Wed 13 Jun 2012 01:25 PM (UTC)
Message
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!


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.


11,244 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.