This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RedstonersElite's profile picture

ICBM Target entering issue

Started by RedstonersElite, 01 February 2014 - 07:41 PM
RedstonersElite #1
Posted 01 February 2014 - 08:41 PM
Im trying to enter coords into the icbm launcher but the issue is if i did icbm.setTarget(a,b,c) and i enter coords using read() it would work for it but id get invaild parameters.


term.clear()
term.setCursorPos(1,1)
write("X:")
a = read()
term.clear()
term.setCursorPos(1,1)
write("Y:")
b = read()
term.clear()
term.setCursorPos(1,1)
write("Z:")
c = read()
print(a,b,c)
icbm = peripheral.wrap("back")
while true do
icbm.setTarget(a, b, c)
break
end
Lyqyd #2
Posted 01 February 2014 - 08:43 PM
read() returns strings, but setTarget probably wants numbers. You can use tonumber to change your numeric strings into numbers. You'd probably want to change your read statements to:


local a = tonumber(read())
RedstonersElite #3
Posted 01 February 2014 - 08:51 PM
read() returns strings, but setTarget probably wants numbers. You can use tonumber to change your numeric strings into numbers. You'd probably want to change your read statements to:


local a = tonumber(read())

Thanks you guys replied pretty fast huge help me and my friend were doing this for a long time.