[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]  General
. . -> [Subject]  Problems With Scripting Variables

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Problems With Scripting Variables
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 05 Jan 2002 06:05 AM (UTC)  quote  ]
Message
Well, that only applies to the player name. If you have to set a lot of them you could make a small sub that sets a player name to a value, eg.


sub setvalue (playername, newvalue)
  world.setvariable replace (playername, " ", "_"), newvalue
end sub


Then use that in place of the "setvariable" you currently do. You could do that with a global find-and-replace.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Sat 05 Jan 2002 03:12 AM (UTC)  quote  ]
Message
Isn't there a simpler way of doing it (I have alot of variables)
[Go to top] top

Posted by Storm Dragon   Denmark  (45 posts)  [Biography] bio
Date Fri 04 Jan 2002 12:00 PM (UTC)  quote  ]
Message
... Was not aware there was such a routine
*shrug* Well I only know the old basic stuff :P
and I have no manuals on VB either.. it is nice to learn new stuff :)
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 04 Jan 2002 12:44 AM (UTC)  quote  ]
Message
I had in mind something a bit simpler, using "replace". :)

Try this:


/world.note replace ("Nick Gammon wrote MUSHclient", " ", "_")


So, just use "replace" when you store the variable name, eg.


world.setvariable replace (playername, " ", "_"), contents


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Storm Dragon   Denmark  (45 posts)  [Biography] bio
Date Thu 03 Jan 2002 09:34 PM (UTC)  quote  ]

Amended on Thu 03 Jan 2002 09:35 PM (UTC) by Storm Dragon

Message
*cough* *cough*

Well.... lets see..

public SDfinal

sub SpaceToUnderscore(Incomming)
 dim x
 'This sub should convert spaces into underscores *shiver*
 SDfinal = ""
 for x = 1 to len(Incomming)
  if mid(Incomming, x, 1) = " " then
   SDfinal = SDfinal & "_"
  else
   SDfinal = SDfinal & mid(Incomming, x, 1)
  end if
 next
end sub

sub testscript(TrigName, TrigLine, WildCards)
 call SpaceToUnderscore(WildCards(1))
 world.setvariable SDfinal, "100"
end sub


I hope you can see what this does, I'm too lazy to explain at the moment and too lazy to include too many remark lines
good luck

ah yes, and you can easilly invert it too
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 03 Jan 2002 09:12 PM (UTC)  quote  ]
Message
Replace the space in the variable name with an underscore, when storing it, and replace the underscore with a space if you need to get it back.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Thu 03 Jan 2002 04:16 PM (UTC)  quote  ]
Message
New problem...
People that have a space in they're name (eg. Storm Dragon) are joining.. and no variable is being created for them (Because you can have spaces in variables)

How can I fix this?

No idea how to even start this... :(

~Rhinoa~
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 01 Jan 2002 07:03 AM (UTC)  quote  ]
Message
Quote:

I know there is a character in VB to notify it to split a line in two, I cant remember it now though


That character is the underscore (_). eg.


if arrWildCards (2) * 100 > _
world.getvariable (arrWildCards (1) & "Gold") * 1 then



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Wed 26 Dec 2001 01:22 PM (UTC)  quote  ]
Message
Actually that didn't work.. and only seemed to work the first time I tried it =(

I've got it done now though, using the code you suggested..

sub CalculateBuyPokeBalls (strName, trig_line, arrWildCards)
if arrWildCards (2) * 100 > world.getvariable (arrWildCards (1) & "Gold") * 1 then
world.send "wh " & arrWildCards (1) & " You do not have enough Gold to purchase " & arrWildCards (2) & " Pokeballs!" 
end if
if arrWildCards (2) * 100 =< world.getvariable (arrWildCards (1) & "Gold") * 1 then
world.send "wh " & arrWildCards (1) & " " & arrWildCards(2) & " Pokeballs have been added to your account! " & arrWildCards (2) * 100 & " Gold has been removed from your account!" 
end if
end sub


The only thing missing was the * 1 with the Gold variable.. and the arrwildcards (1) and get variable needed to be switched. (Don't know why.. just seems to work that way)other then that, it all worked.

~Rhinoa~
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Wed 26 Dec 2001 12:14 PM (UTC)  quote  ]
Message
Thanx, that works nicely..

