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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Ok, this SHOULD work, but it isn't
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Ok, this SHOULD work, but it isn't

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


Posted by David Berthiaume   (202 posts)  [Biography] 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
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] 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
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] 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!
[Go to top] top

Posted by Tsunami   USA  (204 posts)  [Biography] 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.
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,407 posts)  [Biography] 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
[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,354 views.

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