Difference between revisions of "Jumpdrive Script by GamePlayer"

From Pandorabox
Jump to navigation Jump to search
(Created page with "__TOC__ === Creator === The creator of the code is GamePlayer. === Links === About JumpDrive: https://pandorabox.io/index.php/Jumpdrive === Informations === Hello all! I re...")
 
m (Updated formatting)
Line 13: Line 13:
 
This is block to set JumpDrive.  For example: jd_set(<x coords>, <y coords>, <z coords>)
 
This is block to set JumpDrive.  For example: jd_set(<x coords>, <y coords>, <z coords>)
  
local function jd_set(jdx, jdy, jdz)
+
<syntaxhighlight lang="Lua">
digiline_send("jumpdrive", {command="set", key ="x", value=jdx})
+
local function jd_set(jdx, jdy, jdz)
digiline_send("jumpdrive", {command = "save"})
+
  digiline_send("jumpdrive", {command="set", key ="x", value=jdx})
digiline_send("jumpdrive", {command="set", key="y", value=jdy})
+
  digiline_send("jumpdrive", {command = "save"})
digiline_send("jumpdrive", {command = "save"})
+
  digiline_send("jumpdrive", {command="set", key="y", value=jdy})
digiline_send("jumpdrive", {command="set", key="z", value=jdz})
+
  digiline_send("jumpdrive", {command = "save"})
digiline_send("jumpdrive", {command = "save"})
+
  digiline_send("jumpdrive", {command="set", key="z", value=jdz})
end
+
  digiline_send("jumpdrive", {command = "save"})
 +
end
 +
</syntaxhighlight>
  
 
=== JumpDrive - jump block ===
 
=== JumpDrive - jump block ===
 
For example: jd_jump()
 
For example: jd_jump()
  
local function jd_jump()
+
<syntaxhighlight lang="Lua">
digiline_send("jumpdrive", {command="jump"})
+
local function jd_jump()
end
+
  digiline_send("jumpdrive", {command="jump"})
 +
end
 +
</syntaxhighlight>
  
 
=== JumpDrive - show block ===
 
=== JumpDrive - show block ===
 
For example: jd_show()
 
For example: jd_show()
  
local function jd_show()
+
<syntaxhighlight lang="Lua">
digiline_send("jumpdrive", {command="show"})
+
local function jd_show()
end
+
  digiline_send("jumpdrive", {command="show"})
 +
end
 +
</syntaxhighlight>
  
 
=== JumpDrive - save block ===
 
=== JumpDrive - save block ===
 
For example: jd_save()
 
For example: jd_save()
  
local function jd_save()
+
<syntaxhighlight lang="Lua">
digiline_send("jumpdrive", {command = "save"})
+
local function jd_save()
end
+
  digiline_send("jumpdrive", {command = "save"})
 +
end
 +
</syntaxhighlight>
  
 
=== GetSpace - Stable JD Code ===
 
=== GetSpace - Stable JD Code ===
To run this code you need: luacontroller x1, jumpdrive x1, keyboard x1, LCD (or something else) x1, some digilines.
+
To run this code, you'll need:
Default channel for keyboard: "kb"
+
 
Default channel for LCD: "LCD"
+
* one LuaController
Default channel for JumpDrive: "jumpdrive"
+
* 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:
 
Commands to keyboard:
jd_jump - Jump command
+
 
jd_set - Setuping coords: enter the command and X,Y,Z separately
+
* '''jd_jump''' - Jump command
jd_scan - Scaning (searching) asteroids, only you must set X and Z in jd_set
+
* '''jd_set''' - Setuping coords: enter the command and X,Y,Z separately
jd_stop - Stoping scaning asteroids
+
* '''jd_scan''' - Scaning (searching) asteroids, only you must set X and Z in jd_set
jd_y - setuping Y position, enter the command and Y separately
+
* '''jd_stop''' - Stoping scaning asteroids
 +