and sorry about the last code... I was in a rush and wasn't thinking about I was typing =(

~Rhinoa~
[Go to top] top

Posted by Storm Dragon   Denmark  (45 posts)  [Biography] bio
Date Wed 26 Dec 2001 10:24 AM (UTC)  quote  ]
Message
Before:
if world.getvariable (arrWildCards (1) & "Gold") < arrWildCards & (2) * 100 then world.send "say " & arrWildCards & (1) & ", You do not have enough Gold to purchase " & arrWildCards & (2) & " Potions!"
if world.getvariable (arrWildCards & (1) & "Gold")>= arrWildCards & (2) * 100 then world.send "say " & arrWildCards (1) & " " & arrWildCards & (2) & " Potions have been added to your account! " & arrWildCards & (2) * 100 & " Gold has been removed from your account!" 


Wrong : arrWildCards & (1)

Right : arrWildcards(1)

you made those errors throughout most of the lines.

Now:
if world.getvariable (arrWildCards(1) & "Gold") < arrWildCards(2) * 100 then
  world.send "say " & arrWildCards(1) & ", You do not have enough Gold to purchase " & arrWildCards(2) & " Potions!" 
end if
if world.getvariable (arrWildCards(1) & "Gold") >= arrWildCards(2) * 100 then
  world.send "say " & arrWildCards(1) & " " & arrWildCards(2) & " Potions have been added to your account! " & arrWildCards(2) * 100 & " Gold has been removed from your account!" 
end if


Ok.. when writing your own code remember to make it look nice, I can understand it better if it is not cluttered up
split the lines, I know there is a character in VB to notify it to split a line in two, I cant remember it now though
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Tue 25 Dec 2001 08:32 PM (UTC)  quote  ]
Message
Thanks! That works lovely! :)

New problem though...

I have Variables containing a "money" stat, and when the player gets enough money.. they can buy potions..

Now, the potions cost 100 each... so the player will say "Buy 5 potions" the potions will be added to the players stats, and the correct amount of money will be removed from the stats.

Now... how can I do this?

Like always, I've been experimenting, and have come up with this:

if world.getvariable (arrWildCards (1) & "Gold") < arrWildCards & (2) * 100 then world.send "say " & arrWildCards & (1) & ", You do not have enough Gold to purchase " & arrWildCards & (2) & " Potions!"
if world.getvariable (arrWildCards & (1) & "Gold")>= arrWildCards & (2) * 100 then world.send "say " & arrWildCards (1) & " " & arrWildCards & (2) & " Potions have been added to your account! " & arrWildCards & (2) * 100 & " Gold has been removed from your account!"


But like always, it doesn't work :)

~Rhinoa~
[Go to top] top

Posted by Storm Dragon   Denmark  (45 posts)  [Biography] bio
Date Tue 25 Dec 2001 05:55 PM (UTC)  quote  ]
Message
 if mid(lcase(world.getvariable(arrWildCards(1) & "Slot1")),1,7) = "(empty)" then
  world.send "say " & arrWildCards (1) & ", You do not currently have anything in that slot"
 else
  world.send "say " & arrWildCards (1) & "" & world.getvariable (arrWildCards (1) & "slot1") & ""
 end if


Hmm... it did look alright before too, but try the above instead
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Tue 25 Dec 2001 12:51 PM (UTC)  quote  ]
Message
New problem..

Some of my variables contain "(Empty)" because they won't be used until that player does certain things...

Now... when someone says "Blah blah slot 1"
It says back all the variables that contain the "(empty)" word... and I don't want it to..
How can I fix this?
I've been experimenting, and have come up with this..

if world.getvariable (arrWildCards (1) & "Slot1") = ("(Empty)") then
world.send "say " & arrWildCards (1) & ", You do not currently have anything in that slot"
else
world.send "say " & arrWildCards (1) & "" & world.getvariable (arrWildCards (1) & "slot1") & ""
end if


But.. of course.. if that worked, I wouldn't be putting it here...
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Mon 24 Dec 2001 11:28 AM (UTC)  quote  ]
Message
Thanks! I can't test it just yet... but it makes alot of sense... and I'm sure it'll work!


~Rhinoa~
[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.


4,392 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[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]