Improvements on move-, fly-, and turn controllers
This commit is contained in:
parent
5597836d06
commit
793ef84a8c
@ -17,6 +17,7 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local TA4_INV_SIZE = 50
|
local TA4_INV_SIZE = 50
|
||||||
|
local EX_PIONTS = 10
|
||||||
|
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local mConf = dofile(MP.."/basis/conf_inv.lua")
|
local mConf = dofile(MP.."/basis/conf_inv.lua")
|
||||||
@ -365,7 +366,7 @@ minetest.register_node("techage:chest_ta4", {
|
|||||||
techage.remove_node(pos, oldnode, oldmetadata)
|
techage.remove_node(pos, oldnode, oldmetadata)
|
||||||
hyperloop.after_dig_node(pos, oldnode, oldmetadata, digger)
|
hyperloop.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||||
end,
|
end,
|
||||||
ta5_formspec = {menu=hyperloop.WRENCH_MENU, ex_points=10},
|
ta5_formspec = {menu=hyperloop.WRENCH_MENU, ex_points=EX_PIONTS},
|
||||||
ta_after_formspec = hyperloop.after_formspec,
|
ta_after_formspec = hyperloop.after_formspec,
|
||||||
allow_metadata_inventory_put = ta4_allow_metadata_inventory_put,
|
allow_metadata_inventory_put = ta4_allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = ta4_allow_metadata_inventory_take,
|
allow_metadata_inventory_take = ta4_allow_metadata_inventory_take,
|
||||||
|
@ -224,6 +224,10 @@ local function entity_to_node(pos, obj)
|
|||||||
local param2 = self.param2 or 0
|
local param2 = self.param2 or 0
|
||||||
local metadata = self.metadata or {}
|
local metadata = self.metadata or {}
|
||||||
detach_objects(pos, self)
|
detach_objects(pos, self)
|
||||||
|
if self.base_pos then
|
||||||
|
local nvm = techage.get_nvm(self.base_pos)
|
||||||
|
nvm.running = nil
|
||||||
|
end
|
||||||
obj:remove()
|
obj:remove()
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
@ -281,7 +285,7 @@ local function node_to_entity(start_pos)
|
|||||||
self.players = {}
|
self.players = {}
|
||||||
self.entities = {}
|
self.entities = {}
|
||||||
-- Prepare for path walk
|
-- Prepare for path walk
|
||||||
self.idx = 1
|
self.path_idx = 1
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -306,9 +310,9 @@ local function move_entity(obj, dest_pos, dir, is_corner)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function moveon_entity(obj, self, pos1)
|
local function moveon_entity(obj, self, pos1)
|
||||||
local pos2 = next_path_pos(pos1, self.lpath, self.idx)
|
local pos2 = next_path_pos(pos1, self.lpath, self.path_idx)
|
||||||
if pos2 then
|
if pos2 then
|
||||||
self.idx = self.idx + 1
|
self.path_idx = self.path_idx + 1
|
||||||
local dir = determine_dir(pos1, pos2)
|
local dir = determine_dir(pos1, pos2)
|
||||||
move_entity(obj, pos2, dir, true)
|
move_entity(obj, pos2, dir, true)
|
||||||
return true
|
return true
|
||||||
@ -321,15 +325,31 @@ local function handover_to(obj, self, pos1)
|
|||||||
if info and info.name == "techage:ta4_movecontroller" then
|
if info and info.name == "techage:ta4_movecontroller" then
|
||||||
local meta = M(info.pos)
|
local meta = M(info.pos)
|
||||||
if self.move2to1 then
|
if self.move2to1 then
|
||||||
self.handover = meta:contains("handoverB") and meta:get_string("handoverB")
|
|
||||||
else
|
|
||||||
self.handover = meta:contains("handoverA") and meta:get_string("handoverA")
|
self.handover = meta:contains("handoverA") and meta:get_string("handoverA")
|
||||||
|
else
|
||||||
|
self.handover = meta:contains("handoverB") and meta:get_string("handoverB")
|
||||||
end
|
end
|
||||||
local offs = flylib.to_vector(meta:get_string("path"))
|
|
||||||
if pos1 and offs then
|
self.lpath = flylib.to_path(meta:get_string("path"))
|
||||||
self.dest_pos = vector.add(pos1, offs)
|
if pos1 and self.lpath then
|
||||||
local dir = determine_dir(pos1, info.pos)
|
self.path_idx = 2
|
||||||
move_entity(obj, info.pos, dir)
|
if self.move2to1 then
|
||||||
|
self.lpath[1] = vector.multiply(self.lpath[1], - 1)
|
||||||
|
end
|
||||||
|
local pos2 = next_path_pos(pos1, self.lpath, 1)
|
||||||
|
local dir = determine_dir(pos1, pos2)
|
||||||
|
--print("handover_to", P2S(pos1), P2S(pos2), P2S(dir), P2S(info.pos), meta:get_string("path"))
|
||||||
|
if not self.handover then
|
||||||
|
local nvm = techage.get_nvm(info.pos)
|
||||||
|
nvm.lpos1 = nvm.lpos1 or {}
|
||||||
|
if self.move2to1 then
|
||||||
|
nvm.lpos1[self.pos1_idx] = pos2
|
||||||
|
|
||||||
|
else
|
||||||
|
nvm.lpos1[self.pos1_idx] = pos1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
move_entity(obj, pos2, dir)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -355,9 +375,11 @@ minetest.register_entity("techage:move_item", {
|
|||||||
metadata = self.metadata,
|
metadata = self.metadata,
|
||||||
move2to1 = self.move2to1,
|
move2to1 = self.move2to1,
|
||||||
handover = self.handover,
|
handover = self.handover,
|
||||||
idx = self.idx,
|
path_idx = self.path_idx,
|
||||||
|
pos1_idx = self.pos1_idx,
|
||||||
lpath = self.lpath,
|
lpath = self.lpath,
|
||||||
start_pos = self.start_pos,
|
start_pos = self.start_pos,
|
||||||
|
base_pos = self.base_pos,
|
||||||
max_speed = self.max_speed,
|
max_speed = self.max_speed,
|
||||||
dest_pos = self.dest_pos,
|
dest_pos = self.dest_pos,
|
||||||
dir = self.dir,
|
dir = self.dir,
|
||||||
@ -373,14 +395,16 @@ minetest.register_entity("techage:move_item", {
|
|||||||
self.metadata = tbl.metadata or {}
|
self.metadata = tbl.metadata or {}
|
||||||
self.move2to1 = tbl.move2to1 or false
|
self.move2to1 = tbl.move2to1 or false
|
||||||
self.handover = tbl.handover
|
self.handover = tbl.handover
|
||||||
self.idx = tbl.idx or 1
|
self.path_idx = tbl.path_idx or 1
|
||||||
|
self.pos1_idx = tbl.pos1_idx or 1
|
||||||
self.lpath = tbl.lpath or {}
|
self.lpath = tbl.lpath or {}
|
||||||
self.max_speed = tbl.max_speed or MAX_SPEED
|
self.max_speed = tbl.max_speed or MAX_SPEED
|
||||||
self.dest_pos = tbl.dest_pos or self.object:get_pos()
|
self.dest_pos = tbl.dest_pos or self.object:get_pos()
|
||||||
self.start_pos = tbl.start_pos or self.object:get_pos()
|
self.start_pos = tbl.start_pos or self.object:get_pos()
|
||||||
|
self.base_pos = tbl.base_pos
|
||||||
self.dir = tbl.dir or {x=0, y=0, z=0}
|
self.dir = tbl.dir or {x=0, y=0, z=0}
|
||||||
self.object:set_properties({wield_item = self.item})
|
self.object:set_properties({wield_item = self.item})
|
||||||
print("tbl.respawn", tbl.respawn)
|
--print("tbl.respawn", tbl.respawn)
|
||||||
if tbl.respawn then
|
if tbl.respawn then
|
||||||
entity_to_node(self.start_pos, self.object)
|
entity_to_node(self.start_pos, self.object)
|
||||||
end
|
end
|
||||||
@ -405,7 +429,7 @@ minetest.register_entity("techage:move_item", {
|
|||||||
self.old_dist = self.old_dist or dist
|
self.old_dist = self.old_dist or dist
|
||||||
|
|
||||||
-- Landing
|
-- Landing
|
||||||
if self.lpath and self.lpath[self.idx] then
|
if self.lpath and self.lpath[self.path_idx] then
|
||||||
if dist < 1 or dist > self.old_dist then
|
if dist < 1 or dist > self.old_dist then
|
||||||
local dest_pos = self.dest_pos
|
local dest_pos = self.dest_pos
|
||||||
stop_obj(obj, self)
|
stop_obj(obj, self)
|
||||||
@ -415,12 +439,12 @@ minetest.register_entity("techage:move_item", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif self.handover and dist < 0.2 or dist > self.old_dist then
|
elseif self.handover and dist < 0.2 or dist > self.old_dist then
|
||||||
if not handover_to(obj, self, self.dest_pos) then
|
local dest_pos = self.dest_pos
|
||||||
local dest_pos = self.dest_pos
|
stop_obj(obj, self)
|
||||||
stop_obj(obj, self)
|
if not handover_to(obj, self, dest_pos) then
|
||||||
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
return
|
||||||
else
|
else
|
||||||
if dist < 0.05 or dist > self.old_dist then
|
if dist < 0.05 or dist > self.old_dist then
|
||||||
local dest_pos = self.dest_pos
|
local dest_pos = self.dest_pos
|
||||||
@ -458,7 +482,6 @@ minetest.register_entity("techage:move_item", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local function is_valid_dest(pos)
|
local function is_valid_dest(pos)
|
||||||
@ -500,9 +523,9 @@ local function table_add(tbl, offs)
|
|||||||
return tbl2
|
return tbl2
|
||||||
end
|
end
|
||||||
|
|
||||||
local function move_node(pos, start_pos, lpath, max_speed, height, move2to1, handover)
|
local function move_node(pos, pos1_idx, start_pos, lpath, max_speed, height, move2to1, handover)
|
||||||
local pos2 = next_path_pos(start_pos, lpath, 1)
|
local pos2 = next_path_pos(start_pos, lpath, 1)
|
||||||
print("move_node", P2S(pos), P2S(start_pos), lpath, max_speed, height, move2to1, P2S(pos2))
|
--print("move_node", P2S(pos), P2S(start_pos), lpath, max_speed, height, move2to1, P2S(pos2))
|
||||||
if pos2 then
|
if pos2 then
|
||||||
local dir = determine_dir(start_pos, pos2)
|
local dir = determine_dir(start_pos, pos2)
|
||||||
local obj = node_to_entity(start_pos)
|
local obj = node_to_entity(start_pos)
|
||||||
@ -516,19 +539,22 @@ local function move_node(pos, start_pos, lpath, max_speed, height, move2to1, han
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local self = obj:get_luaentity()
|
local self = obj:get_luaentity()
|
||||||
self.idx = 2
|
self.path_idx = 2
|
||||||
|
self.pos1_idx = pos1_idx
|
||||||
self.lpath = lpath
|
self.lpath = lpath
|
||||||
self.max_speed = max_speed
|
self.max_speed = max_speed
|
||||||
self.start_pos = start_pos
|
self.start_pos = start_pos
|
||||||
|
self.base_pos = pos
|
||||||
self.move2to1 = move2to1
|
self.move2to1 = move2to1
|
||||||
self.handover = handover
|
self.handover = handover
|
||||||
|
print("move_node", P2S(start_pos), P2S(pos2), P2S(dir), P2S(pos))
|
||||||
move_entity(obj, pos2, dir)
|
move_entity(obj, pos2, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function move_nodes(pos, meta, nvm, lpath, max_speed, height, move2to1, handover)
|
local function move_nodes(pos, meta, nvm, lpath, max_speed, height, move2to1, handover)
|
||||||
print("move_nodes", dump(nvm), dump(lpath), max_speed, height, move2to1, handover)
|
--print("move_nodes", dump(nvm), dump(lpath), max_speed, height, move2to1, handover)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
techage.counting_add(owner, #nvm.lpos1 * #lpath)
|
techage.counting_add(owner, #nvm.lpos1 * #lpath)
|
||||||
|
|
||||||
@ -540,10 +566,10 @@ local function move_nodes(pos, meta, nvm, lpath, max_speed, height, move2to1, ha
|
|||||||
pos1, pos2 = pos2, pos1
|
pos1, pos2 = pos2, pos1
|
||||||
end
|
end
|
||||||
|
|
||||||
print("move_nodes", P2S(pos1), P2S(pos2))
|
--print("move_nodes", P2S(pos1), P2S(pos2))
|
||||||
if not minetest.is_protected(pos1, owner) and not minetest.is_protected(pos2, owner) then
|
if not minetest.is_protected(pos1, owner) and not minetest.is_protected(pos2, owner) then
|
||||||
if is_simple_node(pos1) and is_valid_dest(pos2) then
|
if is_simple_node(pos1) and is_valid_dest(pos2) then
|
||||||
move_node(pos, pos1, lpath, max_speed, height, move2to1, handover)
|
move_node(pos, idx, pos1, lpath, max_speed, height, move2to1, handover)
|
||||||
else
|
else
|
||||||
if not is_simple_node(pos1) then
|
if not is_simple_node(pos1) then
|
||||||
meta:set_string("status", S("No valid node at the start position"))
|
meta:set_string("status", S("No valid node at the start position"))
|
||||||
|
@ -25,6 +25,7 @@ local hyperloop = techage.hyperloop
|
|||||||
local remote_pos = techage.hyperloop.remote_pos
|
local remote_pos = techage.hyperloop.remote_pos
|
||||||
|
|
||||||
local CAPACITY = 1000
|
local CAPACITY = 1000
|
||||||
|
local EX_PIONTS = 20
|
||||||
|
|
||||||
local function on_rightclick(pos, node, clicker)
|
local function on_rightclick(pos, node, clicker)
|
||||||
local rmt_pos = remote_pos(pos)
|
local rmt_pos = remote_pos(pos)
|
||||||
@ -242,7 +243,7 @@ minetest.register_node("techage:ta4_tank", {
|
|||||||
techage.remove_node(pos, oldnode, oldmetadata)
|
techage.remove_node(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
ta5_formspec = {menu=hyperloop.WRENCH_MENU, ex_points=20},
|
ta5_formspec = {menu=hyperloop.WRENCH_MENU, ex_points=EX_PIONTS},
|
||||||
ta_after_formspec = hyperloop.after_formspec,
|
ta_after_formspec = hyperloop.after_formspec,
|
||||||
can_dig = can_dig,
|
can_dig = can_dig,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -24,6 +24,7 @@ local mark = dofile(MP .. "/basis/mark_lib.lua")
|
|||||||
|
|
||||||
local MAX_DIST = 200
|
local MAX_DIST = 200
|
||||||
local MAX_BLOCKS = 16
|
local MAX_BLOCKS = 16
|
||||||
|
local EX_PIONTS = 40
|
||||||
|
|
||||||
local WRENCH_MENU = {
|
local WRENCH_MENU = {
|
||||||
{
|
{
|
||||||
@ -65,9 +66,9 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
description = S("TA5 Fly Controller"),
|
description = S("TA5 Fly Controller"),
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
"techage_filling_ta4.png^techage_frame_ta5_top.png",
|
||||||
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
"techage_filling_ta4.png^techage_frame_ta5_top.png",
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_movecontroller.png",
|
"techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_movecontroller.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack)
|
after_place_node = function(pos, placer, itemstack)
|
||||||
@ -82,13 +83,18 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if techage.get_expoints(player) < EX_PIONTS then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
|
|
||||||
if fields.record then
|
if fields.record then
|
||||||
nvm.lpos1 = {}
|
nvm.lpos1 = {}
|
||||||
nvm.lpos2 = {}
|
nvm.lpos2 = {}
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("status", S("Recording..."))
|
meta:set_string("status", S("Recording..."))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
minetest.chat_send_player(name, S("Click on all blocks that shall be moved"))
|
minetest.chat_send_player(name, S("Click on all blocks that shall be moved"))
|
||||||
@ -113,20 +119,26 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
elseif fields.moveAB then
|
elseif fields.moveAB then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, false) then
|
if fly.move_to_other_pos(pos, false) then
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
elseif fields.moveBA then
|
elseif fields.moveBA then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, true) then
|
if fly.move_to_other_pos(pos, true) then
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -137,23 +149,34 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
techage.remove_node(pos, oldnode, oldmetadata)
|
techage.remove_node(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
ta4_formspec = WRENCH_MENU,
|
ta5_formspec = {menu=WRENCH_MENU, ex_points=EX_PIONTS},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {choppy=2, cracky=2, crumbly=2},
|
groups = {choppy=2, cracky=2, crumbly=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
local INFO = [[Commands: 'a2b', 'b2a']]
|
local INFO = [[Commands: 'status', 'a2b', 'b2a', 'move']]
|
||||||
|
|
||||||
techage.register_node({"techage:ta5_flycontroller"}, {
|
techage.register_node({"techage:ta5_flycontroller"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "info" then
|
if topic == "info" then
|
||||||
return INFO
|
return INFO
|
||||||
|
elseif topic == "status" then
|
||||||
|
return nvm.running and "running" or "stopped"
|
||||||
elseif topic == "a2b" then
|
elseif topic == "a2b" then
|
||||||
|
nvm.moveBA = true
|
||||||
|
nvm.running = true
|
||||||
return fly.move_to_other_pos(pos, false)
|
return fly.move_to_other_pos(pos, false)
|
||||||
elseif topic == "b2a" then
|
elseif topic == "b2a" then
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
return fly.move_to_other_pos(pos, true)
|
return fly.move_to_other_pos(pos, true)
|
||||||
|
elseif topic == "move" then
|
||||||
|
nvm.moveBA = nvm.moveBA == false
|
||||||
|
nvm.running = true
|
||||||
|
return fly.move_to_other_pos(pos, nvm.moveBA == false)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
@ -25,28 +25,6 @@ local mark = dofile(MP .. "/basis/mark_lib.lua")
|
|||||||
local MAX_DIST = 100
|
local MAX_DIST = 100
|
||||||
local MAX_BLOCKS = 16
|
local MAX_BLOCKS = 16
|
||||||
|
|
||||||
-- Determine and store the path in the first and in the last block of the chain
|
|
||||||
local function store_path(pos)
|
|
||||||
local lpath = {}
|
|
||||||
local pos2 = table.copy(pos)
|
|
||||||
while pos2 do
|
|
||||||
local meta = M(pos2)
|
|
||||||
lpath[#lpath + 1] = meta:get_string("distance")
|
|
||||||
local number = meta:get_string("handoverB")
|
|
||||||
local info = techage.get_node_info(number)
|
|
||||||
if info and info.name == "techage:ta4_movecontroller" then
|
|
||||||
pos2 = info.pos
|
|
||||||
else
|
|
||||||
local s = table.concat(lpath, "\n")
|
|
||||||
M(pos):set_string("path", s) -- first block
|
|
||||||
M(pos2):set_string("path", s) -- last block
|
|
||||||
techage.get_nvm(pos2).lpos1 = techage.get_nvm(pos).lpos2
|
|
||||||
pos2 = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return #lpath
|
|
||||||
end
|
|
||||||
|
|
||||||
local WRENCH_MENU = {
|
local WRENCH_MENU = {
|
||||||
{
|
{
|
||||||
type = "dropdown",
|
type = "dropdown",
|
||||||
@ -81,7 +59,7 @@ local WRENCH_MENU = {
|
|||||||
|
|
||||||
local function formspec(nvm, meta)
|
local function formspec(nvm, meta)
|
||||||
local status = meta:get_string("status")
|
local status = meta:get_string("status")
|
||||||
local distance = meta:contains("distance") and meta:get_string("distance") or "0,3,0"
|
local path = meta:contains("path") and meta:get_string("path") or "0,3,0"
|
||||||
return "size[8,5]" ..
|
return "size[8,5]" ..
|
||||||
default.gui_bg ..
|
default.gui_bg ..
|
||||||
default.gui_bg_img ..
|
default.gui_bg_img ..
|
||||||
@ -91,7 +69,7 @@ local function formspec(nvm, meta)
|
|||||||
techage.wrench_image(7.4, -0.05) ..
|
techage.wrench_image(7.4, -0.05) ..
|
||||||
"button[0.1,0.8;3.8,1;record;" .. S("Record") .. "]" ..
|
"button[0.1,0.8;3.8,1;record;" .. S("Record") .. "]" ..
|
||||||
"button[4.1,0.8;3.8,1;done;" .. S("Done") .. "]" ..
|
"button[4.1,0.8;3.8,1;done;" .. S("Done") .. "]" ..
|
||||||
"field[0.4,2.5;3.8,1;distance;" .. S("Move distance (A to B)") .. ";" .. distance .. "]" ..
|
"field[0.4,2.5;3.8,1;path;" .. S("Move distance (A to B)") .. ";" .. path .. "]" ..
|
||||||
"button[4.1,2.2;3.8,1;store;" .. S("Store") .. "]" ..
|
"button[4.1,2.2;3.8,1;store;" .. S("Store") .. "]" ..
|
||||||
"button_exit[0.1,3.3;3.8,1;moveAB;" .. S("Move A-B") .. "]" ..
|
"button_exit[0.1,3.3;3.8,1;moveAB;" .. S("Move A-B") .. "]" ..
|
||||||
"button_exit[4.1,3.3;3.8,1;moveBA;" .. S("Move B-A") .. "]" ..
|
"button_exit[4.1,3.3;3.8,1;moveBA;" .. S("Move B-A") .. "]" ..
|
||||||
@ -126,6 +104,8 @@ minetest.register_node("techage:ta4_movecontroller", {
|
|||||||
if fields.record then
|
if fields.record then
|
||||||
nvm.lpos1 = {}
|
nvm.lpos1 = {}
|
||||||
nvm.lpos2 = {}
|
nvm.lpos2 = {}
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("status", S("Recording..."))
|
meta:set_string("status", S("Recording..."))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
minetest.chat_send_player(name, S("Click on all blocks that shall be moved"))
|
minetest.chat_send_player(name, S("Click on all blocks that shall be moved"))
|
||||||
@ -141,31 +121,35 @@ minetest.register_node("techage:ta4_movecontroller", {
|
|||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
elseif fields.store then
|
elseif fields.store then
|
||||||
if fly.to_vector(fields.distance, MAX_DIST) then
|
if fly.to_vector(fields.path or "", MAX_DIST) then
|
||||||
meta:set_string("distance", fields.distance)
|
meta:set_string("path", fields.path)
|
||||||
meta:set_string("status", S("Stored"))
|
meta:set_string("status", S("Stored"))
|
||||||
meta:set_string("path", "")
|
|
||||||
else
|
else
|
||||||
meta:set_string("status", S("Error: Invalid distance !!"))
|
meta:set_string("status", S("Error: Invalid distance !!"))
|
||||||
end
|
end
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
elseif fields.moveAB then
|
elseif fields.moveAB then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
--store_path(pos)
|
|
||||||
if fly.move_to_other_pos(pos, false) then
|
if fly.move_to_other_pos(pos, false) then
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
elseif fields.moveBA then
|
elseif fields.moveBA then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, true) then
|
if fly.move_to_other_pos(pos, true) then
|
||||||
|
nvm.running = true
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -183,16 +167,27 @@ minetest.register_node("techage:ta4_movecontroller", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
local INFO = [[Commands: 'a2b', 'b2a']]
|
local INFO = [[Commands: 'status', 'a2b', 'b2a', 'move']]
|
||||||
|
|
||||||
techage.register_node({"techage:ta4_movecontroller"}, {
|
techage.register_node({"techage:ta4_movecontroller"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "info" then
|
if topic == "info" then
|
||||||
return INFO
|
return INFO
|
||||||
|
elseif topic == "status" then
|
||||||
|
return nvm.running and "running" or "stopped"
|
||||||
elseif topic == "a2b" then
|
elseif topic == "a2b" then
|
||||||
|
nvm.moveBA = true
|
||||||
|
nvm.running = true
|
||||||
return fly.move_to_other_pos(pos, false)
|
return fly.move_to_other_pos(pos, false)
|
||||||
elseif topic == "b2a" then
|
elseif topic == "b2a" then
|
||||||
|
nvm.moveBA = false
|
||||||
|
nvm.running = true
|
||||||
return fly.move_to_other_pos(pos, true)
|
return fly.move_to_other_pos(pos, true)
|
||||||
|
elseif topic == "move" then
|
||||||
|
nvm.moveBA = nvm.moveBA == false
|
||||||
|
nvm.running = true
|
||||||
|
return fly.move_to_other_pos(pos, nvm.moveBA == false)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
@ -99,6 +99,7 @@ minetest.register_node("techage:ta4_turncontroller", {
|
|||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
print("new_posses", #new_posses)
|
print("new_posses", #new_posses)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
elseif fields.right then
|
elseif fields.right then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
local new_posses = fly.rotate_nodes(pos, nvm.lpos, "r")
|
local new_posses = fly.rotate_nodes(pos, nvm.lpos, "r")
|
||||||
@ -108,6 +109,7 @@ minetest.register_node("techage:ta4_turncontroller", {
|
|||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
print("new_posses", #new_posses)
|
print("new_posses", #new_posses)
|
||||||
end
|
end
|
||||||
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -164,11 +166,11 @@ techage.register_node({"techage:ta4_turncontroller"}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--minetest.register_craft({
|
minetest.register_craft({
|
||||||
-- output = "techage:ta5_flycontroller",
|
output = "techage:ta4_turncontroller",
|
||||||
-- recipe = {
|
recipe = {
|
||||||
-- {"default:steel_ingot", "dye:blue", "default:steel_ingot"},
|
{"default:steel_ingot", "dye:blue", "default:steel_ingot"},
|
||||||
-- {"default:mese_crystal_fragment", "techage:ta4_wlanchip", "default:mese_crystal_fragment"},
|
{"techage:aluminum", "techage:baborium_ingot", "techage:aluminum"},
|
||||||
-- {"group:wood", "basic_materials:gear_steel", "group:wood"},
|
{"group:wood", "basic_materials:gear_steel", "group:wood"},
|
||||||
-- },
|
},
|
||||||
--})
|
})
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 149 B |
BIN
textures/techage_frame_ta5.png
Normal file
BIN
textures/techage_frame_ta5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 167 B |
BIN
textures/techage_frame_ta5_top.png
Normal file
BIN
textures/techage_frame_ta5_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
Loading…
Reference in New Issue
Block a user