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 ➜ Capturing a word from World

Capturing a word from World

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


Posted by Solara   USA  (59 posts)  Bio
Date Mon 04 Jun 2012 07:16 PM (UTC)
Message
Hello, I'm trying to create a script to grab a password after I execute a spell. Then I need to whisper that password to the face to open a door.

Two problems:
1- when I capture the password and capture it as a variable, there's a leading space in front of it which the door wont' accept. How do I truncate the first empty space?
2- I can't seem to do a Send command (using Lua) with additional text along with the variable. I'm sure it's syntax, but if I can't do a Send command with additonal text combined with the variable, how do I combine two variables together into one string?

Trigger: The runes have moved to form the word:*
Code:
require "wait"
wait.make (function ()

SetVariable ("password", "%1")
SetVariable ("password", (string.format ("%.9s", (GetVariable ("password")))))
Note (GetVariable ("password"))
Send ("rub orb")
wait.time (06)
Send ("whisper face Your name is" (GetVariable ("password")))

end)

The %.9s truncates the last letter, but I'm trying to truncate the first letter.
And I get an script error for the Send ("whisper... line.

Thanks for any help!
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #1 on Mon 04 Jun 2012 07:37 PM (UTC)
Message
Ok after reading another thread, I fixed the first problem. Still can't do a Send command with new preceding text along with the variable. Here's the revised code so far:

require "wait"
wait.make (function ()

SetVariable ("password", (string.sub ("%1", 2, 10)))
Send ("rub orb")
Note (GetVariable ("password"))
wait.time (06)
Send ("whisper face Your name is (GetVariable ("password")))

end)
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #2 on Mon 04 Jun 2012 09:05 PM (UTC)
Message
Okay so I figured out the answer to both problems. BUT I've run into a new problem. Here's the trigger script:

require "wait"
wait.make (function ()

SetVariable ("password", (string.sub ("%1", 2, 10)))
Send ("rub orb")
Note (GetVariable ("password"))
wait.time (06)
Send ("whisper face Your name is @password")
Send ("s")
Send ("close door")

end)

So what happens when I run is it that it will correctly Note the current password. But for some bizarre reason it's sending the previous password instead! It appears the password variable gets changed and is noted correctly, but then when you do @password, it uses the previously stored one? Anyone know what's going on here?
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #3 on Mon 04 Jun 2012 09:31 PM (UTC)
Message
Well I worked around the problem by creating two triggers.
First trigger sets the variable.
Second trigger whispers the password.

Seems the @password is set at the onset of the trigger, and does not get updated while the script is running - though the variable itself is changed and is displayed correctly with the 'Note' command. But for some odd reason the 'Send @password' sends the previous password.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #4 on Mon 04 Jun 2012 11:59 PM (UTC)

Amended on Tue 05 Jun 2012 12:00 AM (UTC) by Fiendish

Message
GetVariable(foo) and @foo do not do the same thing. As you noted, the @ syntax is just a preprocessor that substitutes values at entrance. GetVariable does what you want.

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #5 on Tue 05 Jun 2012 12:39 AM (UTC)

Amended on Tue 05 Jun 2012 12:40 AM (UTC) by Solara

Message
How can I use the Send command to send some text along with the GetVariable then? I've found a workaround but it would be more elegant to have it in one trigger instead of two.

This does not work. I get a script error:

Send ("whisper face Your name is (GetVariable ("password")))
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #6 on Tue 05 Jun 2012 01:11 AM (UTC)
Message
Try

Send("whisper face Your name is "..GetVariable("password"))

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #7 on Tue 05 Jun 2012 03:18 PM (UTC)
Message
Thanks Fiendish, that did the trick.
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.


19,548 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.