Add flip-flop
This commit is contained in:
parent
9210bce637
commit
d6be0812c4
@ -311,4 +311,4 @@ end
|
||||
function techage.dropdown_index(sChoices, selected_value)
|
||||
local l = sChoices:split(",")
|
||||
return index(l, selected_value) or 1
|
||||
end
|
||||
end
|
||||
|
@ -127,6 +127,7 @@ techage.Items = {
|
||||
ta3_motor = "techage:ta3_motor_off",
|
||||
ta3_injector = "techage:ta3_injector_pas",
|
||||
ta3_command_converter = "techage:ta3_command_converter_off",
|
||||
ta3_flipflop = "techage:ta3_flipflop_off",
|
||||
----------------------------
|
||||
techage_ta4 = "techage_ta4.png",
|
||||
techage_ta4c = "techage_ta4c.png",
|
||||
|
@ -108,6 +108,7 @@ techage.manual_DE.aTitel = {
|
||||
"2,Logik-/Schalt-Blöcke",
|
||||
"3,TA3 Taster/Schalter / Button/Switch",
|
||||
"3,TA3 Kommando Konverter / Command Converter",
|
||||
"3,TA3 Flipflop / Flip-Flop",
|
||||
"3,TA3 Logikblock / Logic Block",
|
||||
"3,TA3 Wiederholer / Repeater",
|
||||
"3,TA3 Sequenzer / Sequencer",
|
||||
@ -1067,6 +1068,12 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"Das TA3 Flipflop wechselt seinen Zustand mit jedem empfangenen 'on' Kommando. Empfangene 'off' Kommandos werden ignortiert. Damit werden abhängig vom Zustandswechsel abwechselnd 'on' / 'off' Kommandos gesendet. Die Nummer des Zielblockes bzw. die Nummern der Zielblöcke müssen eingegeben werden. Die Nummern können auch mit Hilfe des Techage Programmers programmiert werden.\n"..
|
||||
"\n"..
|
||||
"Damit lassen sich bspw. Lampen mit Hilfe von Tastern ein- und wieder ausschalten.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"Den TA3 Logikblock kann man so programmieren\\, dass ein oder mehrere Eingangskommandos zu einem Ausgangskommando verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND\\, OR\\, NOT\\, XOR usw. ersetzen.\n"..
|
||||
"Eingangkommandos für den Logikblock sind 'on'/'off' Kommandos.\n"..
|
||||
"Eingangskommandos werden über die Nummer referenziert\\, also bspw. '1234' für das Kommando vom Sender mit der Nummer 1234.\n"..
|
||||
@ -2312,6 +2319,7 @@ techage.manual_DE.aItemName = {
|
||||
"ta3_logic",
|
||||
"ta3_button",
|
||||
"ta3_command_converter",
|
||||
"ta3_flipflop",
|
||||
"ta3_logic",
|
||||
"ta3_repeater",
|
||||
"ta3_sequencer",
|
||||
@ -2605,6 +2613,7 @@ techage.manual_DE.aPlanTable = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"ta4_windturbine",
|
||||
"",
|
||||
"",
|
||||
|
@ -109,6 +109,7 @@ techage.manual_EN.aTitel = {
|
||||
"2,Logic / Switching Blocks",
|
||||
"3,TA3 Button / Switch",
|
||||
"3,TA3 Command Converter",
|
||||
"3,TA3 Flip-Flop",
|
||||
"3,TA3 Logic Block",
|
||||
"3,TA3 Repeater",
|
||||
"3,TA3 Sequencer",
|
||||
@ -1075,6 +1076,12 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"The TA3 flip-flop changes its state with each received 'on' command. Received 'off' commands are ignored. Depending on the status change\\, 'on' / 'off' commands are sent alternately. The number of the target block or the numbers of the target blocks must be entered. The numbers can also be programmed using the Techage programmer.\n"..
|
||||
"\n"..
|
||||
"For example\\, lamps can be switched on and off with the help of buttons.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"The TA3 logic block can be programmed in such a way that one or more input commands are linked to one output command and sent. This block can therefore replace various logic elements such as AND\\, OR\\, NOT\\, XOR etc. \n"..
|
||||
"Input commands for the logic block are 'on' /'off' commands.\n"..
|
||||
"Input commands are referenced via the number\\, e.g. '1234' for the command from the sender with the number 1234. \n"..
|
||||
@ -2323,6 +2330,7 @@ techage.manual_EN.aItemName = {
|
||||
"ta3_logic",
|
||||
"ta3_button",
|
||||
"ta3_command_converter",
|
||||
"ta3_flipflop",
|
||||
"ta3_logic",
|
||||
"ta3_repeater",
|
||||
"ta3_sequencer",
|
||||
@ -2618,6 +2626,7 @@ techage.manual_EN.aPlanTable = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"ta4_windturbine",
|
||||
"",
|
||||
"",
|
||||
|
2
init.lua
2
init.lua
@ -52,7 +52,6 @@ techage.NodeDef = {} -- node registration info
|
||||
|
||||
techage.max_num_forceload_blocks = tonumber(minetest.settings:get("techage_max_num_forceload_blocks")) or 24
|
||||
|
||||
techage.basalt_stone_enabled = minetest.settings:get_bool("techage_basalt_stone_enabled") ~= false
|
||||
techage.ore_rarity = tonumber(minetest.settings:get("techage_ore_rarity")) or 1
|
||||
techage.modified_recipes_enabled = minetest.settings:get_bool("techage_modified_recipes_enabled") ~= false
|
||||
techage.collider_min_depth = tonumber(minetest.settings:get("techage_collider_min_depth")) or -28
|
||||
@ -292,6 +291,7 @@ dofile(MP.."/logic/light_detector.lua")
|
||||
dofile(MP.."/logic/player_detector.lua")
|
||||
dofile(MP.."/logic/gaze_sensor.lua")
|
||||
dofile(MP.."/logic/command_converter.lua")
|
||||
dofile(MP.."/logic/flipflop.lua")
|
||||
dofile(MP.."/logic/mba_detector.lua")
|
||||
dofile(MP.."/logic/cart_detector.lua")
|
||||
dofile(MP.."/logic/charge_detector.lua")
|
||||
|
@ -179,4 +179,4 @@ techage.register_node({
|
||||
end
|
||||
end,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
147
logic/flipflop.lua
Normal file
147
logic/flipflop.lua
Normal file
@ -0,0 +1,147 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2017-2023 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3 Flip-flop
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
local DESCR = S("TA3 Flip-Flop")
|
||||
|
||||
local logic = techage.logic
|
||||
|
||||
local function switch_on(pos)
|
||||
logic.swap_node(pos, "techage:ta3_flipflop_on")
|
||||
logic.send_on(pos, M(pos))
|
||||
end
|
||||
|
||||
local function switch_off(pos)
|
||||
logic.swap_node(pos, "techage:ta3_flipflop_off")
|
||||
logic.send_off(pos, M(pos))
|
||||
end
|
||||
|
||||
local function formspec(meta)
|
||||
local numbers = meta:get_string("numbers") or ""
|
||||
|
||||
return "formspec_version[4]size[10,3.5]"..
|
||||
"box[0.2,0.2;9.6,0.6;#c6e8ff]" ..
|
||||
"label[0.4,0.5;" .. minetest.colorize( "#000000", DESCR) .. "]" ..
|
||||
|
||||
"field[1.0,1.5;8,0.6;numbers;" .. S("Insert destination node number(s)") .. ";" .. numbers .. "]" ..
|
||||
|
||||
"button_exit[3.5,2.7;3,0.6;exit;" .. S("Save") .. "]"
|
||||
end
|
||||
|
||||
local function techage_set_numbers(pos, numbers, player_name)
|
||||
local meta = M(pos)
|
||||
local res = logic.set_numbers(pos, numbers, player_name, DESCR)
|
||||
meta:set_string("formspec", formspec(meta))
|
||||
return true --res
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
techage.remove_node(pos, oldnode, oldmetadata)
|
||||
techage.del_mem(pos)
|
||||
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)
|
||||
if fields.exit and fields.exit ~= "" then
|
||||
if techage.check_numbers(fields.numbers, player:get_player_name()) then
|
||||
meta:set_string("numbers", fields.numbers)
|
||||
logic.infotext(M(pos), DESCR)
|
||||
end
|
||||
meta:set_string("formspec", formspec(meta))
|
||||
elseif fields.exit == "close" then
|
||||
meta:set_string("formspec", formspec(meta))
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta3_flipflop_off", {
|
||||
description = DESCR,
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta3.png^techage_frame_ta3_top.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3_top.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_flipflop.png",
|
||||
},
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
logic.after_place_node(pos, placer, "techage:ta3_flipflop_off", DESCR)
|
||||
logic.infotext(meta, DESCR)
|
||||
meta:set_string("formspec", formspec(meta))
|
||||
end,
|
||||
|
||||
on_timer = function (pos, elapsed)
|
||||
switch_on(pos)
|
||||
end,
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
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_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta3_flipflop_on", {
|
||||
description = DESCR,
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta3.png^techage_frame_ta3_top.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3_top.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_flipflop_on.png",
|
||||
},
|
||||
|
||||
on_timer = function (pos, elapsed)
|
||||
switch_off(pos)
|
||||
end,
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
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_flipflop_off"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:ta3_flipflop_off",
|
||||
recipe = {
|
||||
{"", "group:wood", ""},
|
||||
{"default:mese_crystal_fragment", "default:steel_ingot", "techage:vacuum_tube"},
|
||||
{"", "group:wood", ""},
|
||||
},
|
||||
})
|
||||
|
||||
techage.register_node({
|
||||
"techage:ta3_flipflop_off", "techage:ta3_flipflop_on"
|
||||
}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "on" then
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
return true
|
||||
elseif topic == "off" then
|
||||
return true
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
}
|
||||
)
|
@ -544,6 +544,14 @@ Die Nummern können auch mit Hilfe des Techage Programmers programmiert werden.
|
||||
|
||||
[ta3_command_converter|image]
|
||||
|
||||
### TA3 Flipflop / Flip-Flop
|
||||
|
||||
Das TA3 Flipflop wechselt seinen Zustand mit jedem empfangenen `on` Kommando. Empfangene `off` Kommandos werden ignortiert. Damit werden abhängig vom Zustandswechsel abwechselnd `on` / `off` Kommandos gesendet. Die Nummer des Zielblockes bzw. die Nummern der Zielblöcke müssen eingegeben werden. Die Nummern können auch mit Hilfe des Techage Programmers programmiert werden.
|
||||
|
||||
Damit lassen sich bspw. Lampen mit Hilfe von Tastern ein- und wieder ausschalten.
|
||||
|
||||
[ta3_flipflop|image]
|
||||
|
||||
### TA3 Logikblock / Logic Block
|
||||
|
||||
Den TA3 Logikblock kann man so programmieren, dass ein oder mehrere Eingangskommandos zu einem Ausgangskommando verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND, OR, NOT, XOR usw. ersetzen.
|
||||
|
@ -537,7 +537,6 @@ Note: With the programmer, block numbers can be easily collected and configured.
|
||||
|
||||
[ta3_button|image]
|
||||
|
||||
|
||||
### TA3 Command Converter
|
||||
|
||||
With the TA3 command converter, `on` / `off` commands can be converted into other commands, and forwarding can be prevented or delayed.
|
||||
@ -547,6 +546,13 @@ The numbers can also be programmed using the Techage programmer.
|
||||
|
||||
[ta3_command_converter|image]
|
||||
|
||||
### TA3 Flip-Flop
|
||||
|
||||
The TA3 flip-flop changes its state with each received `on` command. Received `off` commands are ignored. Depending on the status change, `on` / `off` commands are sent alternately. The number of the target block or the numbers of the target blocks must be entered. The numbers can also be programmed using the Techage programmer.
|
||||
|
||||
For example, lamps can be switched on and off with the help of buttons.
|
||||
|
||||
[ta3_flipflop|image]
|
||||
|
||||
### TA3 Logic Block
|
||||
|
||||
|
@ -107,6 +107,7 @@
|
||||
- [Logik-/Schalt-Blöcke](./manual_ta3_DE.md#logik-schalt-blöcke)
|
||||
- [TA3 Taster/Schalter / Button/Switch](./manual_ta3_DE.md#ta3-tasterschalter--buttonswitch)
|
||||
- [TA3 Kommando Konverter / Command Converter](./manual_ta3_DE.md#ta3-kommando-konverter--command-converter)
|
||||
- [TA3 Flipflop / Flip-Flop](./manual_ta3_DE.md#ta3-flipflop--flip-flop)
|
||||
- [TA3 Logikblock / Logic Block](./manual_ta3_DE.md#ta3-logikblock--logic-block)
|
||||
- [TA3 Wiederholer / Repeater](./manual_ta3_DE.md#ta3-wiederholer--repeater)
|
||||
- [TA3 Sequenzer / Sequencer](./manual_ta3_DE.md#ta3-sequenzer--sequencer)
|
||||
|
@ -108,6 +108,7 @@
|
||||
- [Logic / Switching Blocks](./manual_ta3_EN.md#logic--switching-blocks)
|
||||
- [TA3 Button / Switch](./manual_ta3_EN.md#ta3-button--switch)
|
||||
- [TA3 Command Converter](./manual_ta3_EN.md#ta3-command-converter)
|
||||
- [TA3 Flip-Flop](./manual_ta3_EN.md#ta3-flip-flop)
|
||||
- [TA3 Logic Block](./manual_ta3_EN.md#ta3-logic-block)
|
||||
- [TA3 Repeater](./manual_ta3_EN.md#ta3-repeater)
|
||||
- [TA3 Sequencer](./manual_ta3_EN.md#ta3-sequencer)
|
||||
|
@ -1,9 +1,6 @@
|
||||
# Maximim number of Forceload Blocks per player (default 20)
|
||||
techage_max_num_forceload_blocks (Max. number of Forceload Blocks) int 20
|
||||
|
||||
# Enable Basalt Stone (and disable ore generation via cobble generator)
|
||||
techage_basalt_stone_enabled (Basalt Stone enabled) bool false
|
||||
|
||||
# Rarity factor to find ores when sieving with the Gravel Sieve
|
||||
# 1.0 is according to the mapgen generator
|
||||
# 2.0 means half as many ores as result
|
||||
|
BIN
textures/techage_appl_flipflop.png
Normal file
BIN
textures/techage_appl_flipflop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 126 B |
BIN
textures/techage_appl_flipflop_on.png
Normal file
BIN
textures/techage_appl_flipflop_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 126 B |
Loading…
Reference in New Issue
Block a user