Compare commits

..

No commits in common. "main" and "0.01" have entirely different histories.
main ... 0.01

View file

@ -1,4 +1,8 @@
local fwv = "0.02"
-- Based off https://oc.cil.li/topic/1570-drone-controll-bios/
-- Modified by enthusiasticGeek to give the drone inventory capabilities, as well as the ability to update itself without disassembly.
-- Version 0.01
local fwv = "0.01"
local d = component.proxy(component.list("drone")())
local t = component.proxy(component.list("modem")())
local eeprom = component.proxy(component.list("eeprom")())
@ -6,32 +10,25 @@ local interweb = component.proxy(component.list("internet")())
local str = string
local fwaddress = "https://raw.githubusercontent.com/DremOSDeveloperTeam/opencomputers-drone/master/drone.lua"
local commport = 6500
local idle_color = 0xFF00FF
local cmdrec_color = 0xFF00FF
local cmdacc_color = 0xFFFFFF
t.open(6500)
function sendMsg(msg)
t.broadcast(commport,d.name(),"up",msg)
end
while true do
d.setLightColor(idle_color)
d.setLightColor(0x0000FF)
local evt,_,sender,port,_,name,cmd,a,b,c = computer.pullSignal()
d.setLightColor(cmdrec_color)
d.setLightColor(0xFFFFFF)
if evt == "modem_message" and name == d.name() then
d.setLightColor(cmdacc_color)
d.setLightColor(0xFF00FF)
if cmd == "gfw" then -- Get Firmware Version
sendMsg(fwv)
t.broadcast(commport, fwv)
end
if cmd == "ufw" then -- Update Firmware.
if cmd == "ufw" then -- Update Firmware. Essentially stolen from https://github.com/osmarks/oc-drone/
local web_request = interweb.request(fwaddress)
sendMsg("Updating firmware...")
sendMsg(" Connecting...")
t.broadcast(commport, "Updating firmware...")
t.broadcast(commport, " Connecting...")
web_request.finishConnect()
sendMsg(" Connected!")
sendMsg(" Downloading new firmware...")
t.broadcast(commport, " Connected!")
t.broadcast(commport, " Downloading new firmware...")
local full_response = ""
while true do
local chunk = web_request.read()
@ -42,88 +39,69 @@ while true do
break
end
end
sendMsg(" Firmware file downloaded!")
sendMsg(" Flashing new firmware...")
t.broadcast(commport, " Firmware file downloaded!")
t.broadcast(commport, " Flashing new firmware...")
eeprom.set(full_response)
sendMsg(" Done flashing firmware!")
sendMsg("Update process done!")
t.broadcast(commport, " Done flashing firmware!")
t.broadcast(commport, "Update process done! Please reboot the drone for changes to take effect.")
end
if cmd == "gst" then -- Get Status Text
sendMsg(d.getStatusText())
t.broadcast(commport, d.name(),"gst",d.getStatusText())
end
if cmd == "sst" then -- Set Status Text
sendMsg(d.setStatusText(a))
end
if cmd == "gpn" then -- Get Port Number
sendMsg(commport)
end
if cmd == "spn" then -- Set Port Number
if a ~= nil and a ~= '' then
commport = a
end
t.broadcast(commport, d.name(),"sst",d.setStatusText(a))
end
if cmd == "mov" then -- MOVe
d.move(a,b,c)
end
if cmd == "gos" then -- Get OffSet
sendMsg(d.getOffset())
t.broadcast(commport, d.name(),"gos",d.getOffset())
end
if cmd == "gve" then -- Get VElocity
sendMsg(d.getVelocity())
t.broadcast(commport, d.name(),"gv",d.getVelocity())
end
if cmd == "gmv" then -- Get Max Velocity
sendMsg(d.getMaxVelocity())
t.send(commport, d.name(),"gmv",d.getMaxVelocity())
end
if cmd == "gac" then -- Get ACceleration
sendMsg(d.getAcceleration())
t.broadcast(commport, d.name(),"ga",d.getAcceleration())
end
if cmd == "sac" then -- Set ACceleration
d.setAcceleration(a)
end
if cmd == "glc" then -- Get Light Color
sendMsg(d.getLightColor())
t.broadcast(commport, d.name(),"glc",d.getLightColor())
end
if cmd == "slc" then -- Set Light Color (RGB is important!)
if b ~= nil and b ~= '' then
if b == "0" then
idle_color = a
end
if b == "1" then
cmdrec_color = a
end
if b == "2" then
cmdacc_color = a
end
end
d.setLightColor(a)
end
if cmd == "eif" then -- External Inventory Find
if cmd == "eif" then -- External Inventory Find (Instead of detect)
local b, s = d.detect(a)
sendMsg(b)
sendMsg(s)
t.broadcast(commport, d.name(),"dct",b,s)
end
if cmd == "eco" then -- External inventory COmpare
sendMsg(d.compare(a))
t.broadcast(commport, d.name(),"c",d.compare(a))
end
if cmd == "esu" then -- External inventory SUck
o = d.suck(a, b)
sendMsg(o)
t.broadcast(commport, o)
end
if cmd == "edr" then -- External inventory DRop
o = d.drop(a, b)
sendMsg(o)
t.broadcast(commport, o)
end
if cmd == "igs" then -- Internal inventory Get Slot
sendMsg(d.select())
t.broadcast(commport, d.select())
end
if cmd == "iss" then -- Internal inventory Set Slot
o = d.select(a)
sendMsg(o)
o = d.select(a)
t.broadcast(commport, o)
end
if cmd == "gis" then -- Get Inventory Size
sendMsg(d.inventorySize())
t.broadcast(commport, d.inventorySize())
end
if cmd == "gsr" then -- Get Slot space Remaining
sendMsg(d.space(a))
t.broadcast(commport, d.space(a))
end
end
end