* '''jd_y''' - setuping Y position, enter the command and Y separately
  
 
Code:
 
Code:
local function jd_save()
+
 
digiline_send("jumpdrive", {command = "save"})
+
<syntaxhighlight lang="Lua">
end
+
local function jd_save()
local function jd_set(jdx, jdy, jdz)
+
  digiline_send("jumpdrive", {command = "save"})
digiline_send("jumpdrive", {command="set", key ="x", value=jdx})
+
end
digiline_send("jumpdrive", {command = "save"})
+
local function jd_set(jdx, jdy, jdz)
digiline_send("jumpdrive", {command="set", key="y", value=jdy})
+
  digiline_send("jumpdrive", {command = "set", key = "x", value = jdx})
digiline_send("jumpdrive", {command = "save"})
+
  digiline_send("jumpdrive", {command = "save"})
digiline_send("jumpdrive", {command="set", key="z", value=jdz})
+
  digiline_send("jumpdrive", {command = "set", key = "y", value = jdy})
digiline_send("jumpdrive", {command = "save"})
+
  digiline_send("jumpdrive", {command = "save"})
end
+
  digiline_send("jumpdrive", {command = "set", key = "z", value = jdz})
local function jd_jump()
+
  digiline_send("jumpdrive", {command = "save"})
digiline_send("jumpdrive", {command="jump"})
+
end
end
+
local function jd_jump()
local function jd_show()
+
  digiline_send("jumpdrive", {command = "jump"})
digiline_send("jumpdrive", {command="show"})
+
end
end
+
local function jd_show()
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "3") then
+
  digiline_send("jumpdrive", {command = "show"})
mem.z = event.msg
+
end
mem.jdset = "0"
+
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "3") then
digiline_send("jumpdrive", {command = "set", key = "z", value = event.msg})
+
  mem.z = event.msg
jd_save()
+
  mem.jdset = "0"
end
+
  digiline_send("jumpdrive", {command = "set", key = "z", value = event.msg})
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "2") then
+
  jd_save()
mem.y = event.msg
+
end
mem.jdset = "3"
+
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "2") then
digiline_send("LCD","JD >> Z:")
+
  mem.y = event.msg
digiline_send("jumpdrive", {command = "set", key = "y", value = event.msg})
+
  mem.jdset = "3"
jd_save()
+
  digiline_send("LCD", "JD >> Z:")
end
+
  digiline_send("jumpdrive", {command = "set", key = "y", value = event.msg})
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "1") then
+
  jd_save()
mem.x = event.msg
+
end
mem.jdset = "2"
+
if(event.type == "digiline" and event.channel == "kb" and mem.jdset == "1") then
digiline_send("LCD","JD >> Y:")
+
  mem.x = event.msg
digiline_send("jumpdrive", {command = "set", key = "x", value = event.msg})
+
  mem.jdset = "2"
jd_save()
+
  digiline_send("LCD", "JD >> Y:")
end
+
  digiline_send("jumpdrive", {command = "set", key = "x", value = event.msg})
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_set") then
+
  jd_save()
mem.jdset = "1"
+
end
digiline_send("LCD","JD >> Set coordinates (X Y Z):")
+
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_set") then
digiline_send("LCD","JD >> X:")
+
  mem.jdset = "1"
end
+
  digiline_send("LCD", "JD >> Set coordinates (X Y Z):")
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_jump") then
+
  digiline_send("LCD", "JD >> X:")
digiline_send("LCD","JD >> Starting jump!")
+
end
jd_jump()
+
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_jump") then
end
+
  digiline_send("LCD", "JD >> Starting jump!")
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_scan") then
+
  jd_jump()
digiline_send("LCD","JD >> Wait...")
+
end
mem.startscan = "1"
+
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_scan") then
mem.scanf = "1"
+
  digiline_send("LCD", "JD >> Wait...")
end
+
  mem.startscan = "1"
if(event.type == "digiline" and event.channel == "jumpdrive" and event.msg.success) then
+
  mem.scanf = "1"
