Activate ta4 movecontroller, ta4 sequencer and command counting

This commit is contained in:
Joachim Stolberg 2021-10-24 21:15:19 +02:00
parent 3505751f16
commit ad25882ca1
8 changed files with 179 additions and 23 deletions

View File

@ -14,6 +14,10 @@
local PlayerName
local PlayerPoints = {}
local LastPlayerPoints = {}
local S = techage.S
local MAX_POINTS = tonumber(minetest.settings:get("techage_command_limit")) or 1200
function techage.counting_start(player_name)
PlayerName = player_name
@ -32,11 +36,33 @@ end
local function output()
for name, val in pairs(PlayerPoints) do
minetest.log("action", "[techage] " .. name .. " hat " .. val .. " Punkte")
if val > MAX_POINTS then
local obj = minetest.get_player_by_name(name)
if obj then
minetest.chat_send_player(name,
S("[techage] The limit for 'number of commands per minute' has been exceeded.") ..
" " .. string.format(MAX_POINTS .. " " .. S("is allowed. Current value is") .. " " .. val));
minetest.log("action", "[techage] " .. name ..
" exceeds the limit for commands per minute. value = " .. val)
local factor = 100 / (obj:get_armor_groups().fleshy or 100)
obj:punch(obj, 1.0, {full_punch_interval=1.0, damage_groups = {fleshy=factor * 5}})
end
end
end
LastPlayerPoints = table.copy(PlayerPoints)
PlayerPoints = {}
minetest.after(60, output)
end
minetest.after(60, output)
minetest.register_chatcommand("ta_limit", {
description = "Get your current techage command limit value",
func = function(name)
local num = LastPlayerPoints[name] or 0
return true, S("Your current value is") .. " " .. num .. " " .. S("per minute") .. ". " ..
MAX_POINTS .. " " .. S("is allowed")
end
})

View File

