Difference between revisions of "Jumpdrive Script by GamePlayer"

From Pandorabox
Jump to navigation Jump to search
m (Added a "Spaceship design" category)
Line 70: Line 70:
 
* '''jd_scan''' - Scaning (searching) asteroids, only you must set X and Z in jd_set
 
* '''jd_scan''' - Scaning (searching) asteroids, only you must set X and Z in jd_set
 
* '''jd_stop''' - Stoping scaning asteroids
 
* '''jd_stop''' - Stoping scaning asteroids
* '''jd_y''' - setuping Y position, enter the command and Y separately
+
* '''jd_y''' - Setuping Y position, enter the command and Y separately
 +
* '''jd_coords''' - Checking actual position.
  
 
Code:
 
Code:
Line 143: Line 144:
 
     else
 
     else
 
       mem.scany = mem.scany + 25
 
       mem.scany = mem.scany + 25
 +
      mem.y = mem.scany
 
       mem.scanf = "1"
 
       mem.scanf = "1"
 
     end
 
     end
Line 174: Line 176:
 
     digiline_send("jumpdrive", {command = "save"})
 
     digiline_send("jumpdrive", {command = "save"})
 
   end
 
   end
 +
end
 +
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_coords") then
 +
  digiline_send("LCD","JD >> Coords:")
 +
  digiline_send("LCD","X: "..mem.x)
 +
  digiline_send("LCD","Y: "..mem.y)
 +
  digiline_send("LCD","Z: "..mem.z)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 08:58, 6 May 2020

Creator

The creator of the code is GamePlayer.

Links

Jumpdrive page

Informations

Hello all! I recently wrote a code to the luacontroller to control Jumpdrive. The code and the micro tutorial below. This is open-source code and free. Default digiline channel is "jumpdrive". Version: 1.0 Have fun!

JumpDrive settings X, Y, Z

This is block to set JumpDrive. For example: jd_set(<x coords>, <y coords>, <z coords>)

local function jd_set(jdx, jdy, jdz)
  digiline_send("jumpdrive", {command="set", key ="x", value=jdx})
  digiline_send("jumpdrive", {command = "save"})
  digiline_send("jumpdrive", {command="set", key="y", value=jdy})
  digiline_send("jumpdrive", {command = "save"})
  digiline_send("jumpdrive", {command="set", key="z", value=jdz})
  digiline_send("jumpdrive", {command = "save"})
end

JumpDrive - jump block

For example: jd_jump()

local function jd_jump()
  digiline_send("jumpdrive", {command="jump"})
end

JumpDrive - show block

For example: jd_show()

local function jd_show()
  digiline_send("jumpdrive", {command="show"})
end

JumpDrive - save block

For example: jd_save()

local function jd_save()
  digiline_send("jumpdrive", {command = "save"})
end

GetSpace - Stable JD Code

To run this code, you'll need:

  • one LuaController
  • one jumpdrive
  • one keyboard
  • one LCD (or other block to display text from digilines)
  • some digilines

Default channel for keyboard: "kb" Default channel for LCD: "LCD" Default channel for JumpDrive: "jumpdrive"

Commands to keyboard:

  • jd_jump - Jump command
  • jd_set - Setuping coords: enter the command and X,Y,Z separately
  • jd_scan - Scaning (searching) asteroids, only you must set X and Z in jd_set
  • jd_stop - Stoping scaning asteroids
  • jd_y - Setuping Y position, enter the command and Y separately
  • jd_coords - Checking actual position.

Code:

local function jd_save()
  digiline_send("jumpdrive", {command = "save"})
end
local function jd_set(jdx, jdy, jdz)
  digiline_send("jumpdrive", {command = "set", key = "x", value = jdx})
  digiline_send("jumpdrive", {command = "save"})
  digiline_send("jumpdrive", {command = "set", key = "y", value = jdy})
  digiline_send("jumpdrive", {command = "save"})
  digiline_send("jumpdrive", {command = "set", key = "z", value = jdz})
  digiline_send("jumpdrive", {command = "save"})
end
local function jd_jump()
  digiline_send("jumpdrive", {command = "jump"})
end
local function jd_show()
  digiline_send("jumpdrive", {command = "show"})
end
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "3") then
  mem.z = event.msg
  mem.jdset = "0"
  digiline_send("jumpdrive", {command = "set", key = "z", value = event.msg})
  jd_save()
end
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "2") then
  mem.y = event.msg
  mem.jdset = "3"
  digiline_send("LCD", "JD >> Z:")
  digiline_send("jumpdrive", {command = "set", key = "y", value = event.msg})
  jd_save()
end
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "1") then
  mem.x = event.msg
  mem.jdset = "2"
  digiline_send("LCD", "JD >> Y:")
  digiline_send("jumpdrive", {command = "set", key = "x", value = event.msg})
  jd_save()
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_set") then
  mem.jdset = "1"
  digiline_send("LCD", "JD >> Set coordinates (X Y Z):")
  digiline_send("LCD", "JD >> X:")
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_jump") then
  digiline_send("LCD", "JD >> Starting jump!")
  jd_jump()
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_scan") then
  digiline_send("LCD", "JD >> Wait...")
  mem.startscan = "1"
  mem.scanf = "1"
end
if(event.type == "digiline" and event.channel == "jumpdrive" and event.msg.success) then
  digiline_send("LCD", "JD >> Jump done!")
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_stop") then
  mem.scanf = "0"
  digiline_send("LCD", "JD >> Scan canceled!")
end
if(mem.scanf == "2") then
  if(event.type == "digiline" and event.channel == "jumpdrive") then
    if(event.msg.success) then
      digiline_send("LCD", "JD >> Asteroid detected!")
      mem.scanf = "0"
      digiline_send("LCD", "JD >> Y: "..mem.scany)
      digiline_send("jumpdrive", {command = "set", key = "y", value = mem.scany})
      digiline_send("jumpdrive", {command = "save"})
    else
      mem.scany = mem.scany + 25
      mem.y = mem.scany
      mem.scanf = "1"
    end
  end
end
if(mem.scanf == "1") then
  if(mem.startscan == "1") then
    mem.scany = 6000
    mem.startscan = "0"
    mem.postep = 0
  end
  mem.postep = mem.postep + 1
  digiline_send("LCD", mem.postep.." on 80 elements.")
  jd_set(mem.x, mem.scany, mem.z)
  jd_show()
  mem.scanf = "2"
  if(mem.postep == 80) then
    digiline_send("LCD", "JD >> Asteroid not founded!")
    mem.scanf = "0"
  end
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_y") then
  digiline_send("LCD", "JD >> Y: ")
  mem.setdefa = "1"
end
if(mem.setdefa == "1") then
  if(event.type == "digiline" and event.channel == "kb") then
    mem.setdefa = "0"
    mem.y = event.msg
    digiline_send("jumpdrive", {command = "set", key = "y", value = mem.y})
    digiline_send("jumpdrive", {command = "save"})
  end
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_coords") then
  digiline_send("LCD","JD >> Coords:")
  digiline_send("LCD","X: "..mem.x)
  digiline_send("LCD","Y: "..mem.y)
  digiline_send("LCD","Z: "..mem.z)
end