Add NanoBasic to TA3 Terminal

This commit is contained in:
Joachim Stolberg 2024-12-30 22:13:10 +01:00
parent abd2c4a0be
commit 849112013f
17 changed files with 277 additions and 121 deletions

View File

@ -231,6 +231,7 @@ local function quarry_task(pos, crd, nvm)
end
end
crd.State:stop(pos, nvm, S("finished"))
stop_sound(pos)
end
local function keep_running(pos, elapsed)

View File

@ -341,7 +341,7 @@ function techage.not_protected(number, player_name)
if ninfo and ninfo.pos then
return not minetest.is_protected(ninfo.pos, player_name)
end
return false
return true -- node does not exist
end
-- Check the given number value.
@ -461,6 +461,10 @@ function techage.beduino_request_data(src, number, topic, payload)
else
return ndef.on_beduino_request_data(ninfo.pos, src, topic, payload or {})
end
else
if topic == 128 then
return 0, techage.get_node_lvm(ninfo.pos).name
end
end
end
return 1, ""

View File

@ -253,7 +253,7 @@ return {
"techage:ta2_clutch_off",
"",
"tube",
"concentrador",
"concentrator",
"ta2_pusher",
"ta2_distributor",
"",

View File

@ -64,7 +64,7 @@ return {
"3,TA3 Sound Block",
"3,TA3 Mesecons Umsetzer / TA3 Mesecons Converter",
"2,Detektoren",
"3,TA3 Detektor / Detector",
"3,TA3 Item Detektor / Item Detector",
"3,TA3 Wagen Detektor / Cart Detector",
"3,TA3 Block Detektor / Node Detector",
"3,TA3 Spieler Detektor / Player Detector",
@ -632,7 +632,7 @@ return {
"\n"..
"\n"..
"\n",
"Der Detektor ist eine spezieller Röhrenblock\\, der erkennt\\, wenn Items über die Röhre weitergegeben werden. Es muss dazu auf beiden Seiten mit der Röhre verbunden sein. Werden Items mit einem Schieber in den Detektor geschoben\\, gibt er diese automatisch weiter.\n"..
"Der Item Detektor ist eine spezieller Röhrenblock\\, der erkennt\\, wenn Items über die Röhre weitergegeben werden. Es muss dazu auf beiden Seiten mit der Röhre verbunden sein. Werden Items mit einem Schieber in den Detektor geschoben\\, gibt er diese automatisch weiter.\n"..
"Er sendet ein 'on'\\, wenn ein Item erkannt wird\\, gefolgt von einem 'off' eine Sekunde später.\n"..
"Danach werden weitere Kommando für 8 Sekunden blockiert.\n"..
"Die Wartezeit\\, sowie die Items\\, die ein Kommando auslösen sollen\\, können über das Gabelschlüssel-Menü konfiguriert werden.\n"..

View File

@ -64,7 +64,7 @@ return {
"3,TA3 Sound Block",
"3,TA3 Mesecons Converter",
"2,Detectors",
"3,TA3 Detector",
"3,TA3 Item Detector",
"3,TA3 Cart Detector",
"3,TA3 Node Detector",
"3,TA3 Player Detector",

View File

@ -51,7 +51,7 @@ return {
"3,TA4 4x Signallampe / 4x Signal Lamp",
"3,TA4 Spieler Detektor / Player Detector",
"3,TA4 Zustandssammler / State Collector",
"3,TA4 Detektor / Detector",
"3,TA4 Item Detektor / Item Detector",
"3,TA4 Block Detektor / Node Detector",
"3,TA4 Energiespeicher-Ladungsdetektor / Energy Storage Charge Detector",
"3,TA4 Blicksensor / Gaze Sensor",

View File

@ -51,7 +51,7 @@ return {
"3,TA4 4x Signal Lamp",
"3,TA4 Player Detector",
"3,TA4 State Collector",
"3,TA4 Detector",
"3,TA4 Item Detector",
"3,TA4 Node Detector",
"3,TA4 Energy Storage Charge Detector",
"3,TA4 Gaze Sensor",
@ -476,7 +476,7 @@ return {
"\n"..
"The status collector queries all configured machines in turn for the status. If one of the machines has reached or exceeded a preconfigured status\\, an \"on\" command is sent. For example\\, many machines can be easily monitored for faults from a Lua controller.\n"..
"\n",
"The functionality is the same as for the TA3 detector. In addition\\, the detector counts the items passed on.\n"..
"The functionality is the same as for the TA3 item detector. In addition\\, the detector counts the items passed on.\n"..
"This counter can be queried with the 'count' command and reset with 'reset'.\n"..
"\n"..
"\n"..

View File

@ -64,6 +64,20 @@ Basalt Stone Block=Basaltsteinblock
Basalt Stone Brick=Basaltsteinziegel
Sieved Basalt Gravel=Basaltkies gesiebt
### basic_terminal.lua ###
### movecontroller.lua ###
### terminal.lua ###
Operational mode=Betriebsmodus
### basic_terminal.lua ###
### terminal.lua ###
Access allowed for=Zugriff zulässig für
Friends are players for whom this area is not protected=Freunde sind Spieler, für die dieser Bereich nicht geschützt ist
Switch between TA3 terminal and BASIC computer=Umschalten zwischen TA3-Terminal und BASIC-Computer
TA3 Terminal=TA3 Terminal
### battery.lua ###
Battery=Batterie
@ -323,9 +337,10 @@ TA2 Cylinder=TA2 Zylinder
Counts down the number of items passed through@nand only triggers an 'on' command when it reaches zero.=Zählt die Anzahl der durchlaufenen Elemente herunter@nund löst nur dann einen 'ON'-Befehl aus, wenn er Null erreicht.
Current countdown=Aktueller Zähler
Current countdown value.=Aktueller Zählerwert.
TA3 Item Detector=TA3 Item Detektor
TA4 Collider Detector=TA4 Collider Detektor
TA4 Collider Detector Core=TA4 Collider Detektorkern
TA4 Detector=TA4 Detektor
TA4 Item Detector=TA3 Item Detektor
### detector.lua ###
### electricmeter.lua ###
@ -344,7 +359,6 @@ Blocking Time=Sperrzeit
Configured Items=Konfigurierte Gegenstände
Items which generate an 'on' command.@nIf empty, all passed items generate an 'on' command.=Items, die einen 'on'-Kommando generieren.@nWenn leer, generieren alle übergebenen Items einen 'on'-Befehl.
On Time=ON Zeit
TA3 Detector=TA3 Detektor
The time after the 'off' command@nuntil the next 'on' command is accepted.=Die Zeit nach dem 'off' Kommando,@nbis das nächste 'on' Kommando akzeptiert wird.
The time between the 'on' and 'off' commands.=Die Zeit zwischen den 'on' und 'off' Kommandos.
@ -601,6 +615,11 @@ Techage Forceload Block=Techage Forceload Block
Techage Forceload Tile=Techage Forceload Kachel
loaded=geladen
### forceload.lua ###
### teleport.lua ###
Status=Status
### formspecs.lua ###
Block has a wrench menu=Block hat ein Gabelschlüssel-Menü
@ -642,6 +661,8 @@ TA4 Fuel Cell Stack=Brennstoffzellenstapel
Furnace Top=Ofenoberteil
Outp=Ergeb.
Pre-Assignment Input Inv.=Vorbelegung Eingangs-Inv.
Stack locations can be pre-assigned to specific items,@nto be filled only with those items.=Stapelplätze können für bestimmte Artikeln vorbelegt werden, um nur mit diesen Artikeln gefüllt zu werden.
no fuel or no power=kein Strom oder Brennstoff
### gas_pipe.lua ###
@ -979,7 +1000,6 @@ Test Mini Tank=Testminitank
Error: Invalid distance !!=Fehler: Ungültige Entfernung !!
Move distance=Entfernung
Move distance (A to B)=Entfernung (A nach B)
Operational mode=Betriebsmodus
Switch to the remote controlled 'move xyz' mode=Wechseln in den ferngesteuerten 'move xyz'-Modus
TA Rack and Pinion=TA Zahnstange
TA4 Move Controller=TA4 Move Controller
@ -1430,6 +1450,8 @@ TA5 Hyperloop Chest=TA5 Hyperloop Kiste
### ta5_pump.lua ###
Operation=Betrieb
Pump direction=Pumprichtung
TA5 Pump=TA5 Pumpe
### ta5_tank.lua ###
@ -1446,13 +1468,16 @@ TA4 Tank=TA4 Tank
TA Tank Cart=TA Tankwagen
### tele.lua ###
TA3 Detector=TA3 Detektor
### teleport.lua ###
Connected=Verbunden
Connection status=Verbindungsstatus
Distance > @1 blocks=Abstand > @1 Blöcke
Ex-points missing (@1 < @2)=Erf.-Punkte fehlen (@1 < @2)
Status=Status
server not connected=Server nicht verbunden
### teleport_pipe.lua ###
@ -1471,7 +1496,6 @@ TA5 Teleport Block Items=TA5 Teleport Block Gegenstände
### terminal.lua ###
Syntax error, try help=Syntax Fehler, nutze help
TA3 Terminal=TA3 Terminal
TA4 Terminal=TA4 Terminal
commands like: help=Kommandos wie: help

View File

@ -64,6 +64,20 @@ Basalt Stone Block=Bloc de pierre de basalte
Basalt Stone Brick=Brique de pierre de basalte
Sieved Basalt Gravel=Gravier de basalte tamisé
### basic_terminal.lua ###
### movecontroller.lua ###
### terminal.lua ###
Operational mode=
### basic_terminal.lua ###
### terminal.lua ###
Access allowed for=
Friends are players for whom this area is not protected=
Switch between TA3 terminal and BASIC computer=
TA3 Terminal=Terminal TA3
### battery.lua ###
Battery=Batterie
@ -323,9 +337,10 @@ TA2 Cylinder=Cylindre TA2
Counts down the number of items passed through@nand only triggers an 'on' command when it reaches zero.=
Current countdown=
Current countdown value.=
TA3 Item Detector=
TA4 Collider Detector=
TA4 Collider Detector Core=
TA4 Detector=Détecteur TA4
TA4 Item Detector=
### detector.lua ###
### electricmeter.lua ###
@ -344,7 +359,6 @@ Blocking Time=
Configured Items=
Items which generate an 'on' command.@nIf empty, all passed items generate an 'on' command.=
On Time=
TA3 Detector=Détecteur TA3
The time after the 'off' command@nuntil the next 'on' command is accepted.=
The time between the 'on' and 'off' commands.=
@ -601,6 +615,11 @@ Techage Forceload Block=Bloc de Forceload Techage
Techage Forceload Tile=Tuile de Forceload Techage
loaded=chargé
### forceload.lua ###
### teleport.lua ###
Status=
### formspecs.lua ###
Block has a wrench menu=
@ -642,6 +661,8 @@ TA4 Fuel Cell Stack=Empilement de cellules à combustible TA4
Furnace Top=Haut du fourneau
Outp=
Pre-Assignment Input Inv.=
Stack locations can be pre-assigned to specific items,@nto be filled only with those items.=
no fuel or no power=pas de carburant ou pas d'électricité
### gas_pipe.lua ###
@ -979,7 +1000,6 @@ Test Mini Tank=
Error: Invalid distance !!=
Move distance=
Move distance (A to B)=
Operational mode=
Switch to the remote controlled 'move xyz' mode=
TA Rack and Pinion=
TA4 Move Controller=
@ -1430,6 +1450,8 @@ TA5 Hyperloop Chest=
### ta5_pump.lua ###
Operation=
Pump direction=
TA5 Pump=
### ta5_tank.lua ###
@ -1446,13 +1468,16 @@ TA4 Tank=Citerne TA4
TA Tank Cart=Chariot-citerne TA
### tele.lua ###
TA3 Detector=Détecteur TA3
### teleport.lua ###
Connected=
Connection status=
Distance > @1 blocks=
Ex-points missing (@1 < @2)=
Status=
server not connected=
### teleport_pipe.lua ###
@ -1471,7 +1496,6 @@ TA5 Teleport Block Items=
### terminal.lua ###
Syntax error, try help=Erreur de syntaxe, essayez l'aide
TA3 Terminal=Terminal TA3
TA4 Terminal=
commands like: help=commandes comme: aide
@ -1581,6 +1605,7 @@ TA4 Collider Detector Worker=
##### not used anymore #####
TA4 Detector=Détecteur TA4
TA3 Akku Box=TA3 Boite Akku
No plan available=Aucun plan disponible
Side view=Vue de côté

View File

@ -64,6 +64,20 @@ Basalt Stone Block=Блок базальтового камня
Basalt Stone Brick=Базальтовый кирпич
Sieved Basalt Gravel=Просеянный базальтовый камень
### basic_terminal.lua ###
### movecontroller.lua ###
### terminal.lua ###
Operational mode=Рабочий режим
### basic_terminal.lua ###
### terminal.lua ###
Access allowed for=
Friends are players for whom this area is not protected=
Switch between TA3 terminal and BASIC computer=
TA3 Terminal=TA3 Терминал
### battery.lua ###
Battery=Батарея
@ -323,9 +337,10 @@ TA2 Cylinder=TA2 Цилиндр
Counts down the number of items passed through@nand only triggers an 'on' command when it reaches zero.=Считает количество проходящих предметов@nи включается когда количество достигает нуля.
Current countdown=Кол-во предметов которое должно пройти
Current countdown value.=Кол-во прошедших предметов
TA3 Item Detector=
TA4 Collider Detector=TA4 Детектор коллайдера
TA4 Collider Detector Core=TA4 Ядро детектора коллайдера
TA4 Detector=TA4 Детектор
TA4 Item Detector=
### detector.lua ###
### electricmeter.lua ###
@ -344,7 +359,6 @@ Blocking Time=Время блокировки
Configured Items=Настроенные предметы
Items which generate an 'on' command.@nIf empty, all passed items generate an 'on' command.=Предметы, которые генерируют команду 'on' (включить).@nЕсли пусто, все прошедшие предметы генерируют команду 'on'.
On Time=Вовремя
TA3 Detector=TA3 Детектор
The time after the 'off' command@nuntil the next 'on' command is accepted.=Время после команды 'off' до приема следующей команды 'on'.
The time between the 'on' and 'off' commands.=Промежуток времени между командами 'on' (включить) и 'off' (выключить).
@ -591,6 +605,9 @@ TA2 Flywheel=TA2 Маховик
### forceload.lua ###
Area already loaded or max. number of Forceload Blocks reached!=Зона уже загружена или достигнуто максимальное количество блоков загрузки!
Area from=
Area to=
Block at pos=
List of your Forceload Blocks:=Список ваших блоков загрузки:
Punch the block to make the area visible.=Ударьте блок, что бы сделать зону видимой.
Show all forceload blocks in a 64x64x64 range=Показать все блоки загрузки в диапазоне 64x64x64.
@ -598,6 +615,11 @@ Techage Forceload Block=Techage Блок загрузки
Techage Forceload Tile=Techage Плитка загрузки
loaded=загружено
### forceload.lua ###
### teleport.lua ###
Status=Статус
### formspecs.lua ###
Block has a wrench menu=У блока есть меню для гаечного ключа
@ -639,6 +661,8 @@ TA4 Fuel Cell Stack=TA4 Блок топливных элементов
Furnace Top=Верхняя часть печи
Outp=Результат
Pre-Assignment Input Inv.=
Stack locations can be pre-assigned to specific items,@nto be filled only with those items.=
no fuel or no power=нет топлива или нет энергии
### gas_pipe.lua ###
@ -976,7 +1000,6 @@ Test Mini Tank=Тестовый мини резервуар
Error: Invalid distance !!=Ошибка: Неправильное расстояние!!
Move distance=Расстояние перемещения
Move distance (A to B)=Расстояние перемещения (из А в Б)
Operational mode=Рабочий режим
Switch to the remote controlled 'move xyz' mode=Переключиться в режим 'move xyz'
TA Rack and Pinion=TA Реечная передача
TA4 Move Controller=TA4 Контроллер движения
@ -1427,6 +1450,8 @@ TA5 Hyperloop Chest=TA5 Hyperloop сундук
### ta5_pump.lua ###
Operation=
Pump direction=
TA5 Pump=TA5 Насос
### ta5_tank.lua ###
@ -1443,13 +1468,16 @@ TA4 Tank=TA4 Резервуар
TA Tank Cart=TA Вагонетка с резервуаром
### tele.lua ###
TA3 Detector=TA3 Детектор
### teleport.lua ###
Connected=Соединен
Connection status=Статус соединения
Distance > @1 blocks=Расстояние > @1 блоков
Ex-points missing (@1 < @2)=Очки опыта отсутствуют (@1 < @2)
Status=Статус
server not connected=сервер не соединен
### teleport_pipe.lua ###
@ -1468,7 +1496,6 @@ TA5 Teleport Block Items=TA5 Блок для телепортирования п
### terminal.lua ###
Syntax error, try help=Синтаксическая ошибка, попробуйте написать help
TA3 Terminal=TA3 Терминал
TA4 Terminal=TA4 Терминал
commands like: help=команды как: help
@ -1574,3 +1601,8 @@ Remove detector=Убрать детектор
TA4 Collider Detector Worker=TA4 Построитель детектора коллайдера
[TA4] Detector is being built!=[TA4] Детектор был построен!
[TA4] Detector is being removed!=[TA4] Детектор был удален!
##### not used anymore #####
TA4 Detector=TA4 Детектор

View File

@ -64,6 +64,20 @@ Basalt Stone Block=
Basalt Stone Brick=
Sieved Basalt Gravel=
### basic_terminal.lua ###
### movecontroller.lua ###
### terminal.lua ###
Operational mode=
### basic_terminal.lua ###
### terminal.lua ###
Access allowed for=
Friends are players for whom this area is not protected=
Switch between TA3 terminal and BASIC computer=
TA3 Terminal=
### battery.lua ###
Battery=
@ -323,9 +337,10 @@ TA2 Cylinder=
Counts down the number of items passed through@nand only triggers an 'on' command when it reaches zero.=
Current countdown=
Current countdown value.=
TA3 Item Detector=
TA4 Collider Detector=
TA4 Collider Detector Core=
TA4 Detector=
TA4 Item Detector=
### detector.lua ###
### electricmeter.lua ###
@ -344,7 +359,6 @@ Blocking Time=
Configured Items=
Items which generate an 'on' command.@nIf empty, all passed items generate an 'on' command.=
On Time=
TA3 Detector=
The time after the 'off' command@nuntil the next 'on' command is accepted.=
The time between the 'on' and 'off' commands.=
@ -601,6 +615,11 @@ Techage Forceload Block=
Techage Forceload Tile=
loaded=
### forceload.lua ###
### teleport.lua ###
Status=
### formspecs.lua ###
Block has a wrench menu=
@ -642,6 +661,8 @@ TA4 Fuel Cell Stack=
Furnace Top=
Outp=
Pre-Assignment Input Inv.=
Stack locations can be pre-assigned to specific items,@nto be filled only with those items.=
no fuel or no power=
### gas_pipe.lua ###
@ -979,7 +1000,6 @@ Test Mini Tank=
Error: Invalid distance !!=
Move distance=
Move distance (A to B)=
Operational mode=
Switch to the remote controlled 'move xyz' mode=
TA Rack and Pinion=
TA4 Move Controller=
@ -1430,6 +1450,8 @@ TA5 Hyperloop Chest=
### ta5_pump.lua ###
Operation=
Pump direction=
TA5 Pump=
### ta5_tank.lua ###
@ -1446,13 +1468,16 @@ TA4 Tank=
TA Tank Cart=
### tele.lua ###
TA3 Detector=
### teleport.lua ###
Connected=
Connection status=
Distance > @1 blocks=
Ex-points missing (@1 < @2)=
Status=
server not connected=
### teleport_pipe.lua ###
@ -1471,7 +1496,6 @@ TA5 Teleport Block Items=
### terminal.lua ###
Syntax error, try help=
TA3 Terminal=
TA4 Terminal=
commands like: help=

View File

@ -20,6 +20,15 @@ local Functions = {}
local Actions = {}
local Buttons = {"Edit", "Save", "Renum", "Cancel", "Run", "Stop", "Continue", "List"}
local States = {"init", "edit", "stopped", "running", "error", "input_str", "input_num", "break"}
local ErrorStr = {
[1] = "Node not found",
[2] = "Command not supported",
[3] = "Command failed",
[4] = "Access denied",
[5] = "Wrong response type",
[6] = "Wrong number of parameters",
}
local InputField = "style_type[field;textcolor=#FFFFFF]" ..
"field[1.5,0.8;7.4,0.7;input;;]" ..
"field_close_on_enter[input;false]" ..
@ -190,7 +199,7 @@ local function replace_all_goto_refs(lines, new_nums)
lines[num] = line:gsub("GOSUB%s+%d+", "GOSUB " .. new_num)
end
end
local goto_num = line:match("goto%s+(%d+)")
goto_num = line:match("goto%s+(%d+)")
if goto_num then
local new_num = new_nums[goto_num]
if new_num then
@ -213,10 +222,12 @@ local function renumber_lines(pos, nvm, code)
local num = 10
for line in code:gmatch("[^\r\n]+") do
local s = line:match("^%s*(%d+)")
if s then
if s and tonumber(s) < 65000 then
lines[#lines + 1] = num .. line:sub(s:len() + 1)
new_nums[s] = num
num = num + 10
else
lines[#lines + 1] = line
end
end
@ -381,6 +392,47 @@ minetest.register_node("techage:basic_terminal", {
--
-- Register VM external/callback functions
--
local function get_num_param(pos, num_param)
local payload2 = 0
local payload1 = 0
local cmnd, num, owner, own_num
if num_param == 4 then
payload2 = nanobasic.pop_num(pos) or 0
end
if num_param >= 3 then
payload1 = nanobasic.pop_num(pos) or 0
end
cmnd = nanobasic.pop_num(pos)
num = nanobasic.pop_num(pos) or 0
owner = M(pos):get_string("owner")
own_num = M(pos):get_string("node_number")
return owner, num, own_num, {payload1, payload2}
end
local function get_str_param(pos, num_param)
local payload1 = ""
local cmnd, num, owner, own_num
if num_param == 3 then
payload1 = nanobasic.pop_str(pos) or ""
end
cmnd = nanobasic.pop_num(pos)
num = nanobasic.pop_num(pos) or 0
owner = M(pos):get_string("owner")
own_num = M(pos):get_string("node_number")
return owner, num, own_num, payload1
end
local function error_handling(pos, sts)
local nvm = techage.get_nvm(pos)
if sts > 0 and nvm.error_label_addr and nvm.error_label_addr > 0 then
local err = ErrorStr[sts] or "unknown error"
nanobasic.push_str(pos, err)
nanobasic.set_pc(pos, nvm.error_label_addr)
end
end
register_ext_function("input", {nanobasic.NB_STR}, nanobasic.NB_NUM, function(pos, nvm)
nvm.status = "input_num"
local s = nanobasic.pop_str(pos)
@ -418,90 +470,83 @@ register_ext_function("time", {}, nanobasic.NB_NUM, function(pos, nvm)
return true
end)
-- str: cmd$(num: node_num, str: cmnd, str: payload)
register_ext_function("cmd$", {nanobasic.NB_NUM, nanobasic.NB_STR, nanobasic.NB_STR}, nanobasic.NB_STR, function(pos, nvm)
local payload = nanobasic.pop_str(pos) or ""
local cmnd = nanobasic.pop_str(pos) or ""
local num = tostring(nanobasic.pop_num(pos) or 0)
local own_num = M(pos):get_string("node_number")
local owner = M(pos):get_string("owner")
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local resp = techage.send_single(own_num, num, cmnd, payload)
if type(resp) == "string" then
nanobasic.push_str(pos, resp)
else
nanobasic.push_str(pos, dump(resp))
-- num: cmd(num: node_num, num: cmnd, any: pyld1, any: pyld2)
register_ext_function("cmd", {nanobasic.NB_NUM, nanobasic.NB_NUM, nanobasic.NB_ANY, nanobasic.NB_ANY}, nanobasic.NB_NUM, function(pos, nvm)
local num_param = nanobasic.stack_depth(pos)
if num_param >= 2 and num_param <= 4 then
local cmnd = nanobasic.peek_num(pos, num_param - 1) or 0
if cmnd < 64 then -- command with payload as number(s)
local owner, num, own_num, payload = get_num_param(pos, num_param)
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_send_cmnd(own_num, num, cmnd, payload)
nanobasic.push_num(pos, sts)
error_handling(pos, sts)
else
nanobasic.push_num(pos, 4)
error_handling(pos, 4)
end
elseif cmnd < 128 then -- command with payload as string
local owner, num, own_num, payload = get_str_param(pos, num_param)
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_send_cmnd(own_num, num, cmnd, payload)
nanobasic.push_num(pos, sts)
error_handling(pos, sts)
else
nanobasic.push_num(pos, 4)
error_handling(pos, 4)
end
else -- request with payload as number(s) and result as number
local owner, num, own_num, payload = get_num_param(pos, num_param)
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_request_data(own_num, num, cmnd, payload)
print("cmd resp", sts, dump(resp))
if type(resp) == "table" then
nanobasic.push_num(pos, resp[1] or 0)
else
nanobasic.push_num(pos, 5)
sts = 5
end
error_handling(pos, sts)
else
nanobasic.push_num(pos, 4)
error_handling(pos, 4)
end
end
else
nanobasic.push_str(pos, "protected")
nanobasic.push_num(pos, 6)
error_handling(pos, 6)
end
return true
end)
-- num: cmd(num: node_num, num: cmnd, arr: payload)
register_ext_function("bcmd", {nanobasic.NB_NUM, nanobasic.NB_NUM, nanobasic.NB_ARR}, nanobasic.NB_NUM, function(pos, nvm)
local addr = nanobasic.pop_arr_addr(pos)
local payload = nanobasic.read_arr(pos, addr) or {}
local cmnd = nanobasic.pop_num(pos) or 0
local num = nanobasic.pop_num(pos) or 0
local own_num = M(pos):get_string("node_number")
local owner = M(pos):get_string("owner")
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local resp = techage.beduino_send_cmnd(own_num, num, cmnd, payload)
nanobasic.push_num(pos, resp)
else
nanobasic.push_num(pos, 4)
end
return true
end)
-- num: breq(num: node_num, num: cmnd, arr: payload)
register_ext_function("breq", {nanobasic.NB_NUM, nanobasic.NB_NUM, nanobasic.NB_ARR}, nanobasic.NB_NUM, function(pos, nvm)
local addr = nanobasic.pop_arr_addr(pos)
local payload = nanobasic.read_arr(pos, addr) or {}
local cmnd = nanobasic.pop_num(pos) or 0
local num = nanobasic.pop_num(pos) or 0
local own_num = M(pos):get_string("node_number")
local owner = M(pos):get_string("owner")
--print("breq", own_num, num, cmnd, owner)
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_request_data(own_num, num, cmnd, payload)
if type(resp) == "table" then
nanobasic.write_arr(pos, addr, resp)
nanobasic.push_num(pos, sts)
else
nanobasic.push_num(pos, 5)
-- str: cmd(num: node_num, num: cmnd, any: pyld1, any: pyld2)
register_ext_function("cmd$", {nanobasic.NB_NUM, nanobasic.NB_NUM, nanobasic.NB_ANY, nanobasic.NB_ANY}, nanobasic.NB_STR, function(pos, nvm)
local num_param = nanobasic.stack_depth(pos)
if num_param >= 2 and num_param <= 4 then
local cmnd = nanobasic.peek_num(pos, num_param - 1) or 0
if cmnd >= 128 then -- request with payload as number(s) and result as string
local owner, num, own_num, payload = get_num_param(pos, num_param)
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_request_data(own_num, num, cmnd, payload)
if type(resp) == "string" then
nanobasic.push_str(pos, resp)
else
nanobasic.push_str(pos, "")
sts = 5
end
error_handling(pos, sts)
else
nanobasic.push_str(pos, "")
error_handling(pos, 4)
end
end
else
nanobasic.push_num(pos, 4)
end
return true
end)
-- str: breq(num: node_num, num: cmnd, arr: payload)
register_ext_function("breq$", {nanobasic.NB_NUM, nanobasic.NB_NUM, nanobasic.NB_ARR}, nanobasic.NB_STR, function(pos, nvm)
local addr = nanobasic.pop_arr_addr(pos)
local payload = nanobasic.read_arr(pos, addr) or {}
local cmnd = nanobasic.pop_num(pos) or 0
local num = nanobasic.pop_num(pos) or 0
local own_num = M(pos):get_string("node_number")
local owner = M(pos):get_string("owner")
if techage.not_protected(tostring(num), owner) then
techage.counting_add(owner, 1)
local sts, resp = techage.beduino_request_data(own_num, num, cmnd, payload)
print("breq$", sts, dump(resp))
if type(resp) == "string" and sts == 0 then
nanobasic.push_str(pos, resp)
elseif sts > 0 then
nanobasic.push_str(pos, "<" .. tostring(sts) .. ">")
elseif type(resp) ~= "string" then
nanobasic.push_str(pos, "<5>")
end
else
nanobasic.push_str(pos, "<4>")
nanobasic.push_str(pos, "")
error_handling(pos, 6)
end
return true
end)
@ -609,7 +654,7 @@ register_action({"edit"}, "Save", function(pos, nvm, fields)
end)
register_action({"edit"}, "Renum", function(pos, nvm, fields)
code = sort_lines(pos, nvm, fields.code)
local code = sort_lines(pos, nvm, fields.code)
if code == nil then
nvm.status = "error"
nvm.bttns = {"Edit", "", "", "", "", "Stop", "", ""}
@ -640,6 +685,7 @@ register_action({"init", "edit", "stopped"}, "Run", function(pos, nvm, fields)
nvm.bttns = {"", "", "", "", "", "Stop", "", ""}
nvm.input = ""
nvm.variables = nanobasic.get_variable_list(pos)
nvm.error_label_addr = nanobasic.get_label_address(pos, "65000") or 0
--print("nvm.variables", dump(nvm.variables))
minetest.get_node_timer(pos):start(0.2)
return nanobasic.get_screen_buffer(pos) or ""

View File

@ -127,8 +127,8 @@ local function after_place_node3(pos, placer)
local meta = M(pos)
local inv = meta:get_inventory()
inv:set_size('cfg', 4)
logic.after_place_node(pos, placer, "techage:ta3_detector_off", S("TA3 Detector"))
logic.infotext(meta, S("TA3 Detector"))
logic.after_place_node(pos, placer, "techage:ta3_detector_off", S("TA3 Item Detector"))
logic.infotext(meta, S("TA3 Item Detector"))
meta:set_string("formspec", formspec(meta))
end
@ -136,8 +136,8 @@ local function after_place_node4(pos, placer)
local meta = M(pos)
local inv = meta:get_inventory()
inv:set_size('cfg', 4)
logic.after_place_node(pos, placer, "techage:ta4_detector_off", S("TA4 Detector"))
logic.infotext(meta, S("TA4 Detector"))
logic.after_place_node(pos, placer, "techage:ta4_detector_off", S("TA4 Item Detector"))
logic.infotext(meta, S("TA4 Item Detector"))
meta:set_string("formspec", formspec(meta))
end
@ -175,7 +175,7 @@ local function ta_after_formspec(pos, fields, playername)
end
minetest.register_node("techage:ta3_detector_off", {
description = S("TA3 Detector"),
description = S("TA3 Item Detector"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
@ -203,7 +203,7 @@ minetest.register_node("techage:ta3_detector_off", {
minetest.register_node("techage:ta3_detector_on", {
description = S("TA3 Detector"),
description = S("TA3 Item Detector"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
@ -228,7 +228,7 @@ minetest.register_node("techage:ta3_detector_on", {
})
minetest.register_node("techage:ta4_detector_off", {
description = S("TA4 Detector"),
description = S("TA4 Item Detector"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",
@ -257,7 +257,7 @@ minetest.register_node("techage:ta4_detector_off", {
minetest.register_node("techage:ta4_detector_on", {
description = S("TA4 Detector"),
description = S("TA4 Item Detector"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",

View File

@ -727,9 +727,9 @@ Detektoren scannen ihre Umgebung ab und senden ein `on`-Kommando, wenn das Gesuc
[ta3_nodedetector|image]
### TA3 Detektor / Detector
### TA3 Item Detektor / Item Detector
Der Detektor ist eine spezieller Röhrenblock, der erkennt, wenn Items über die Röhre weitergegeben werden. Es muss dazu auf beiden Seiten mit der Röhre verbunden sein. Werden Items mit einem Schieber in den Detektor geschoben, gibt er diese automatisch weiter.
Der Item Detektor ist eine spezieller Röhrenblock, der erkennt, wenn Items über die Röhre weitergegeben werden. Es muss dazu auf beiden Seiten mit der Röhre verbunden sein. Werden Items mit einem Schieber in den Detektor geschoben, gibt er diese automatisch weiter.
Er sendet ein `on`, wenn ein Item erkannt wird, gefolgt von einem `off` eine Sekunde später.
Danach werden weitere Kommando für 8 Sekunden blockiert.
Die Wartezeit, sowie die Items, die ein Kommando auslösen sollen, können über das Gabelschlüssel-Menü konfiguriert werden.

View File

@ -723,7 +723,7 @@ Detectors scan their surroundings and send an `on` command when the search is re
[ta3_nodedetector|image]
### TA3 Detector
### TA3 Item Detector
The detector is a special tube block that detects when items are passed on through the tube. To do this, it must be connected to tubes on both sides. If items are pushed into the detector with a pusher, they are automatically passed on.
It sends an `on` when an item is recognized, followed by an `off` a second later.

View File

@ -531,7 +531,7 @@ Beim TA4 Spieler Detektor hat sich nur das Aussehen geändert. Die Funktionalit
Der Zustandssammler fragt der Reihe nach alle konfigurierten Maschinen nach dem Status ab. Wenn eine der Maschinen einen vorkonfigurierte Status erreicht oder überschritten hat, wird ein "on" Kommando gesendet. Damit können bspw. vom einem Lua Controller aus sehr einfach viele Maschinen auf Störungen überwacht werden.
### TA4 Detektor / Detector
### TA4 Item Detektor / Item Detector
Die Funktionalität ist gleich wie beim TA3 Detektor / Detector. Zusätzlich zählt der Detector aber die weitergegebenen Items.
Diesen Zähler kann man über das Kommando 'count' abfragen und über 'reset' zurücksetzen.

View File

@ -522,9 +522,9 @@ Only the appearance of the TA4 player detector has changed. The functionality is
The status collector queries all configured machines in turn for the status. If one of the machines has reached or exceeded a preconfigured status, an "on" command is sent. For example, many machines can be easily monitored for faults from a Lua controller.
### TA4 Detector
### TA4 Item Detector
The functionality is the same as for the TA3 detector. In addition, the detector counts the items passed on.
The functionality is the same as for the TA3 item detector. In addition, the detector counts the items passed on.
This counter can be queried with the 'count' command and reset with 'reset'.
[ta4_detector|image]