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
➜ VBscript
➜ Declaring and initializing with world.getvariable
Declaring and initializing with world.getvariable
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Dabura
(11 posts) Bio
|
Date
| Tue 29 Mar 2005 11:42 PM (UTC) |
Message
| I've got a problem with a script. In fact, there's several. The script is also too large to be pasted here. If anyone wants to contact me at "the kourck" on AIM or kyoranu88@hotmail.com (email and MSN), please do so. I'd really like to get this working. | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #1 on Tue 29 Mar 2005 11:47 PM (UTC) |
Message
| You can split up the script if it's too large, and make multiple posts. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #2 on Tue 29 Mar 2005 11:53 PM (UTC) |
Message
| Or if you can isolate the problem areas you can just post them (and the stuff they rely on). Of course with a complicated script, that could be hard to discern (on both accounts). If you have a lot of repetative functions that are identical (except for spell name or whatnot) you can get rid of most of the iterations.
And please be sure to retitle the thread once we've figured out what the problem is (for archival purposes, it makes searching a whole lot easier a year down the road). |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Dabura
(11 posts) Bio
|
Date
| Reply #3 on Wed 30 Mar 2005 12:14 AM (UTC) |
Message
| I always hated doing this on a forum because it makes me feel so stupid, it sucks.
I've written a little sub that will check my if my defenses are on or off and then will send appropriate messages to a notepad.. I'm going to have it triggered each time one of my defenses' status changes (i.e. on/off messages). Here's the one I'm currently working with (because I have so many, I just decided to use this one until I get it working.)
<triggers>
<trigger
enabled="y"
group="Defenses"
match="^Your body is weathering the storm of life a little better\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>setvariable "weathering", "1"</send>
</trigger>
</triggers>
My sub's name is DefensePad. Whenever I try to call it in the send part of my trigger, it gives me an error saying there's an Expected "End" error. Whenever I try to put my sub's name in the Script box for my trigger, it says there's no Trigger sub named that (even though it's the only sub in my script file)
I'm not sure exactly how to call the sub in that trigger, and the next post will be involving some of the other error messages I've gotten fiddling around with this. | Top |
|
Posted by
| Dabura
(11 posts) Bio
|
Date
| Reply #4 on Wed 30 Mar 2005 12:20 AM (UTC) |
Message
| My sub itself goes a little like this:
sub DefensePad (name, output, wildcards)
dim boosting = world.getvariable("boosting")
dim caloric = world.getvariable("caloric")
' ... this goes on for like 23 more different ones.
' this is getting the value from my mushclient variable
' for the defense and putting it in the local variable
' but I got an error about this one time so I'm not sure
' if this is possible or if I'm doing this right.
' I might have to declare and initialize separately
world.replacenotepad "Defenses", " "
' this is to clear my Defenses pad
if (boosting = "1") then
world.appendtonotepad "Defenses", "Boosting: ON" + vbcrlf
else
world.appendtonotepad "Defenses", "Boosting: OFF" + vbcrlf
end if
' .. again there's like 24 more of these
' I got an error on the if statement one time too so I
' don't know if the syntax is right, I haven't done
' this in a while
end sub
I found out of my problems was that I have a DefensePad.txt and a DefensePad.vbs in the same folder which messed me up, but I still have soo many errors in here. Be gentle. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #5 on Wed 30 Mar 2005 04:07 AM (UTC) Amended on Wed 30 Mar 2005 04:20 AM (UTC) by Flannel
|
Message
| Having a text file and a script file shouldn't be a problem.
Just make sure your script file in MC points to the vbs one, and you should be fine.
The end problem is a matching thing, go to the line it says and check it out. Or walk through your script file and check for unpaired things.
Your sub is correct (with the arguments) and shouldn't be a problem with adding the script name, provided that you do infact have the sub in the file (and the file has been saved/reloaded into the world, and is set to the script file). So check those three things.
However, Ive written a script that handles most of this, well, its an array handling set of subroutines. You can download it here:
http://mud.bussett.com/arrays.zip
Documentation is in the script file, and the world file that comes with it shows a couple of examples (check the aliases) which basically do what you need. You can also email me and ask (emails at the top of the script file) about whatever.
It basically allows for arrays to be used (without being much more complicated than storing a value per affect, or spells, or defense in this case) as associative arrays (or a set of three arrays to be used as complete listings, see the aliases) since VBScript doesn't do associative arrays. As well as providing subroutines to save the values to MCVariables at connect/disconnect or whatever. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Dabura
(11 posts) Bio
|
Date
| Reply #6 on Wed 30 Mar 2005 04:13 AM (UTC) Amended on Wed 30 Mar 2005 04:24 AM (UTC) by Dabura
|
Message
| Well, the problem with the two files was that the .txt was empty. That was sort of just an aside.
Expected end of statement
Line in error:
dim boosting = world.getvariable("boosting")
is the error I just got, by the way.
EDIT: I just got one to work by doing something a little different, I think I know what's wrong.
EDIT2: I can't declare a variable and then initialize it to the world.getvariable. I did a dim variable and then a variable = world.getvariable("variable") seperately and it works. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #7 on Wed 30 Mar 2005 04:21 AM (UTC) Amended on Thu 07 Apr 2005 05:15 AM (UTC) by Flannel
|
Message
| Unless you declared Option Explicit (first line in script file) you don't need to declare (dim) variables.
And if you do, and want to, then you need to declare and THEN assign.
And also, your comparison (if XX == 1) needs to be DOUBLE == not just one. One is assignment, two is comparison. Everything else looks good though.
Edit: No! nevermind, VBS is single = for both. Gotta love mixing up languages, of course, you can pick ANY other language and it'll be ==, why, oh why does VB have to be so difficult? |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #8 on Thu 07 Apr 2005 04:56 AM (UTC) |
Message
|
Quote:
I can't declare a variable and then initialize it to the world.getvariable. I did a dim variable and then a variable = world.getvariable("variable") seperately and it works.
Yes that is right. You are trying to combine two statements into one:
- Dim (creating a variable)
- = (assignment) - (assigning something to a variable)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
24,167 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top