Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
raycar5

MDLI. When you just want to test some lua code in a drone (Mini drone lua interpreter)

Recommended Posts

With this eeprom you can send the drone any lua command via network message in port 123 and it will execute it and send the response as a broadcast in the same port (if there's no response you'll get a bunch of nil)


local m = component.proxy(component.list("modem")())
m.open(123)
local typ
local data
while true do 
while typ ~= "modem_message" do
typ,_,_,_,_,data = computer.pullSignal()
end
local f = assert(load(data))
w,x,y,z = f()
m.broadcast(123, w,x,y,z)
typ = nil
f = nil
end
Link to post
Share on other sites

Here's my (old) take on it.

This is loaded onto the eeprom:

https://github.com/MaHuJa/OpenComp-Scripts/blob/master/drone/remote_control.lua

And this is on the controller you have a console for

https://github.com/MaHuJa/OpenComp-Scripts/blob/master/drone/remote_controller.lua

 

Differences of note:

- Syntax errors don't crash the drone

- Runtime errors (including misspelled names) don't crash the drone

- "Unlimited" return values. This is one of the few ways to crash the drone, running it over the oc config value.

- a few "dump table" commands useful for exploring or debugging.

- first return value is always a boolean saying if it ran successfully. In the posted code above, false would instead shut down the drone.

- function com(name) for getting a component. Makes subsequent code, including user input, much less verbose.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.