@ -113,6 +113,13 @@ Access:=Zugriff:
TA3 Button/Switch=TA3 Taster/Schalter
TA4 Button/Switch=TA4 Schalter/Taster
### button.lua ###
### button_4x.lua ###
### signallamp_4x.lua ###
Command=Kommando
Command to be sent=Zu sendender Befehl
### button.lua ###
### cart_detector.lua ###
### detector.lua ###
@ -130,6 +137,7 @@ Insert destination node number(s)=Gebe Zielnummer(n) ein
### doorcontroller.lua ###
### mesecons_converter.lua ###
### repeater.lua ###
### sequencer2.lua ###
### submenu.lua ###
Save=Speichern
@ -145,8 +153,6 @@ TA4 4x Button=TA4 4x Taster
Access=Zugriff
Button protection=Tastenschutz
Command=Kommando
Command to be sent=Zu sendender Befehl
Destination block number=Zielblocknummer
Number=Nummer
@ -220,6 +226,14 @@ TA3 Melting=TA3 Schmelzen
TA3 Cooler=TA3 Kühler
### counting.lua ###
Your current value is=Der aktuelle Wert ist
[techage] The limit for 'number of commands per minute' has been exceeded.=[techage] Das Limit für 'Anzahl Befehle pro Minute' wurde überschritten.
is allowed=ist erlaubt
is allowed. Current value is=ist erlaubt. Aktueller Wert ist
per minute=pro Minute
### cylinder.lua ###
TA2 Cylinder=TA2 Zylinder
@ -276,15 +290,19 @@ Blocks are back=Blöcke sind wieder da
Blocks are disappeared=Blöcke sind verschwunden
Click on all the blocks that are part of the door/gate=Klicke auf alle Blöcke, die Teil des Tores sind
Ctrl,Inv=Ctrl,Inv
Done=Fertig
Record=Aufzeichnen
Recording...=Aufzeichnung...
Remove=Entfernen
Set=Setzen
TA3 Door Controller II=TA3 Tür Controller II
block positions are stored.=Block Positionen gespeichert.
with door sound=mit Türgeräusch
### doorcontroller2.lua ###
### movecontroller.lua ###
Done=Fertig
Record=Aufzeichnen
Recording...=Aufzeichnung...
block positions are stored.=Block Positionen gespeichert.
### drillbox.lua ###
Build derrick=Errichte Ölturm
@ -634,10 +652,15 @@ Syntax=Syntax
### logic_block.lua ###
### lua_logic.lua ###
Store=Speichern
TA3 Logic Block=TA3 Logikblock
Update=Update
### logic_block.lua ###
### lua_logic.lua ###
### movecontroller.lua ###
Store=Speichern
### lye.lua ###
Lye=Lauge
@ -695,6 +718,27 @@ TA1 Pine Wood Board=TA1 Kiefernholzbrett
TA4 Streetlamp Solar Cell=TA4 Straßenlampen-Solarzelle
### movecontroller.lua ###
Click on all blocks that shall be moved=Klicke auf alle Blöcke, die verschoben werden sollen
Destination position is protected=Zielposition ist geschützt
Handover to A=Übergabe an A
Handover to B=Übergabe an B
Maximum Speed=Maximalgeschwindigkeit
Maximum speed for the moving block.=Maximale Geschwindigkeit für den beweglichen Block.
Move A-B=Bewege A-B
Move B-A=Bewege B-A
Move block height=Move Block Höhe
Move distance (A to B)=Entfernung (A nach B)
No valid destination position=Keine gültige Zielposition
No valid node at the start position=Kein gültiger Block an der Startposition
Number of the next movecontroller.=Nummer des nächsten Move Controllers.
Number of the previous movecontroller.=Nummer des vorherigen Move Controllers.
Position list error=Positionslistenfehler
Start position is protected=Startposition ist geschützt
TA4 Move Controller=TA4 Move Controller
Value in the range of 0.0 to 1.0=Wert im Bereich von 0.0 bis 1.0
### node_detector.lua ###
Send signal if nodes have been:=Sende ein Signal falls Blöcke:
@ -905,8 +949,26 @@ not connected=nicht verbunden
### sequencer.lua ###
TA3 Sequencer=TA3 Sequenzer
### sequencer.lua ###
### sequencer2.lua ###
stopped=gestoppt
### sequencer2.lua ###
Commands=Kommandos
Invalid command!=Ungültiges Kommando!
Start=Start
Stop=Stopp
TA4 Sequencer=TA4 Sequenzer
running=läuft
### sequencer2.lua ###
### submenu.lua ###
Cancel=Abbruch
### signallamp.lua ###
TA4 Wind Turbine Signal Lamp=TA4 Windkraftanlagenlampe
@ -979,7 +1041,6 @@ TA4 LED Street Lamp Pole=TA4 LED Lampenmast
### submenu.lua ###
Cancel=Abbruch
Note: You can't change any values while the block is running!=Hinweis: Während der Block läuft, kann kein Wert geändert werden!
Refresh=Aktualisieren
@ -1161,3 +1222,5 @@ is a suitable place for a wind turbine!=ist ein geeigneter Ort für eine Windkra
##### not used anymore #####
[techage] The limit for commands per minute has been exceeded.=[techage] Das Limit für Befehle pro Minute wurde überschritten.

View File

