Difference between revisions of "Jumpdrive Script by GamePlayer"
Jump to navigation
Jump to search
GamePlayer (talk | contribs) m |
GamePlayer (talk | contribs) |
||
Line 8: | Line 8: | ||
=== Informations === | === 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". | + | 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". Have fun! |
=== JumpDrive settings X, Y, Z === | === JumpDrive settings X, Y, Z === | ||
Line 72: | Line 72: | ||
* '''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. (Warning: First set the jumpdrive command: jd_set) | * '''jd_coords''' - Checking actual position. (Warning: First set the jumpdrive command: jd_set) | ||
+ | * '''jd_sethome''' - Set home on jumpdrive location. | ||
+ | * '''jd_gohome''' - Go to home position. | ||
+ | * '''jd_setscan''' - Setup coords of start scan (only Y). | ||
− | Code: | + | |
+ | Code (version: 1.4): | ||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
Line 148: | Line 152: | ||
end | end | ||
end | end | ||
+ | end | ||
+ | if not(mem.sss) then | ||
+ | mem.sdefault = 6000 | ||
+ | end | ||
+ | if(mem.sss == "1") then | ||
+ | if(event.type == "digiline" and event.channel == "kb") then | ||
+ | mem.sdefault = event.msg | ||
+ | mem.sss = "2" | ||
+ | end | ||
+ | end | ||
+ | if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_setscan") then | ||
+ | digiline_send("LCD","JD >> Set scan point:") | ||
+ | mem.sss = "1" | ||
end | end | ||
if(mem.scanf == "1") then | if(mem.scanf == "1") then | ||
if(mem.startscan == "1") then | if(mem.startscan == "1") then | ||
− | mem.scany = | + | mem.scany = mem.sdefault |
mem.startscan = "0" | mem.startscan = "0" | ||
mem.postep = 0 | mem.postep = 0 | ||
end | end | ||
mem.postep = mem.postep + 1 | mem.postep = mem.postep + 1 | ||
− | digiline_send("LCD", mem.postep.." on 80 | + | digiline_send("LCD", mem.postep.." on 80 - "..mem.y.." Y") |
jd_set(mem.x, mem.scany, mem.z) | jd_set(mem.x, mem.scany, mem.z) | ||
jd_show() | jd_show() | ||
Line 183: | Line 200: | ||
digiline_send("LCD","Z: "..mem.z) | digiline_send("LCD","Z: "..mem.z) | ||
end | end | ||
+ | if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_sethome") then | ||
+ | mem.homex = mem.x | ||
+ | mem.homey = mem.y | ||
+ | mem.homez = mem.z | ||
+ | digiline_send("LCD","JD Home >> Home setuped!") | ||
+ | end | ||
+ | if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_gohome") then | ||
+ | mem.x = mem.homex | ||
+ | mem.y = mem.homey | ||
+ | mem.z = mem.homez | ||
+ | jd_set(mem.x, mem.y, mem.z) | ||
+ | digiline_send("LCD","JD Home >> Teleportation!") | ||
+ | jd_jump() | ||
+ | end | ||
+ | interrupt(2) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:GetSpacePlaces]] | [[Category:GetSpacePlaces]] | ||
[[Category:Spaceship design]] | [[Category:Spaceship design]] |
Revision as of 07:51, 7 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". 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. (Warning: First set the jumpdrive command: jd_set)
- jd_sethome - Set home on jumpdrive location.
- jd_gohome - Go to home position.
- jd_setscan - Setup coords of start scan (only Y).
Code (version: 1.4):
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 not(mem.sss) then
mem.sdefault = 6000
end
if(mem.sss == "1") then
if(event.type == "digiline" and event.channel == "kb") then
mem.sdefault = event.msg
mem.sss = "2"
end
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_setscan") then
digiline_send("LCD","JD >> Set scan point:")
mem.sss = "1"
end
if(mem.scanf == "1") then
if(mem.startscan == "1") then
mem.scany = mem.sdefault
mem.startscan = "0"
mem.postep = 0
end
mem.postep = mem.postep + 1
digiline_send("LCD", mem.postep.." on 80 - "..mem.y.." Y")
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
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_sethome") then
mem.homex = mem.x
mem.homey = mem.y
mem.homez = mem.z
digiline_send("LCD","JD Home >> Home setuped!")
end
if(event.type == "digiline" and event.channel == "kb" and event.msg == "jd_gohome") then
mem.x = mem.homex
mem.y = mem.homey
mem.z = mem.homez
jd_set(mem.x, mem.y, mem.z)
digiline_send("LCD","JD Home >> Teleportation!")
jd_jump()
end
interrupt(2)