Merge pull request #77 from joe7575/wizardofgcc/master

Wizardofgcc/master
This commit is contained in:
Joachim Stolberg 2022-02-23 19:07:00 +01:00 committed by GitHub
commit 622a26d575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 222 additions and 0 deletions

View File

@ -110,6 +110,7 @@ techage.Items = {
ta3_logic = "techage:ta3_logic", ta3_logic = "techage:ta3_logic",
ta3_nodedetector = "techage:ta3_nodedetector_off", ta3_nodedetector = "techage:ta3_nodedetector_off",
ta3_playerdetector = "techage:ta3_playerdetector_off", ta3_playerdetector = "techage:ta3_playerdetector_off",
ta3_lightdetector = "techage:ta3_lightdetector_off",
ta3_repeater = "techage:ta3_repeater", ta3_repeater = "techage:ta3_repeater",
ta3_sequencer = "techage:ta3_sequencer", ta3_sequencer = "techage:ta3_sequencer",
ta3_timer = "techage:ta3_timer", ta3_timer = "techage:ta3_timer",

View File

@ -124,6 +124,7 @@ techage.manual_DE.aTitel = {
"3,TA3 Wagen Detektor / Cart Detector", "3,TA3 Wagen Detektor / Cart Detector",
"3,TA3 Block Detektor / Node Detector", "3,TA3 Block Detektor / Node Detector",
"3,TA3 Spieler Detektor / Player Detector", "3,TA3 Spieler Detektor / Player Detector",
"3,TA3 Lichtdetektor",
"2,TA3 Maschinen", "2,TA3 Maschinen",
"3,TA3 Schieber / Pusher", "3,TA3 Schieber / Pusher",
"3,TA3 Verteiler / Distributor", "3,TA3 Verteiler / Distributor",
@ -1198,6 +1199,11 @@ techage.manual_DE.aText = {
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"Der Lichtdetektor sendet einen 'on'-Kommando\\, wenn der Lichtpegel des darüber liegenden Blocks einen bestimmten Pegel überschreitet\\, der über das Rechtsklickmenü eingestellt werden kann.\n"..
"Mit einen TA4 Lua Controller kann die genaue Lichtstärke mit $get_cmd(num\\, 'light_level') ermitteln werden.\n"..
"\n"..
"\n"..
"\n",
"Bei TA3 existieren die gleichen Maschinen wie bei TA2\\, nur sind diese hier leistungsfähiger und benötigen Strom statt Achsenantrieb.\n".. "Bei TA3 existieren die gleichen Maschinen wie bei TA2\\, nur sind diese hier leistungsfähiger und benötigen Strom statt Achsenantrieb.\n"..
"Im folgenden sind daher nur die unterschiedlichen\\, technischen Daten angegeben.\n".. "Im folgenden sind daher nur die unterschiedlichen\\, technischen Daten angegeben.\n"..
"\n".. "\n"..
@ -2240,6 +2246,7 @@ techage.manual_DE.aItemName = {
"ta3_cartdetector", "ta3_cartdetector",
"ta3_nodedetector", "ta3_nodedetector",
"ta3_playerdetector", "ta3_playerdetector",
"ta3_lightdetector",
"ta3_grinder", "ta3_grinder",
"ta3_pusher", "ta3_pusher",
"ta3_distributor", "ta3_distributor",
@ -2511,6 +2518,7 @@ techage.manual_DE.aPlanTable = {
"", "",
"", "",
"", "",
"",
"ta4_windturbine", "ta4_windturbine",
"", "",
"", "",

View File

@ -124,6 +124,7 @@ techage.manual_EN.aTitel = {
"3,TA3 Cart Detector", "3,TA3 Cart Detector",
"3,TA3 Block Detector", "3,TA3 Block Detector",
"3,TA3 Player Detector", "3,TA3 Player Detector",
"3,TA3 Light Detector",
"2,TA3 Machines", "2,TA3 Machines",
"3,TA3 Pusher", "3,TA3 Pusher",
"3,TA3 Distributor", "3,TA3 Distributor",
@ -1196,6 +1197,11 @@ techage.manual_EN.aText = {
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"The light detector sends an 'on' command if the light level of the block above exceeds a certain level\\, which can be set through the right-click menu.\n"..
"If you have a TA4 Lua Controller\\, you can get the exact light level with $get_cmd(num\\, 'light_level')\n"..
"\n"..
"\n"..
"\n",
"TA3 has the same machines as TA2\\, only these are more powerful and require electricity instead of axis drive.\n".. "TA3 has the same machines as TA2\\, only these are more powerful and require electricity instead of axis drive.\n"..
"Therefore\\, only the different technical data are given below.\n".. "Therefore\\, only the different technical data are given below.\n"..
"\n".. "\n"..
@ -2235,6 +2241,7 @@ techage.manual_EN.aItemName = {
"ta3_cartdetector", "ta3_cartdetector",
"ta3_nodedetector", "ta3_nodedetector",
"ta3_playerdetector", "ta3_playerdetector",
"ta3_lightdetector",
"ta3_grinder", "ta3_grinder",
"ta3_pusher", "ta3_pusher",
"ta3_distributor", "ta3_distributor",
@ -2505,6 +2512,7 @@ techage.manual_EN.aPlanTable = {
"", "",
"", "",
"", "",
"",
"ta4_windturbine", "ta4_windturbine",
"", "",
"", "",

View File

@ -285,6 +285,7 @@ dofile(MP.."/logic/timer.lua")
dofile(MP.."/logic/lua_logic.lua") -- old dofile(MP.."/logic/lua_logic.lua") -- old
dofile(MP.."/logic/logic_block.lua") -- new dofile(MP.."/logic/logic_block.lua") -- new
dofile(MP.."/logic/node_detector.lua") dofile(MP.."/logic/node_detector.lua")
dofile(MP.."/logic/light_detector.lua")
dofile(MP.."/logic/player_detector.lua") dofile(MP.."/logic/player_detector.lua")
dofile(MP.."/logic/mba_detector.lua") dofile(MP.."/logic/mba_detector.lua")
dofile(MP.."/logic/cart_detector.lua") dofile(MP.."/logic/cart_detector.lua")

View File

@ -127,6 +127,7 @@ Command=Kommando
### button.lua ### ### button.lua ###
### cart_detector.lua ### ### cart_detector.lua ###
### detector.lua ### ### detector.lua ###
### light_detector.lua ###
### lua_logic.lua ### ### lua_logic.lua ###
### mesecons_converter.lua ### ### mesecons_converter.lua ###
### node_detector.lua ### ### node_detector.lua ###
@ -178,6 +179,7 @@ TA4 4x Button=TA4 4x Taster
TA3 Cart Detector=TA3 Wagen Detektor TA3 Cart Detector=TA3 Wagen Detektor
### cart_detector.lua ### ### cart_detector.lua ###
### light_detector.lua ###
### node_detector.lua ### ### node_detector.lua ###
accept=akzeptieren accept=akzeptieren
@ -732,6 +734,11 @@ Block has an@nadditional wrench menu=Block besitzt ein@nzusätzliches@nSchrauben
connected with=verbunden mit connected with=verbunden mit
### light_detector.lua ###
Send signal if light level is above:=Sende ein Signal wenn der Lichtwert größer ist als:
TA3 Light Detector=TA3 Lichtdetektor
### lighter.lua ### ### lighter.lua ###
TA1 Lighter=TA1 Anzünder TA1 Lighter=TA1 Anzünder

View File

@ -127,6 +127,7 @@ Command=
### button.lua ### ### button.lua ###
### cart_detector.lua ### ### cart_detector.lua ###
### detector.lua ### ### detector.lua ###
### light_detector.lua ###
### lua_logic.lua ### ### lua_logic.lua ###
### mesecons_converter.lua ### ### mesecons_converter.lua ###
### node_detector.lua ### ### node_detector.lua ###
@ -178,6 +179,7 @@ TA4 4x Button=
TA3 Cart Detector= TA3 Cart Detector=
### cart_detector.lua ### ### cart_detector.lua ###
### light_detector.lua ###
### node_detector.lua ### ### node_detector.lua ###
accept= accept=
@ -732,6 +734,11 @@ Block has an@nadditional wrench menu=
connected with= connected with=
### light_detector.lua ###
Send signal if light level is above:=
TA3 Light Detector=
### lighter.lua ### ### lighter.lua ###
TA1 Lighter= TA1 Lighter=

174
logic/light_detector.lua Executable file
View File

@ -0,0 +1,174 @@
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
Light Detector
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local logic = techage.logic
local CYCLE_TIME = 2
local function switch_off(pos)
local node = minetest.get_node(pos)
if node.name == "techage:ta3_lightdetector_on" then
logic.swap_node(pos, "techage:ta3_lightdetector_off")
logic.send_off(pos, M(pos))
end
end
local function switch_on(pos)
logic.swap_node(pos, "techage:ta3_lightdetector_on")
if logic.send_on(pos, M(pos)) then
minetest.after(1, switch_off, pos)
end
end
local function node_timer(pos)
local nvm = techage.get_nvm(pos)
trigger = nvm.mode or 7
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
if minetest.get_node_light(pos_above, nil) == nil then
switch_off(pos)
return true
end
if minetest.get_node_light(pos_above, nil) > trigger then
switch_on(pos)
else
switch_off(pos)
end
return true
end
local function formspec(meta, nvm)
local numbers = meta:get_string("numbers") or ""
local dropdown_label = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15" -- Has to be a cleaner way of doing this, but it's just easier this way
return "size[7.5,4]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.5,1;7,1;numbers;"..S("Insert destination node number(s)")..";"..numbers.."]" ..
"label[0.2,1.6;"..S("Send signal if light level is above:").."]"..
"dropdown[0.2,2.1;7.3,1;mode;"..dropdown_label.."; "..(nvm.mode or 7).."]"..
"button_exit[2,3.2;3,1;accept;"..S("accept").."]"
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local meta = minetest.get_meta(pos)
local nvm = techage.get_nvm(pos)
if fields.accept then
nvm.mode = tonumber(fields.mode) or 7
if techage.check_numbers(fields.numbers, player:get_player_name()) then
meta:set_string("numbers", fields.numbers)
logic.infotext(M(pos), S("TA3 Light Detector"))
end
meta:set_string("formspec", formspec(meta, nvm))
end
end
local function techage_set_numbers(pos, numbers, player_name)
local meta = M(pos)
local res = logic.set_numbers(pos, numbers, player_name, S("TA3 Light Detector"))
meta:set_string("formspec", formspec(meta))
return res
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
techage.remove_node(pos, oldnode, oldmetadata)
end
minetest.register_node("techage:ta3_lightdetector_off", {
description = S("TA3 Light Detector"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_lightdetector.png",
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png^[transformR90",
},
after_place_node = function(pos, placer)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
logic.after_place_node(pos, placer, "techage:ta3_lightdetector_off", S("TA3 Light Detector"))
logic.infotext(meta, S("TA3 Light Detector"))
meta:set_string("formspec", formspec(meta, nvm))
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
on_receive_fields = on_receive_fields,
on_timer = node_timer,
techage_set_numbers = techage_set_numbers,
after_dig_node = after_dig_node,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta3_lightdetector_on", {
description = "TA3 Light Detector (On)",
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_lightdetector_on.png",
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png^[transformR90",
},
on_receive_fields = on_receive_fields,
on_timer = node_timer,
techage_set_numbers = techage_set_numbers,
after_dig_node = after_dig_node,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
drop = "techage:ta3_cartdetector_off"
})
minetest.register_craft({
output = "techage:ta3_lightdetector_off",
recipe = {
{"", "group:wood", "default:glass"},
{"", "default:copper_ingot", "techage:vacuum_tube"},
{"", "group:wood", "default:mese_crystal"},
},
})
techage.register_node({"techage:ta3_lightdetector_off", "techage:ta3_lightdetector_on"}, {
on_recv_message = function(pos, src, topic, payload)
if topic == "state" then
local node = techage.get_node_lvm(pos)
if node.name == "techage:ta3_lightdetector_on" then
return "on"
else
return "off"
end
elseif topic == "light_level" then -- Allow finding the specific light level
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
return minetest.get_node_light(pos_above, nil)
else
return "unsupported"
end
end,
on_node_load = function(pos)
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
})

View File

@ -737,6 +737,14 @@ Soll die Suche auf bestimmte Spieler eingegrenzt werden, so können diese Spiele
[ta3_playerdetector|image] [ta3_playerdetector|image]
### TA3 Lichtdetektor
Der Lichtdetektor sendet einen `on`-Kommando, wenn der Lichtpegel des darüber liegenden Blocks einen bestimmten Pegel überschreitet, der über das Rechtsklickmenü eingestellt werden kann.
Mit einen TA4 Lua Controller kann die genaue Lichtstärke mit $get_cmd(num, 'light_level') ermitteln werden.
[ta3_lightdetector|image]
## TA3 Maschinen ## TA3 Maschinen
Bei TA3 existieren die gleichen Maschinen wie bei TA2, nur sind diese hier leistungsfähiger und benötigen Strom statt Achsenantrieb. Bei TA3 existieren die gleichen Maschinen wie bei TA2, nur sind diese hier leistungsfähiger und benötigen Strom statt Achsenantrieb.

View File

@ -730,6 +730,12 @@ If the search should be limited to specific players, these player names can also
[ta3_playerdetector|image] [ta3_playerdetector|image]
### TA3 Light Detector
The light detector sends an `on` command if the light level of the block above exceeds a certain level, which can be set through the right-click menu.
If you have a TA4 Lua Controller, you can get the exact light level with $get_cmd(num, 'light_level')
[ta3_lightdetector|image]
## TA3 Machines ## TA3 Machines

View File

@ -123,6 +123,7 @@
- [TA3 Wagen Detektor / Cart Detector](./manual_ta3_DE.md#ta3-wagen-detektor--cart-detector) - [TA3 Wagen Detektor / Cart Detector](./manual_ta3_DE.md#ta3-wagen-detektor--cart-detector)
- [TA3 Block Detektor / Node Detector](./manual_ta3_DE.md#ta3-block-detektor--node-detector) - [TA3 Block Detektor / Node Detector](./manual_ta3_DE.md#ta3-block-detektor--node-detector)
- [TA3 Spieler Detektor / Player Detector](./manual_ta3_DE.md#ta3-spieler-detektor--player-detector) - [TA3 Spieler Detektor / Player Detector](./manual_ta3_DE.md#ta3-spieler-detektor--player-detector)
- [TA3 Lichtdetektor](./manual_ta3_DE.md#ta3-lichtdetektor)
- [TA3 Maschinen](./manual_ta3_DE.md#ta3-maschinen) - [TA3 Maschinen](./manual_ta3_DE.md#ta3-maschinen)
- [TA3 Schieber / Pusher](./manual_ta3_DE.md#ta3-schieber--pusher) - [TA3 Schieber / Pusher](./manual_ta3_DE.md#ta3-schieber--pusher)
- [TA3 Verteiler / Distributor](./manual_ta3_DE.md#ta3-verteiler--distributor) - [TA3 Verteiler / Distributor](./manual_ta3_DE.md#ta3-verteiler--distributor)

View File

@ -123,6 +123,7 @@
- [TA3 Cart Detector](./manual_ta3_EN.md#ta3-cart-detector) - [TA3 Cart Detector](./manual_ta3_EN.md#ta3-cart-detector)
- [TA3 Block Detector](./manual_ta3_EN.md#ta3-block-detector) - [TA3 Block Detector](./manual_ta3_EN.md#ta3-block-detector)
- [TA3 Player Detector](./manual_ta3_EN.md#ta3-player-detector) - [TA3 Player Detector](./manual_ta3_EN.md#ta3-player-detector)
- [TA3 Light Detector](./manual_ta3_EN.md#ta3-light-detector)
- [TA3 Machines](./manual_ta3_EN.md#ta3-machines) - [TA3 Machines](./manual_ta3_EN.md#ta3-machines)
- [TA3 Pusher](./manual_ta3_EN.md#ta3-pusher) - [TA3 Pusher](./manual_ta3_EN.md#ta3-pusher)
- [TA3 Distributor](./manual_ta3_EN.md#ta3-distributor) - [TA3 Distributor](./manual_ta3_EN.md#ta3-distributor)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB