Turned the whole thing into a modpack.
This commit is contained in:
parent
69e6e3ae13
commit
43a8e5bbec
1
modpack.txt
Normal file
1
modpack.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
The presence of this file indicates that the current folder is a modpack.
|
@ -1,7 +1,11 @@
|
|||||||
|
if not digiline then
|
||||||
|
print("Digilines not found.")
|
||||||
|
return
|
||||||
|
end
|
||||||
local oldprint=print
|
local oldprint=print
|
||||||
local function print(...)
|
local function print(...)
|
||||||
for k,v in ipairs({...}) do
|
for k,v in ipairs({...}) do
|
||||||
oldprint("[Test3D] "..tostring(v))
|
oldprint("[Test3D:T400] "..tostring(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print("Test3D loading.")
|
print("Test3D loading.")
|
||||||
@ -10,15 +14,9 @@ local tInstructions = {
|
|||||||
"NOP",
|
"NOP",
|
||||||
"ADD",
|
"ADD",
|
||||||
"SUB",
|
"SUB",
|
||||||
|
"PEEK",
|
||||||
|
"POKE",
|
||||||
}
|
}
|
||||||
--[[
|
|
||||||
local statedir = minetest.get_worldpath() .. '/' .. minetest.get_current_modname() .. "/"
|
|
||||||
print("State directory: "..statedir)
|
|
||||||
if not digiline then
|
|
||||||
print("Digilines not found.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
local function push(pos,val)
|
local function push(pos,val)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local sstack = ""
|
local sstack = ""
|
||||||
@ -43,43 +41,46 @@ local function pop(pos)
|
|||||||
end
|
end
|
||||||
return tonumber(n)
|
return tonumber(n)
|
||||||
end
|
end
|
||||||
local function t21_digiline_receive(pos, node, channel, msg)
|
local function t400_digiline_receive(pos, node, channel, msg)
|
||||||
print(pos,node,channel,msg)
|
print(pos,node,channel,msg)
|
||||||
meta = minetest.get_meta(pos)
|
meta = minetest.get_meta(pos)
|
||||||
if meta:get_string("state") == "waiting" and meta:get_string("waitingfor") == channel then
|
if meta:get_string("waitingfor") == channel then
|
||||||
push(pos,msg)
|
if meta:get_string("state") == "waitingstack" then
|
||||||
|
push(pos,msg)
|
||||||
|
if meta:get_string("state") == "waitingins" then
|
||||||
|
meta:set_int("ci",tonumber(msg))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print("Created T21 digiline function")
|
print("Created T400 digiline function")
|
||||||
|
|
||||||
local function t21_set_infotext(pos)
|
local function t400_set_infotext(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local running="false"
|
local running="false"
|
||||||
if meta:get_int("test3d_running") == 1 then running="true" end
|
if meta:get_int("test3d_running") == 1 then running="true" end
|
||||||
meta:set_string("infotext","Running: "..running.."\nState: "..meta:get_string("state").."\nPC: "..tostring(meta:get_int("pc")).."\nACC: "..tostring(meta:get_int("acc")).."\nBAK: "..tostring(meta:get_int("bak")))
|
meta:set_string("infotext","Running: "..running.."\nState: "..meta:get_string("state").."\nPC: "..tostring(meta:get_int("pc")).."\nACC: "..tostring(meta:get_int("acc")).."\nBAK: "..tostring(meta:get_int("bak")))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function t21_set_meta(pos)
|
local function t400_set_meta(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local fspec = "size[8,9]\nlabel[0,0;T21 execution node]\nfield[0.25,1;8,1;channel;Channel prefix;${channel}]\n"
|
local fspec = "size[8,9]\nlabel[0,0;T400 execution node]\nfield[0.25,1;8,1;channel;Channel prefix;${channel}]\n"
|
||||||
fspec = fspec .. "textarea[0.25,2;8,7.5;program;Program;${program}]\n"
|
fspec = fspec .. "textarea[0.25,2;8,7.5;program;Program;${program}]\n"
|
||||||
fspec = fspec .. "button_exit[0,8.5;7.9,1;;Done]\n"
|
fspec = fspec .. "button_exit[0,8.5;7.9,1;;Done]\n"
|
||||||
meta:set_string("formspec",fspec)
|
meta:set_string("formspec",fspec)
|
||||||
meta:set_string("channel","")
|
meta:set_string("channel","")
|
||||||
meta:set_string("program","#This is the default program.")
|
meta:set_string("state","running") -- can be "running", "waitingstack" or "waitingins"
|
||||||
meta:set_string("state","running") -- can be "running", or "waiting"
|
|
||||||
meta:set_string("waitingfor","") -- address waiting for
|
meta:set_string("waitingfor","") -- address waiting for
|
||||||
meta:set_int("pc",0)
|
meta:set_string("stack","") -- internal stack
|
||||||
meta:set_int("acc",0)
|
meta:set_int("ci",0) -- current instruction
|
||||||
meta:set_int("bak",0)
|
meta:set_int("pc",0) -- program counter
|
||||||
t21_set_infotext(pos)
|
t400_set_infotext(pos)
|
||||||
print("Initialized T21 at "..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z))
|
print("Initialized T400 at "..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z))
|
||||||
end
|
end
|
||||||
minetest.register_node("test3d:t21", {
|
minetest.register_node("test3d:t400", {
|
||||||
description = "T21 Execution Node",
|
description = "T400 Execution Node",
|
||||||
tiles = {
|
tiles = {
|
||||||
{
|
{
|
||||||
image="t21.png",
|
image="t400.png",
|
||||||
animation={
|
animation={
|
||||||
type = "vertical_frames",
|
type = "vertical_frames",
|
||||||
aspect_w=16,
|
aspect_w=16,
|
||||||
@ -89,7 +90,7 @@ minetest.register_node("test3d:t21", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_construct = t21_set_meta,
|
on_construct = t400_set_meta,
|
||||||
on_punch = function(pos, _, _, _)
|
on_punch = function(pos, _, _, _)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local cstate = meta:get_int("test3d_running")
|
local cstate = meta:get_int("test3d_running")
|
||||||
@ -106,7 +107,7 @@ minetest.register_node("test3d:t21", {
|
|||||||
digiline = {
|
digiline = {
|
||||||
receptor = {},
|
receptor = {},
|
||||||
effector = {
|
effector = {
|
||||||
action = t21_digiline_receive
|
action = t400_digiline_receive
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_receive_fields = function(pos,_,fields,sender)
|
on_receive_fields = function(pos,_,fields,sender)
|
||||||
@ -143,13 +144,13 @@ minetest.register_node("test3d:t21", {
|
|||||||
sProgram = sProgram:sub(1,-1)
|
sProgram = sProgram:sub(1,-1)
|
||||||
meta:set_string("program",sProgram)
|
meta:set_string("program",sProgram)
|
||||||
print("Program:\n"..sProgram)
|
print("Program:\n"..sProgram)
|
||||||
meta:set_int("pc",1)
|
meta:set_int("pc",0)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
print("T21 node registered")
|
print("T400 node registered")
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames={"test3d:t21"},
|
nodenames={"test3d:t400"},
|
||||||
interval=1,
|
interval=1,
|
||||||
chance=1,
|
chance=1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
@ -167,17 +168,17 @@ minetest.register_abm({
|
|||||||
local pc = meta:get_int("pc")
|
local pc = meta:get_int("pc")
|
||||||
local acc = meta:get_int("acc")
|
local acc = meta:get_int("acc")
|
||||||
local bak = meta:get_int("bak")
|
local bak = meta:get_int("bak")
|
||||||
print("Running T21 node with instance at position "..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z).." (PC: "..tostring(pc)..", ACC: "..tostring(acc)..", BAK: "..tostring(bak)..")")
|
print("Running T400 node with instance at position "..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z).." (PC: "..tostring(pc)..", ACC: "..tostring(acc)..", BAK: "..tostring(bak)..")")
|
||||||
local tProgram = string.split(meta:get_string("program"),"\n")
|
local tProgram = string.split(meta:get_string("program"),"\n")
|
||||||
local tLine = string.split(tProgram[pc]:upper())
|
local tLine = string.split(tProgram[pc]:upper())
|
||||||
if pc == #tProgram then pc = 0 end
|
if pc == #tProgram then pc = 0 end
|
||||||
meta:set_int("pc",pc+1)
|
meta:set_int("pc",pc+1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
t21_set_infotext(pos)
|
t400_set_infotext(pos)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
print("T21 ABMs registered")
|
print("T400 ABMs registered")
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
minetest.register_chatcommand("lua", { -- I'm a terrible person
|
minetest.register_chatcommand("lua", { -- I'm a terrible person
|
Before Width: | Height: | Size: 778 B After Width: | Height: | Size: 778 B |
Loading…
Reference in New Issue
Block a user