Posted 22 February 2015 - 04:32 PM
So, i decided that i really wanted an airship like the ones we used to have, so i went out and found Remain in Motion (Thx to planetguy,de3dsoul,and jakj for making it all possible). I then saw that RemIM had programmable engines. it was then that i knew…. i must make a totally awesome airship program! It is no where near finished, but the basic concept is prepared and mostly been user-proofed (aka, hard to break) so i figured now would be a decent time to post it and see if anyone was interested in it. It is actually two programs (an API and a startup) but all you have to do is download the startup program and it will snatch the AirshipAPI program if you don't already have it.
AirshipAPI
StartUp
And if you are lazy(like me xD) then here is the code to type into your computer: pastebin get nmVYPHG1 startup
also, you have to build the engine in a fairly particular way. start out facing north and place your engines in a plus pattern with the center being any block other than a carriage(engines can have only one carriage block attached or they won't work) then stick some modems on the back of them and turn those suckers on. at this point, i normally go ahead and make the frame of the engine by placing a carriage on the end of each engine and then connecting them all together in a box around the engines(remember the engines can have no other carriages touching them than the ones on the ends) then you slap a computer on top, stick a modem to the back, wire em' up with network cables and your ready to go. download the startup program and start flying! Also, as i said, this is a work in progress, i have many more planned features and will be releasing new versions as i crank them out here. An engine tutorial with pictures is in the spoiler below.
Engine Build Tutorial
You then build a frame using your carriages (I suggest the standard frame carriage) around it, again the red light can be replaced with any non-carriage blocks.
After building the frame, go to to the front side of the structure and put modems on all four engine controllers. Then hook them all together with network cable, like so:
At this step, i have added a computer onto the frame directly above the top engine. I have also added anoth modem to the back of the computer.(make sure they are all on ie. have a red ring) also, we have to make sure our cables travel with us, so i have framed the cables with carriages as well.
This is the finished product. now again, make sure there is only one carriage touching each engine, or else it won't move. as you can see from this side view, i put lights in my engine. One note that is not easily seen in this photo:If you did as i did and put a block in the middle of the engines, on the opposite side of the network cables, make sure to bring your frames through the center to grab that block, or again… your airship will not move!
on the to-do list
add a gps and waypointing system to allow one to set and travel to waypoints.
add a menu screen to startup for the various features(not needed atm, as all the program does is move the engine).
add a monitor plugin for displaying coords and distance to travel points.
possibly make monitor into more of a gui interface to control the Airship.
program a turtle to build the engine, download the startup program, place a disk drive, load the startup to the disk, then place the computer down(aka, self build/install)
any other cool ideas you or i come up with. I am open to suggestions!
AirshipAPI
Spoiler
if fs.exists("AirVar")==false then
vars={}
h=fs.open("AirVar","w")
h.write(textutils.serialize(vars))
h.close()
end
function VarsLoad()
h=fs.open("AirVar","r")
vars=textutils.unserialize(h.readAll())
h.close()
return vars
end
function VarsWrite(vars)
h=fs.open("AirVar","w")
h.write(textutils.serialize(vars))
h.close()
end
function configure()
vars=VarsLoad()
vars.moved=true
vars.perif=peripheral.getNames()
t=1
vars.carriages={}
for i=1,#vars.perif do
if peripheral.getType(vars.perif[i])=="carriage" then
vars.carriages[t]=vars.perif[i]
t=t+1
end
end
if vars.IT==nil then
print("iteration is nil. reset")
sleep(0.5)
reset()
end
VarsWrite(vars)
return vars
end
function input()
vars=VarsLoad()
vars.valid={"left","right","up","down","forward","backward"}
print("Please input direction:")
vars.direct=string.lower(read())
if direct=="" then
direct="forward"
end
for _,k in pairs(vars.valid) do
if vars.direct==k then
isValid=true
break
end
end
if isValid~=true then
return false,"Invalid Input"
end
print("Please input distance:")
vars.dist=read()
vars.dist=tonumber(vars.dist)
if type(vars.dist)~="number"then
return false,"Invalid Input"
end
if vars.dist=="" then
vars.dist = "1"
print("Distance defaulted to 1")
end
VarsWrite(vars)
return true
end
function move()
vars=VarsLoad()
temp={}
for i=1,#vars.carriages do
temp[i]=peripheral.wrap(vars.carriages[i])
end
if vars.IT==nil or vars.IT>vars.dist then
vars.IT=0
vars.dist=0
print("Distance reset")
VarsWrite(vars)
os.reboot()
end
if vars.IT~=vars.dist then
vars.IT=vars.IT+1
if vars.direct=="forward" then
print("Moving Forward")
vars.dir=5
elseif vars.direct=="backward" then
print("Moving Backwards")
vars.dir=4
elseif vars.direct=="right" then
print("Moving Right")
vars.dir=3
elseif vars.direct=="left" then
print("Moving Left")
vars.dir=2
elseif vars.direct=="up" then
print("Moving Up")
vars.dir=1
elseif vars.direct=="down" then
print("Moving Down")
vars.dir=0
else
return "Invalid"
end
VarsWrite(vars)
for k,t in pairs(temp) do
t.move(vars.dir,false,false)
num,vars.moved=t.status()
end
VarsWrite(vars)
end
end
function reset()
VarsLoad()
vars.direct="forward"
vars.dist=0
vars.IT=0
VarsWrite(vars)
end
Spoiler
os.sleep(0.1)
if fs.exists("AirshipAPI")==false then
shell.run("pastebin get","HAEadDZt","AirshipAPI")
end
os.loadAPI("AirshipAPI")
--defining variables from file to continue movement after shutdown
vars=AirshipAPI.configure()
if vars.IT~=vars.dist then
print("Moving")
AirshipAPI.move()
if vars.moved==false then
print(error.." restarting")
h=fs.open("configure","w")
h.writeLine("true")
h.close()
AirshipAPI.reset()
os.sleep(0.3)
os.reboot()
end
elseif vars.IT==vars.dist then
AirshipAPI.reset()
repeat
inp,error=AirshipAPI.input()
if inp==false then
print(error)
end
until inp==true
AirshipAPI.move()
end
And if you are lazy(like me xD) then here is the code to type into your computer: pastebin get nmVYPHG1 startup
also, you have to build the engine in a fairly particular way. start out facing north and place your engines in a plus pattern with the center being any block other than a carriage(engines can have only one carriage block attached or they won't work) then stick some modems on the back of them and turn those suckers on. at this point, i normally go ahead and make the frame of the engine by placing a carriage on the end of each engine and then connecting them all together in a box around the engines(remember the engines can have no other carriages touching them than the ones on the ends) then you slap a computer on top, stick a modem to the back, wire em' up with network cables and your ready to go. download the startup program and start flying! Also, as i said, this is a work in progress, i have many more planned features and will be releasing new versions as i crank them out here. An engine tutorial with pictures is in the spoiler below.
Engine Build Tutorial
Spoiler
the engine controllers will be laid out like this. The middle block can be any non carriage block:You then build a frame using your carriages (I suggest the standard frame carriage) around it, again the red light can be replaced with any non-carriage blocks.
After building the frame, go to to the front side of the structure and put modems on all four engine controllers. Then hook them all together with network cable, like so:
At this step, i have added a computer onto the frame directly above the top engine. I have also added anoth modem to the back of the computer.(make sure they are all on ie. have a red ring) also, we have to make sure our cables travel with us, so i have framed the cables with carriages as well.
This is the finished product. now again, make sure there is only one carriage touching each engine, or else it won't move. as you can see from this side view, i put lights in my engine. One note that is not easily seen in this photo:If you did as i did and put a block in the middle of the engines, on the opposite side of the network cables, make sure to bring your frames through the center to grab that block, or again… your airship will not move!
add a gps and waypointing system to allow one to set and travel to waypoints.
add a menu screen to startup for the various features(not needed atm, as all the program does is move the engine).
add a monitor plugin for displaying coords and distance to travel points.
possibly make monitor into more of a gui interface to control the Airship.
program a turtle to build the engine, download the startup program, place a disk drive, load the startup to the disk, then place the computer down(aka, self build/install)
any other cool ideas you or i come up with. I am open to suggestions!
Edited on 22 February 2015 - 07:21 PM