Jump to content




attempt to call nil error


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

#1 Soulack

  • New Members
  • 2 posts

Posted 12 September 2013 - 10:43 AM

Can´t open an own topic, so i ask here if that okay :)
I´m german, so i used german words in the code, sorry.

problem:
attempt to call number
or
attempt to call nil

server
code is really big, so just an example
function sx() -- function to set x
write("X: ")
x1 = tonumber(read())
if x1 == "x" then
os.reboot()
elseif not tonumber(x1) then
print("Es wurde keine Zahl eingegeben!")
sleep(1)
sx()
end
end

Same for y and z


function h()
write("H: ")
h1 = tonumber(read())
if h1 == "x" then
os.reboot()
elseif not tonumber(h1) then
print("Es wurde keine Zahl eingegeben!")
sleep(3)
h()
end

end

shell.run("clear")
print("--------------")
print("I Beenden I")
print("--------------")
print("")
print("-----------")
print("I Weiter I")
print("-----------")
daten()

while true do
mouse()

if y >= 5 and y <= 7 and x >= 1 and x <= 10 then -- Position Button 1
shell.run("clear")
daten()
print("")
sx()
sy()
sz()
h()

rednet.send(id, "satellit")
a, msg, b = rednet.receive(15)
print(msg)
rednet.send(id, x1)
rednet.send(id, y1)
rednet.send(id, z1)
rednet.send(id, h1)
a, msg, b = rednet.receive(15)

receiver
only example.
if hauptpc == true then
local x1, y1, z1 = gps.locate(10)
if x1 == nil then
                rednet.send(id, "no signal")
os.reboot()
else
rednet.send(id, "koords")
a, setx, b = rednet.receive()
a, sety, b = rednet.receive()
a, setz, b = rednet.receive()
a, seth, b = rednet.receive()

if not tonumber(setx) or not tonumber(sety) or not tonumber(setz) then
rednet.send(id, "error")
os.reboot()
end

example:
type in 1500 47 20 30 -> and get "error"
If i use
height = seth - sety
I get attempt to compare nil

Anyone can help me? :S

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 12 September 2013 - 11:43 AM

Split into new topic.

You really need to go read ALL of the sticky posts, both of the global ones and the New Members and Before Asking Questions topics here in Ask a Pro. If you had done this, you wouldn't have posted your question in the wrong place.

#3 Soulack

  • New Members
  • 2 posts

Posted 12 September 2013 - 05:12 PM

Found the problem in the code, my turtle receives wrong information ;)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users