Ok, this SHOULD work, but it isn't

Posted by David Berthiaume on Fri 10 Dec 2004 03:44 PM — 6 posts, 23,672 views.

#0
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
#1
Oh yeah, and the variables are all set at the apropriate numbers

AAADeathwalk = 20
AAADeathCount = 19
AAAKillCount = 1
Greece #2
Make it note the two variables and see if they work? I usually use Int instead of CInt.
USA #3
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.
#4

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
Australia Forum Administrator #5
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