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

Help - Easy teleport Program

Started by gheotic, 25 July 2012 - 02:08 PM
gheotic #1
Posted 25 July 2012 - 04:08 PM
Hello everyone who is reading this =)

I'm trying to make a program for a Tekkit server my friend has

I have 1 monitor in the middle in the ground then i got 1 teleporter for each side of it except top and bottom ofc.
Im trying to make a program that gives you 4 places that you can teleport to like: Town - friend's house
i have only tried to make it work for just 1 destination so fare.
but i have some problems with this script it seems like the read() doesn't get the right number or something because it just give me the msg invalid dest.


local side = nil
local input = nil
term.clear()
term.setCursorPos(1,1)
print("Where do you wana teleport to?")
term.setCursorPos(1,2)
print("1-2-3-4")
input = read()
if input == 1 then
side = front
rs.setOutput(side,true)
sleep(5)
rs.setOutput(side,false)
print("teleported")
else
print(dist)
print("invalid dist")
end

[attachment=340:2012-07-25_16.56.24.png] [attachment=341:2012-07-25_16.56.33.png] [attachment=342:2012-07-25_17.05.58.png]

Does anyone know why?
or does anyone have some suggestions?
1lann #2
Posted 25 July 2012 - 04:43 PM
Hello everyone who is reading this =)

I'm trying to make a program for a Tekkit server my friend has

I have 1 monitor in the middle in the ground then i got 1 teleporter for each side of it except top and bottom ofc.
Im trying to make a program that gives you 4 places that you can teleport to like: Town - friend's house
i have only tried to make it work for just 1 destination so fare.
but i have some problems with this script it seems like the read() doesn't get the right number or something because it just give me the msg invalid dest.


local side = nil
local input = nil
term.clear()
term.setCursorPos(1,1)
print("Where do you wana teleport to?")
term.setCursorPos(1,2)
print("1-2-3-4")
input = read()
if input == 1 then
side = front
rs.setOutput(side,true)
sleep(5)
rs.setOutput(side,false)
print("teleported")
else
print(dist)
print("invalid dist")
end

[attachment=340:2012-07-25_16.56.24.png] [attachment=341:2012-07-25_16.56.33.png] [attachment=342:2012-07-25_17.05.58.png]

Does anyone know why?
or does anyone have some suggestions?

since read() reads input as a string, you need to do
if input == "1" then
BigSHinyToys #3
Posted 25 July 2012 - 04:52 PM
Ignore the above post he is wrong (I mean no offense as you insertion to help was nobal)
My apologizes this would work as well

read() creates a string example "5" what you want is a number 5 yes so you must convert the string to a number . luckily enough there is a function for this tonumber()

try this line
input = tonumber(read())

ALSO
side = front
should be
side = "front"
as this is a string not a variable.

and where does the vaible dist come from
print(dist) this should be something else
print(input) maybe
gheotic #4
Posted 26 July 2012 - 02:39 AM
Thank you so much =) i really do appreciate you time =)