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
➜ Using Variables
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Burzmali
(10 posts) Bio
|
Date
| Thu 21 Dec 2006 08:27 PM (UTC) |
Message
| I am having no luck trying to use variables. I have v3.83. When I try to send to the following to script from an alias
setvariable ("clevel", "82") I get the following error.
[string "Alias: "]:3: attempt to call global 'setvariable' (a nil value)
stack traceback:
[string "Alias: "]:3: in main chunk
I went to the Variables area and entered the variable clevel with the contents 82 but it made no difference. The sanbox seems to be set up the way you describe in the thread improved sandbox (if that is even relevent). If i send the alias to execute it doesn't process the if statement it just sends each line in the alias to the mud 1 line at a time. I am obviously missing something fundamental again. what I am ultimately trying to accomplish is to create an alias which will choose which speedwalk will be sent to the mud based on what level the character is. | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #1 on Thu 21 Dec 2006 08:38 PM (UTC) |
Message
|
setvariable should be SetVariable
The caps thing, try that for starters. | Top |
|
Posted by
| Burzmali
(10 posts) Bio
|
Date
| Reply #2 on Thu 21 Dec 2006 09:12 PM (UTC) |
Message
| Ok, that was the problem alright. Now, i have entered the variable clevel in the variables section with the value of 82. I am assuming that makes it a global variable. My alias is as below entered directly into the edit window:
local mylevel
GetVariable ("mylevel", "clevel")
Send ("enter")
Send ("d")
if mylevel < 60 then
Send ("run d2s10wn2wn4wn8wn21w11sd")
else
Send ("rem (255326)")
Send ("get warplans (249550)")
Send ("wear warplans")
Send ("enter")
Send ("rem warplans")
Send ("put warplans (249550)")
Send ("wear (255326)")
end
when i call the alias i get the following error:
[string "Alias: "]:5: attempt to compare nil with number
stack traceback:
[string "Alias: "]:5: in main chunk
i also tried it with tonumber (mylevel) and got the same result. Why would mylevel be nil and is it possible just to refer to the global variable directly? The help is greatly appreciated.
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 21 Dec 2006 10:36 PM (UTC) |
Message
| Have a look at the documentation for GetVariable. The examples there should help:
http://www.gammon.com.au/scripts/doc.php?function=GetVariable
You want:
local mylevel = GetVariable ("clevel")
That is, assigning the MUSHclient variable "clevel" into the script variable "mylevel".
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Burzmali
(10 posts) Bio
|
Date
| Reply #4 on Fri 22 Dec 2006 12:38 AM (UTC) |
Message
| Thanks, that got it working. | 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.
17,067 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top