Jump to content




problem with 'x = x + 1'


  • You cannot reply to this topic
4 replies to this topic

#1 Agent Silence

  • Members
  • 319 posts
  • Location[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)

Posted 12 May 2014 - 08:50 PM

x = 1
while true do
x = x + 1
print(x)
sleep(1)
end
all it does is print "1", any fix?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 12 May 2014 - 09:16 PM

Are you sure you don't mean something like:

x = 0
while true do
  local x = x + 1
  print(x)
  sleep(1)
end

Because the code you have above should increment just fine.

#3 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 12 May 2014 - 09:54 PM

I think its actually this:
local x = 0
while true do
x = x + 1
print(x)
sleep(1)
end

[Edit] Because don't you got to set a variable before you do the arithmetic part?

Edited by cptdeath58, 12 May 2014 - 09:56 PM.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 12 May 2014 - 11:53 PM

Your code would work fine, as does his original code. The code I posted above is the only close variant I can think of that would exhibit the symptoms he describes.

#5 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 13 May 2014 - 12:25 AM

View PostLyqyd, on 12 May 2014 - 11:53 PM, said:

Your code would work fine, as does his original code. The code I posted above is the only close variant I can think of that would exhibit the symptoms he describes.
oh ok





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users