[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  usage of 'or'

usage of 'or'

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


Pages: 1 2  

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Thu 26 Jun 2003 08:05 AM (UTC)
Message
hrm, just a question, but does MUSH support 'or' in vb script? If not, whats the equivalent?

Ex:
if newhp = oldhp or newsp = oldsp then

Just wondering

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Thu 26 Jun 2003 09:40 AM (UTC)

Amended on Thu 26 Jun 2003 09:41 AM (UTC) by Flannel

Message
Yes, it does.
Mushclient loads the scripting engine, and lets it handle everything.

VBScript documentation is available, there's a link on this site, under the VBscript forum, at the top; and yes, its just standard VBscript syntax, Mushclient doesnt have its own version of VBscript.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #2 on Sat 28 Jun 2003 10:59 PM (UTC)
Message
I think you need to put each expression in brackets, so try this syntax:

if (newhp = oldhp) or (newsp = oldsp) then

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #3 on Sun 29 Jun 2003 07:22 AM (UTC)

Amended on Sun 29 Jun 2003 07:24 AM (UTC) by Neverwhere

Message
Ok, I've tried both suggestions, and it still doesnt work. Myabe its just a script problem...

Sub OnNewHp(strAliasName, strOutput, arrWildCards)
newhp = world.getvariable ("newhp")
newsp = world.getvariable ("newsp")
oldsp = world.getvariable ("newsp")
oldhp = world.getvariable ("oldhp")
totalhp = world.getvariable ("totalhp")
totalsp = world.getvariable ("totalsp")
if (newhp = oldhp) or (newsp = oldsp) then
world.setvariable "oldhp",newhp
world.setvariable "oldsp",newsp
ElseIf (newhp <> oldhp) or (newsp <> oldsp) then
hpchange = newhp-oldhp
spchange = newsp-oldsp
if (hpchange < "0") or (spchange < "0") then
World.Send "ps Hp: "&newhp&"("&totalhp&") "&hpchange&" Sp: "&newsp&"("&totalsp&") "&spchange&""
ElseIf (hpchange >= "0") or (spchange >= "0") then
World.Send "ps Hp: "&newhp&"("&totalhp&") +"&hpchange&" Sp: "&newsp&"("&totalsp&") +"&spchange&""
End If
world.setvariable "oldhp",newhp
world.setvariable "oldsp",newsp
End If
End Sub

Any Suggestions? (yes, variables work correctly. The triggers firing get the required info for them, and I've checked and double checked them)

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sun 29 Jun 2003 07:59 AM (UTC)

Amended on Sun 29 Jun 2003 08:00 AM (UTC) by Nick Gammon

Message
Can you clarify what the symptoms are? I am guessing it is not a syntax error, as you don't give a line number.

One possibility is the "string to number" issue. Variables are stored as strings, whereas you seem to be treating them as numbers. eg. something like this will not work as you expect ...


a = "22"
b = "123"

if  a < b then
  note "22 is less than 123"
else
  note "123 is less than 22"
end if


Since the first character of each string is different it will think that 123 is less than 22.

To fix this you need to convert to numbers, eg.

a = CInt ("22")
b = CInt ("123")

Similarly for your code.

- Nick Gammon

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

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #5 on Sun 29 Jun 2003 08:01 AM (UTC)

Amended on Sun 29 Jun 2003 08:09 AM (UTC) by Neverwhere

Message
actually, there is no error report. The script runs fine, but it never proforms what it is supposed to ... it runs fine when i remove all the sp things, and i was just attempting to make it run when it has sp change also. I think its got something to do with the 'or''s but i could be wrong.

[Edit]
I know that the script goes to the first statement, because it processes the
world.setvariable "oldhp",newhp
world.setvariable "oldsp",newsp
from the very first if statment even if it is false (so im assuming thats where the error lies, within the first part of the if statment?)

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Sun 29 Jun 2003 08:19 AM (UTC)
Message
I would still put the CInt into the getvariable lines, ie.

x = CInt (world.GetVariable ("Y"))

I think that will help. Also try showing what you actually get, eg.

hpchange = newhp-oldhp
spchange = newsp-oldsp

world.note "newhp = " & newhp
world.note "oldhp = " & oldhp
world.note "newsp = " & newsp
world.note "oldsp = " & oldsp
world.note "hpchange = " & hpchange
world.note "spchange = " & spchange

- Nick Gammon

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

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #7 on Sun 29 Jun 2003 08:25 AM (UTC)
Message
ok, I think its official... Its far too late to be writing script....
Quote:

newsp = world.getvariable ("newsp")
oldsp = world.getvariable ("newsp")


Its time for bed .... (thanks Nick, Im sorry I cant think straight ;p)

Night :)

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Sun 29 Jun 2003 08:28 AM (UTC)
Message
Quote:

Myabe its just a script problem...


Well, you were right. The notes I suggested would have shown that up. VB can be strange but it doesn't usually do totally the wrong thing. :)

- Nick Gammon

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

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #9 on Sun 29 Jun 2003 08:29 AM (UTC)

Amended on Sun 29 Jun 2003 08:31 AM (UTC) by Neverwhere

Message
aye, the notes helped out a lot. I was wondering why it was executing the change from newsp to oldsp even before it hit the if statment (thats where i stuck notes). Thanks again.

[Edit]

Acutally, will the CInt change the if statments? Meaning should i remove the "" around the zeros?

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Sun 29 Jun 2003 08:42 AM (UTC)
Message
It would be logical if you are dealing in numbers to get rid of the quotes. VB will probably promote the string to an int, or the int to a string, but to be sure why not do it correctly yourself?

- Nick Gammon

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

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #11 on Sun 29 Jun 2003 08:44 AM (UTC)
Message
Well, for one the MUD just went down for the next hour (rebooting) and im going to bed soon, which prohibits me from testing the script (unless there is a client-side tester?) and Im sure if I dont do it now, I wont remember in the morning. Sorry to bug you so much :/

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Neverwhere   USA  (40 posts)  [Biography] bio
Date Reply #12 on Sun 29 Jun 2003 09:10 AM (UTC)
Message
Ok, now I do have the correct variables in the script, but it still bugs... automatically executes the first if statement (i tried doing it with the CInt, and without, either way that 'or' forces it to do the first one for some reason, even tho the world.note's you gave me show that it does not equal zero)

[Without CInt]
if (hpchange = "0") or (spchange = "0") then
XXX
ElseIf (hpchange <> "0") or (spchange <> "0") then
XXX
End If

Is it the 'or' statements?

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Sun 29 Jun 2003 09:56 AM (UTC)
Message
Quote:

it does not equal zero


It? What does not equal zero? Your test is that:

if (hpchange = "0") or (spchange = "0") then


Are you saying that both hpchange and spchange are zero, yet it does the things after that if? Do you have world.notes to prove that?

Anyway, when I look at your earlier post, there is no such line.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Sun 29 Jun 2003 10:01 AM (UTC)

Amended on Sun 29 Jun 2003 10:03 AM (UTC) by Nick Gammon

Message
Let me give you a clue - there is no known fundamental bug in the way "or" works. Certainly not one that MUSHclient introduces, as it simply passes your script to the VBscript engine, and if VBscript can't do an "or" there would be thousands of programmers screaming.

Simply put in displays (world.note) after the test that you think should have passed/failed but didn't, to check what are passing to it. Remember, the line:

if A or B then

means it will pass the test if A is true or B is true. Thus, display A and B and see what is happening.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


48,314 views.

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

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]