Difference between revisions of "Digiline Jumpdrive controller"

From Pandorabox
Jump to navigation Jump to search
Line 92: Line 92:
  
 
[[Category:Tutorial]]
 
[[Category:Tutorial]]
 +
[[Category:Digiline]]
 
[[Category:Spaceship design]]
 
[[Category:Spaceship design]]

Revision as of 06:23, 27 September 2019

Overview

Simple digiline jumpdrive controller

Features:

  • Allows for step-jumping into all 6 directions
  • Sethome / go-home button
  • Lock button

Lua Controller

Version history:

-- version 1.0

if event.type == "program" then
 digiline_send("touch", { command = "clear" })

 digiline_send("touch", {  command = "addbutton_exit",  name="xplus",  label="X+",  X=0, Y=0, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="xminus",  label="X-",  X=0, Y=1, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="yplus",  label="Y+",  X=0, Y=2, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="yminus",  label="Y-",  X=0, Y=3, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="zplus",  label="Z+",  X=0, Y=4, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="zminus",  label="Z-",  X=0, Y=5, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="sethome",  label="Set home",  X=4, Y=0, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="gohome",  label="Go home",  X=4, Y=1, W=4, H=1 })
 digiline_send("touch", {  command = "addbutton_exit",  name="lock",  label="Lock",  X=4, Y=5, W=4, H=1 })
end

if event.type == "digiline" and event.channel == "touch" then
 mem.touch_event = event.msg
 digiline_send("jumpdrive",  {command="get"})
end

if event.type == "digiline" and event.channel == "jumpdrive" and event.msg.target then
 local jump = false
 local increment = (event.msg.radius*2)+1
 if mem.touch_event.lock then
  digiline_send("touch", { command = "clear" })

 elseif mem.touch_event.sethome then
  mem.home = event.msg.position

 elseif mem.touch_event.gohome and mem.home then
  digiline_send("jumpdrive", {command="set", key="x", value=mem.home.x})
  digiline_send("jumpdrive", {command="set", key="y", value=mem.home.y})
  digiline_send("jumpdrive", {command="set", key="z", value=mem.home.z})
  jump = true

 elseif mem.touch_event.yplus then
  digiline_send("jumpdrive", {command="set", key="y", value=event.msg.target.y+increment})
  jump = true

 elseif mem.touch_event.yminus then
  digiline_send("jumpdrive", {command="set", key="y", value=event.msg.target.y-increment})
  jump = true

 elseif mem.touch_event.xplus then
  digiline_send("jumpdrive", {command="set", key="x", value=event.msg.target.x+increment})
  jump = true

 elseif mem.touch_event.xminus then
  digiline_send("jumpdrive", {command="set", key="x", value=event.msg.target.x-increment})
  jump = true

 elseif mem.touch_event.zplus then
  digiline_send("jumpdrive", {command="set", key="z", value=event.msg.target.z+increment})
  jump = true

 elseif mem.touch_event.zminus then
  digiline_send("jumpdrive", {command="set", key="z", value=event.msg.target.z-increment})
  jump = true

 end

 if jump then
  digiline_send("jumpdrive", {command="jump"})
 end
end

Setup