Add rack version for techage:ta4_server

This commit is contained in:
Joachim Stolberg 2021-05-09 19:34:13 +02:00
parent c920910d75
commit 49fd5bc29a
10 changed files with 142 additions and 9 deletions

View File

@ -81,14 +81,13 @@ local function formspec_help(meta, manual)
default.gui_bg_img..
default.gui_slots..
"item_image[9.6,0;1,1;techage:construction_board]"..
"tablecolumns[tree,width=1;text,width=10,align=inline]"..
"tableoptions[opendepth=1]"..
"table[0.1,0;9,5;page;"..table.concat(aTitel, ",")..";"..idx.."]"..
bttn..
"style_type[textarea;textcolor=#FFFFFF]"..
"textarea[0.3,5.7;11,5.3;;"..(aText[idx] or "")..";]"..
"box[0,5.75;10.775,4.45;#000000]"..
"tablecolumns[tree,width=1;text,width=10,align=inline]"..
"tableoptions[opendepth=1]"..
"table[0.1,0;9,5;page;"..table.concat(aTitel, ",")..";"..idx.."]"
"box[0,5.75;10.775,4.45;#000000]"
end
local function formspec_plan(meta, manual)

View File

@ -36,7 +36,8 @@ minetest.register_craft({
{"techage:clay_powder", "techage:aluminum_powder", ""},
{"techage:silver_sandstone_powder", "bucket:bucket_water", ""},
{"", "", ""},
}
},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}},
})
minetest.register_craftitem("techage:ta4_furnace_ceramic", {

View File

@ -263,7 +263,11 @@ techage.register_node({"techage:ta3_sequencer"}, {
elseif topic == "off" then
-- do not stop immediately
local nvm = techage.get_nvm(pos)
if not nvm.running then
nvm.endless = not (nvm.endless or false)
else
nvm.endless = false
end
else
return "unsupported"
end

View File

@ -38,6 +38,18 @@ techage.lua_ctlr.register_function("get_input", {
" The device has to be connected with the controller."
})
techage.lua_ctlr.register_function("get_next_input", {
cmnd = function(self)
return techage.lua_ctlr.get_next_input(self.meta.number)
end,
help = ' $get_next_input() --> number and state\n'..
' Similar to $get_input(), but provides the\n'..
' input node number in addition.\n'..
' example: num, state = $get_next_input()\n'..
' This function deletes the input and returns\n'..
' nil if no further input value is available.'
})
techage.lua_ctlr.register_function("read_data", {
cmnd = function(self, num, cmnd, data)
num = tostring(num or "")

View File

@ -605,6 +605,18 @@ function techage.lua_ctlr.get_input(number, input)
return "off"
end
function techage.lua_ctlr.get_next_input(number)
if Cache[number] and Cache[number].inputs then
local num, state = next(Cache[number].inputs or {})
if num ~= "msg" and num ~= "term" then
if num then
Cache[number].inputs[num] = nil
end
return num, state
end
end
end
-- used for Terminal commands
function techage.lua_ctlr.get_command(number)
if Cache[number] and Cache[number].inputs then

View File

@ -120,6 +120,111 @@ minetest.register_craft({
},
})
minetest.register_node("techage:ta4_server2", {
description = "TA4 Lua Rack Server",
tiles = {
-- up, down, right, left, back, front
"techage_server2_top.png",
"techage_server2_top.png",
"techage_server2_side.png",
"techage_server2_side.png^[transformFX",
"techage_server2_back.png",
{
image = "techage_server2_front.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 1,
},
},
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.4375, -0.4375, 0.5},
{-0.5, 0.4375, -0.5, -0.4375, 0.5, 0.5},
{0.4375, -0.5, -0.5, 0.5, -0.4375, 0.5},
{0.4375, 0.4375, -0.5, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.375, -0.4375, 0.5, -0.3125},
{-0.5, -0.5, 0.3125, -0.4375, 0.5, 0.375},
{0.4375, -0.5, 0.3125, 0.5, 0.5, 0.375},
{0.4375, -0.5, -0.375, 0.5, 0.5, -0.3125},
{-0.4375, -0.3125, -0.4375, 0.4375, 0.3125, 0.4375},
{0.4375, -0.0625, -0.4375, 0.5, 0, 0.4375},
{-0.5, -0.0625, -0.4375, -0.4375, 0, 0.4375},
}
},
after_place_node = function(pos, placer)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
local number = techage.add_node(pos, "techage:ta4_server2")
meta:set_string("owner", placer:get_player_name())
meta:set_string("number", number)
meta:set_string("formspec", formspec(nvm))
nvm.size = 0
meta:set_string("infotext", "Server "..number..": ("..nvm.size.."/"..SERVER_CAPA..")")
minetest.get_node_timer(pos):start(20)
end,
on_receive_fields = function(pos, formname, fields, player)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
local owner = meta:get_string("owner")
if player:get_player_name() == owner then
if fields.names and fields.names ~= "" then
nvm.names = string.split(fields.names, " ")
meta:set_string("formspec", formspec(nvm))
end
end
end,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
techage.del_mem(pos)
minetest.node_dig(pos, node, puncher, pointed_thing)
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
end,
on_timer = function(pos, elasped)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
nvm.size = nvm.size or 0
local number = meta:get_string("number")
meta:set_string("infotext", "Server "..number..": ("..nvm.size.."/"..SERVER_CAPA..")")
return true
end,
paramtype = "light",
sunlight_propagates = true,
use_texture_alpha = techage.CLIP,
paramtype2 = "facedir",
groups = {choppy=1, cracky=1, crumbly=1},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_craft({
type = "shapeless",
output = "techage:ta4_server2",
recipe = {"techage:ta4_server"},
})
minetest.register_craft({
type = "shapeless",
output = "techage:ta4_server",
recipe = {"techage:ta4_server2"},
})
local function calc_size(v)
if type(v) == "number" then
return 1
@ -173,7 +278,7 @@ local function read_value(nvm, key)
return item
end
techage.register_node({"techage:ta4_server"}, {
techage.register_node({"techage:ta4_server", "techage:ta4_server2"}, {
on_recv_message = function(pos, src, topic, payload)
return "unsupported"
end,

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B