Register forum user name Search FAQ

Gammon Forum

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.
 Entire forum ➜ MUSHclient ➜ General ➜ Ok, this SHOULD work, but it isn't

Ok, this SHOULD work, but it isn't

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


Posted by David Berthiaume   (202 posts)  Bio
Date Fri 10 Dec 2004 03:44 PM (UTC)
Message
dim killcount
killcount = world.getvariable ("AAAKillCount")

if killcount = cint(world.getvariable ("AAADeathCount")) then
world.note "It's working, " & killcount & " killed."
killcount = 0
world.setvariable "AAAKillCount", killcount
for i = 1 to cint(world.getvariable("AAADeathWalk"))
world.send "east"
world.send "west"
next
world.send "put all.cor barrel"
world.doafter 6, "kill dummy"
else
killcount = killcount + 1
world.setvariable "AAAKillCount", killcount
world.note "My kill count is: " & world.getvariable ("AAAKillCount")
world.send "kill dummy"
end if


The problem is it does the loop wrong... It always does the first part of the if statement, it never seems to do the second part of the statement.

I think the problem is in the operator....

I dunno, I've not had much luck in greater than or equal to, or less than or equal to
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #1 on Fri 10 Dec 2004 03:45 PM (UTC)
Message
Oh yeah, and the variables are all set at the apropriate numbers

AAADeathwalk = 20
AAADeathCount = 19
AAAKillCount = 1
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #2 on Fri 10 Dec 2004 04:16 PM (UTC)
Message
Make it note the two variables and see if they work? I usually use Int instead of CInt.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Tsunami   USA  (204 posts)  Bio
Date Reply #3 on Fri 10 Dec 2004 04:24 PM (UTC)
Message
killcount is a string, because you're not cint'ing it. However, you are comparing it to cint(world.getvariable ("AAADeathCount")), which IS an integer. I hope that solves it.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #4 on Fri 10 Dec 2004 10:00 PM (UTC)
Message

dim killcount
killcount = world.getvariable ("AAAKillCount")
killcount = killcount + 1
world.setvariable "AAAKillCount", killcount
if world.getvariable ("AAAKillCount") = world.getvariable ("AAADeathCount") then
killcount = 0
world.send "put all.cor barrel"
world.setvariable "AAAKillCount", killcount
    for i = 1 to cint(world.getvariable("AAADeathWalk"))
    world.send "east"
    world.send "west"
next
else
world.send "kill dummy"
end if


Final working version. Thanks for the help. Much appreciated
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Fri 10 Dec 2004 11:52 PM (UTC)
Message
You are better off doing CInt everywhere to make everything integers, rather than taking them out and having them all strings.

For example:


A = "20"
B = "0020"

if A = B then
 -- will be FALSE - the strings are different


A = "20"
B = "100"

if A < B then
 -- will be FALSE - you are comparing strings, not numbers


- 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.


17,245 views.

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

Go to topic:           Search the forum


[Go to top] top

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