digiline_send("LCD","JD >> Jump done!")
+
end
end
+
if(event.type == "digiline" and event.channel == "jumpdrive" and event.msg.success) then
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_stop") then
+
  digiline_send("LCD", "JD >> Jump done!")
mem.scanf = "0"
+
end
digiline_send("LCD","JD >> Scan canceled!")
+
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_stop") then
end
+
  mem.scanf = "0"
if(mem.scanf == "2") then
+
  digiline_send("LCD", "JD >> Scan canceled!")
if(event.type == "digiline" and event.channel == "jumpdrive") then
+
end
if(event.msg.success) then
+
if(mem.scanf == "2") then
digiline_send("LCD","JD >> Asteroid detected!")
+
  if(event.type == "digiline" and event.channel == "jumpdrive") then
mem.scanf = "0"
+
    if(event.msg.success) then
digiline_send("LCD", "JD >> Y: "..mem.scany)
+
      digiline_send("LCD", "JD >> Asteroid detected!")
digiline_send("jumpdrive", {command = "set", key = "y", value = mem.scany})
+
      mem.scanf = "0"
digiline_send("jumpdrive", {command = "save"})
+
      digiline_send("LCD", "JD >> Y: "..mem.scany)
else
+
      digiline_send("jumpdrive", {command = "set", key = "y", value = mem.scany})
mem.scany = mem.scany + 25
+
      digiline_send("jumpdrive", {command = "save"})
mem.scanf = "1"
+
    else
end
+
      mem.scany = mem.scany + 25
end
+
      mem.scanf = "1"
end
+
    end
if(mem.scanf == "1") then
+
  end
if(mem.startscan == "1") then
+
end
mem.scany = 6000
+
if(mem.scanf == "1") then
mem.startscan = "0"
+
  if(mem.startscan == "1") then
mem.postep = 0
+
    mem.scany = 6000
end
+
    mem.startscan = "0"
mem.postep = mem.postep + 1
+
    mem.postep = 0
digiline_send("LCD", mem.postep.." na 80")
+
  end
jd_set(mem.x, mem.scany, mem.z)
+
  mem.postep = mem.postep + 1
jd_show()
+
  digiline_send("LCD", mem.postep.." na 80")
mem.scanf = "2"
+
  jd_set(mem.x, mem.scany, mem.z)
if(mem.postep == 80) then
+
  jd_show()
digiline_send("LCD","JD >> Asteroid not founded!")
+
  mem.scanf = "2"
mem.scanf = "0"
+
  if(mem.postep == 80) then
end
+
    digiline_send("LCD", "JD >> Asteroid not founded!")
end
+
    mem.scanf = "0"
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_y") then
+
  end
digiline_send("LCD","JD >> Y: ")
+
end
mem.setdefa = "1"
+
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_y") then
end
+
  digiline_send("LCD", "JD >> Y: ")
if(mem.setdefa == "1") then
+
  mem.setdefa = "1"
if(event.type == "digiline" and event.channel == "kb") then
+
end
mem.setdefa = "0"
+
if(mem.setdefa == "1") then
mem.y = event.msg
+
  if(event.type == "digiline" and event.channel == "kb") then
digiline_send("jumpdrive", {command = "set", key = "y", value = mem.y})
+
    mem.setdefa = "0"
digiline_send("jumpdrive", {command = "save"})
+
    mem.y = event.msg
end
+
    digiline_send("jumpdrive", {command = "set", key = "y", value = mem.y})
end
+
    digiline_send("jumpdrive", {command = "save"})
 +
  end
 +
end
 +
</syntaxhighlight>
  
 
[[Category:GetSpacePlaces]]
 
[[Category:GetSpacePlaces]]

Revision as of 17:57, 5 May 2020

Creator

The creator of the code is GamePlayer.

Links

About JumpDrive: https://pandorabox.io/index.php/Jumpdrive

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

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.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.." na 80")
  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