@ -113,6 +113,13 @@ Access:=
TA3 Button/Switch=
TA4 Button/Switch=
### button.lua ###
### button_4x.lua ###
### signallamp_4x.lua ###
Command=
Command to be sent=
### button.lua ###
### cart_detector.lua ###
### detector.lua ###
@ -130,6 +137,7 @@ Insert destination node number(s)=
### doorcontroller.lua ###
### mesecons_converter.lua ###
### repeater.lua ###
### sequencer2.lua ###
### submenu.lua ###
Save=
@ -145,8 +153,6 @@ TA4 4x Button=
Access=
Button protection=
Command=
Command to be sent=
Destination block number=
Number=
@ -220,6 +226,14 @@ TA3 Melting=
TA3 Cooler=
### counting.lua ###
Your current value is=
[techage] The limit for 'number of commands per minute' has been exceeded.=
is allowed=
is allowed. Current value is=
per minute=
### cylinder.lua ###
TA2 Cylinder=
@ -276,15 +290,19 @@ Blocks are back=
Blocks are disappeared=
Click on all the blocks that are part of the door/gate=
Ctrl,Inv=
Done=
Record=
Recording...=
Remove=
Set=
TA3 Door Controller II=
block positions are stored.=
with door sound=
### doorcontroller2.lua ###
### movecontroller.lua ###
Done=
Record=
Recording...=
block positions are stored.=
### drillbox.lua ###
Build derrick=
@ -634,10 +652,15 @@ Syntax=
### logic_block.lua ###
### lua_logic.lua ###
Store=
TA3 Logic Block=
Update=
### logic_block.lua ###
### lua_logic.lua ###
### movecontroller.lua ###
Store=
### lye.lua ###
Lye=
@ -695,6 +718,27 @@ TA1 Pine Wood Board=
TA4 Streetlamp Solar Cell=
### movecontroller.lua ###
Click on all blocks that shall be moved=
Destination position is protected=
Handover to A=
Handover to B=
Maximum Speed=
Maximum speed for the moving block.=
Move A-B=
Move B-A=
Move block height=
Move distance (A to B)=
No valid destination position=
No valid node at the start position=
Number of the next movecontroller.=
Number of the previous movecontroller.=
Position list error=
Start position is protected=
TA4 Move Controller=
Value in the range of 0.0 to 1.0=
### node_detector.lua ###
Send signal if nodes have been:=
@ -905,8 +949,26 @@ not connected=
### sequencer.lua ###
TA3 Sequencer=
### sequencer.lua ###
### sequencer2.lua ###
stopped=
### sequencer2.lua ###
Commands=
Invalid command!=
Start=
Stop=
TA4 Sequencer=
running=
### sequencer2.lua ###
### submenu.lua ###
Cancel=
### signallamp.lua ###
TA4 Wind Turbine Signal Lamp=
@ -979,7 +1041,6 @@ TA4 LED Street Lamp Pole=
### submenu.lua ###
Cancel=
Note: You can't change any values while the block is running!=
Refresh=

View File

@ -175,7 +175,9 @@ local function entity_to_node(pos, obj)
local meta = M(pos)
if not meta:contains("ta_move_block") then
meta:set_string("ta_move_block", minetest.serialize({name=name, param2=param2}))
return
end
minetest.add_item(pos, ItemStack(name))
elseif ndef1 then
minetest.add_item(pos, ItemStack(name))
end
@ -563,7 +565,7 @@ local function move_nodes(pos, lpos1, lpos2, handover)
if not is_simple_node(pos1) then
meta:set_string("status", S("No valid node at the start position"))
else
meta:set_string("status", S("No air at the destination position"))
meta:set_string("status", S("No valid destination position"))
end
end
else

View File

@ -114,9 +114,6 @@ local function check_rules(pos, elapsed)
nvm.index = get_next_slot(nvm.index, nvm.rules, nvm.endless)
if nvm.index ~= nil and offs ~= nil and nvm.running then
-- after the last rule a pause with 1 or more sec is required
if nvm.index == 1 and offs < 1 then
offs = 1
end
if offs > 0 then
-- we can't restart the timer within the function om_timer
minetest.after(0, restart_timer, pos, offs)

View File

@ -31,7 +31,7 @@ end
local function command(s)
local num, cmd, pld = unpack(string.split(s, " ", false, 2))
if not num or not cmd then
return "Invalid command!"
return S("Invalid command!")
end
return {number = num, cmnd = cmd, payload = pld}
end
@ -171,7 +171,9 @@ local function node_timer(pos, elapsed)
local code = mem.code.tCode[mem.idx]
if code and code.cmnd then
local src = M(pos):get_string("node_number")
techage.counting_start(M(pos):get_string("owner"))
techage.send_single(src, code.number, code.cmnd, code.payload)
techage.counting_stop()
end
if code and code.next_idx then
local offs = code.next_idx - mem.idx

View File

@ -403,7 +403,8 @@ local function call_loop(pos, meta, elapsed)
local code = Cache[number].code
local res = safer_lua.run_loop(pos, elapsed, code, error)
if res then
t = minetest.get_us_time() - t
-- Don't count thread changes
t = math.min(minetest.get_us_time() - t, 1000)
cpu = math.floor(((cpu * 20) + t) / 21)
meta:set_int("cpu", cpu)
meta:set_string("infotext", "Controller "..number..": running ("..cpu.."us)")

View File

@ -26,3 +26,7 @@ techage_use_marshal (use lua-marshal as serialize/deserialize functions) bool fa
# Use the external library 'lsqlite3' for for faster storing of data.
# See also 'README.md'.
techage_use_sqlite (use sqlite database) bool false
# To reduce the server CPU load, the number of sent techage commands
# per player and minute can be limited.
techage_command_limit (Max. number of commands sent per minute) int 1200