[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  How do you remove the comma from a wildcard variable and use it?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Commissar   (2 posts)  [Biography] bio
Date Wed 13 Jun 2012 08:16 AM (UTC)  quote  ]

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?
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Wed 13 Jun 2012 12:17 PM (UTC)  quote  ]

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.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

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


[Go to top] 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.


671 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]