From 49fd5bc29af23ceec7aae81c1f00249da55f6914 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 9 May 2021 19:34:13 +0200 Subject: [PATCH] Add rack version for techage:ta4_server --- doc/guide.lua | 9 ++- items/ceramic.lua | 3 +- logic/sequencer.lua | 6 +- lua_controller/commands.lua | 12 ++++ lua_controller/controller.lua | 12 ++++ lua_controller/server.lua | 109 ++++++++++++++++++++++++++++- textures/techage_server2_back.png | Bin 0 -> 283 bytes textures/techage_server2_front.png | Bin 0 -> 283 bytes textures/techage_server2_side.png | Bin 0 -> 231 bytes textures/techage_server2_top.png | Bin 0 -> 169 bytes 10 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 textures/techage_server2_back.png create mode 100644 textures/techage_server2_front.png create mode 100644 textures/techage_server2_side.png create mode 100644 textures/techage_server2_top.png diff --git a/doc/guide.lua b/doc/guide.lua index 918bb45..cae14aa 100644 --- a/doc/guide.lua +++ b/doc/guide.lua @@ -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) diff --git a/items/ceramic.lua b/items/ceramic.lua index e6864e5..62aa79b 100644 --- a/items/ceramic.lua +++ b/items/ceramic.lua @@ -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", { diff --git a/logic/sequencer.lua b/logic/sequencer.lua index 4692ff3..b5abfb7 100644 --- a/logic/sequencer.lua +++ b/logic/sequencer.lua @@ -263,7 +263,11 @@ techage.register_node({"techage:ta3_sequencer"}, { elseif topic == "off" then -- do not stop immediately local nvm = techage.get_nvm(pos) - nvm.endless = false + if not nvm.running then + nvm.endless = not (nvm.endless or false) + else + nvm.endless = false + end else return "unsupported" end diff --git a/lua_controller/commands.lua b/lua_controller/commands.lua index db1ed3f..ef3bd0e 100644 --- a/lua_controller/commands.lua +++ b/lua_controller/commands.lua @@ -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 "") diff --git a/lua_controller/controller.lua b/lua_controller/controller.lua index 7855999..6c6cd43 100644 --- a/lua_controller/controller.lua +++ b/lua_controller/controller.lua @@ -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 diff --git a/lua_controller/server.lua b/lua_controller/server.lua index ff2b2b1..eeff021 100644 --- a/lua_controller/server.lua +++ b/lua_controller/server.lua @@ -93,7 +93,7 @@ minetest.register_node("techage:ta4_server", { techage.remove_node(pos, oldnode, oldmetadata) end, -on_timer = function(pos, elasped) + on_timer = function(pos, elasped) local meta = M(pos) local nvm = techage.get_nvm(pos) nvm.size = nvm.size or 0 @@ -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, diff --git a/textures/techage_server2_back.png b/textures/techage_server2_back.png new file mode 100644 index 0000000000000000000000000000000000000000..c8c3da38fb329a83b3fc5ce4175aacbe942460e1 GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv^#Gp`*Q}hJ+mD|DdH?_a-?nK} zcyMred3j%7Uv+i$oH=uT?oQ!hW}Y1!yyM1nQ=p>to-U3d8s}RlZWKJMz~j1K`rOh) z=1opvCz$kNEL*kW%@p2g1Z{BC)2=wx@u1-6juZMJHgZ;t8|G>1n(DZP-Jqz?WLoyxapd;$C~y@+?TUG!ya;2;m1yi zrN?6r=EW4nID{nMUL`2%!?jAVv~T8f0n<-6^HLn#DrF?w>`yrS;Qs2hd;0$ckxL&O fRM>L6ejlS9XGlfx`}f*Fr!#oE`njxgN@xNA;$U$9 literal 0 HcmV?d00001 diff --git a/textures/techage_server2_front.png b/textures/techage_server2_front.png new file mode 100644 index 0000000000000000000000000000000000000000..0240dc08cace3e502e16d3a6b301171d4e154a54 GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!VDxk7i7!@QYryHA+GKPJ}pycU%!4GD3Fzv zb^Gzt%F4=uf`Y!jzOaCR1q&90ya`FU%-0N*W-JNv3ubV5b|VeQS?cNH7-Dhy?WBX8 zhYfgK|8uEIr?ftDei>@PoWc57Ct(tA)61*gQ~V;YPgx`%Uvy@nmED&M+jVRlz8>OB zQDNhp=y>E%!b`_1t2M<9UuK;071%qYsOf;0#R3lPpyQK-9!7o?o$zR4{Q}L|jJ_vl zY>h}Y^PDX-VT;IOl{Gf0YrTGM<8iK*aovCY#lOpeJ{$7n4|z{xRxsfBoBsZQ@c-Wy e_iOK*E0)jy+&PEcM7I^>IR;NxKbLh*2~7aFlyZIm literal 0 HcmV?d00001 diff --git a/textures/techage_server2_side.png b/textures/techage_server2_side.png new file mode 100644 index 0000000000000000000000000000000000000000..0887f4b438f75dafccf000bf1a15722c12644f7e GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvp#Yx{*UHMuf`WpqtSla8=Kufy zCnqQS`v-UfWhZ#LIEHAP@11y&lf{sO)l}3)`@(gnC=XWl+x6Phb8Z-WScH9gd|*MP z&|(LD^A6|LQWH0HGp*TScgSUL|M!rcyLs32F<(*6*!s8Y77ND%$pxxQ_k?({O*@`< zpzlB?i=vq`V zFr8%a6PTvNIptAWA) Rc|Z#oJYD@<);T3K0RZjfJ7WL< literal 0 HcmV?d00001