|
Capturing a word from World
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Solara
(13 posts) bio
|
| Date |
Mon 04 Jun 2012 07:16 PM (UTC) [ quote
] |
| 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
(13 posts) bio
|
| Date |
Reply #1 on Mon 04 Jun 2012 07:37 PM (UTC) [ quote
] |
| 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
(13 posts) bio
|
| Date |
Reply #2 on Mon 04 Jun 2012 09:05 PM (UTC) [ quote
] |
| 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
(13 posts) bio
|
| Date |
Reply #3 on Mon 04 Jun 2012 09:31 PM (UTC) [ quote
] |
| 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 (849 posts) bio
Global Moderator |
| Date |
Reply #4 on Mon 04 Jun 2012 11:59 PM (UTC) [ quote
] 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. |
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Solara
(13 posts) bio
|
| Date |
Reply #5 on Tue 05 Jun 2012 12:39 AM (UTC) [ quote
] 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 (849 posts) bio
Global Moderator |
| Date |
Reply #6 on Tue 05 Jun 2012 01:11 AM (UTC) [ quote
] |
| Message |
Try
Send("whisper face Your name is "..GetVariable("password"))
|
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Solara
(13 posts) bio
|
| Date |
Reply #7 on Tue 05 Jun 2012 03:18 PM (UTC) [ quote
] |
| 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.
1,091 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )