[mp-advtrains] Update to Git commit 74c8784 & remove patch:
https://github.com/orwell96/advtrains/tree/74c8784master
parent
5d4c99e558
commit
a43e66573f
|
@ -138,7 +138,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
* shields
|
||||
* technic_armor
|
||||
* wieldview
|
||||
* [advtrains][] ([LGPL][lic.lgpl2.1] / [CC BY-NC-SA][lic.ccbyncsa3.0]) -- version: [da884af Git][ver.advtrains] *2017-05-12* ([patched][patch.advtrains]) **UPDATE**
|
||||
* [advtrains][] ([LGPL][lic.lgpl2.1] / [CC BY-NC-SA][lic.ccbyncsa3.0]) -- version: [74c8784 Git][ver.advtrains] *2017-05-22*
|
||||
* [animalmaterials][animals_modpack] (part of animals_modpack) ([CC0][lic.cc0] / [CC BY-SA][lic.ccbysa3.0]) -- version: [0.1.3 (d952d27 Git)][ver.animalmaterials] *2014-09-10*
|
||||
* mp-animalmaterials/
|
||||
* animal_resources
|
||||
|
@ -435,7 +435,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
|
||||
[ver.3d_armor]: https://github.com/stujones11/minetest-3d_armor/tree/793c748
|
||||
[ver.adv_spawning]: https://github.com/sapier/adv_spawning/tree/ec41aa9
|
||||
[ver.advtrains]: https://github.com/orwell96/advtrains/tree/da884af
|
||||
[ver.advtrains]: https://github.com/orwell96/advtrains/tree/74c8784
|
||||
[ver.airtanks]: https://github.com/minetest-mods/airtanks/tree/fc01ffb
|
||||
[ver.animalmaterials]: https://github.com/sapier/animalmaterials/tree/d952d27
|
||||
[ver.animals_modpack]: https://github.com/sapier/animals_modpack/tree/b9d0172
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
default
|
||||
mesecons?
|
||||
digtron?
|
|
@ -0,0 +1,25 @@
|
|||
--digtron.lua
|
||||
--make tracks placeable by digtrons by overriding the place function.
|
||||
|
||||
local old_item_place = digtron.item_place_node
|
||||
|
||||
digtron.item_place_node = function(itemstack, placer, place_to, param2)
|
||||
if minetest.get_item_group(itemstack:get_name(), "advtrains_trackplacer")>0 then
|
||||
return advtrains.pcall(function()
|
||||
local def = minetest.registered_items[itemstack:get_name()]
|
||||
if not def then return itemstack, false end
|
||||
|
||||
local pointed_thing = {}
|
||||
pointed_thing.type = "node"
|
||||
pointed_thing.above = {x=place_to.x, y=place_to.y, z=place_to.z}
|
||||
pointed_thing.under = {x=place_to.x, y=place_to.y - 1, z=place_to.z}
|
||||
|
||||
--call the on_rightclick callback
|
||||
local success
|
||||
itemstack, success = def.on_place(itemstack, placer, pointed_thing)
|
||||
return itemstack, success
|
||||
end)
|
||||
else
|
||||
return old_item_place(itemstack, placer, place_to, param2)
|
||||
end
|
||||
end
|
|
@ -170,12 +170,6 @@ function advtrains.minAngleDiffRad(r1, r2)
|
|||
return try3
|
||||
end
|
||||
end
|
||||
function advtrains.dumppath(path)
|
||||
if not path then atprint("dumppath: no path(nil)") return end
|
||||
local min=advtrains.minN(path)
|
||||
local max=advtrains.maxN(path)
|
||||
for i=min, max do atprint("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end
|
||||
end
|
||||
|
||||
function advtrains.merge_tables(a, ...)
|
||||
local new={}
|
||||
|
|
|
@ -43,7 +43,8 @@ advtrains.modpath = minetest.get_modpath("advtrains")
|
|||
function advtrains.print_concat_table(a)
|
||||
local str=""
|
||||
local stra=""
|
||||
for i=1,10 do
|
||||
local t
|
||||
for i=1,20 do
|
||||
t=a[i]
|
||||
if t==nil then
|
||||
stra=stra.."nil "
|
||||
|
@ -70,23 +71,20 @@ function advtrains.print_concat_table(a)
|
|||
end
|
||||
return str
|
||||
end
|
||||
|
||||
atprint=function() end
|
||||
if minetest.setting_getbool("advtrains_debug") then
|
||||
atprint=function(t, ...)
|
||||
atlog=function(t, ...)
|
||||
local context=advtrains.atprint_context_tid
|
||||
if not context then context="" end
|
||||
--if context~="4527" then return end
|
||||
if not context then return end
|
||||
local text=advtrains.print_concat_table({t, ...})
|
||||
minetest.log("action", "[advtrains]"..context..">"..text)
|
||||
minetest.chat_send_all("[advtrains]"..context..">"..text)
|
||||
end
|
||||
minetest.log("action", text)
|
||||
end
|
||||
atwarn=function(t, ...)
|
||||
local text=advtrains.print_concat_table({t, ...})
|
||||
minetest.log("warning", "[advtrains]"..text)
|
||||
minetest.chat_send_all("[advtrains] -!- "..text)
|
||||
end
|
||||
sid=function(id) return string.sub(id, -4) end
|
||||
sid=function(id) return string.sub(id, -6) end
|
||||
|
||||
dofile(advtrains.modpath.."/helpers.lua");
|
||||
--dofile(advtrains.modpath.."/debugitems.lua");
|
||||
|
@ -106,6 +104,7 @@ advtrains.meseconrules =
|
|||
{x=0, y=-1, z=-1},
|
||||
{x=0, y=-2, z=0}}
|
||||
|
||||
|
||||
dofile(advtrains.modpath.."/trainlogic.lua")
|
||||
dofile(advtrains.modpath.."/trainhud.lua")
|
||||
dofile(advtrains.modpath.."/trackplacer.lua")
|
||||
|
@ -122,6 +121,9 @@ dofile(advtrains.modpath.."/misc_nodes.lua")
|
|||
dofile(advtrains.modpath.."/crafting.lua")
|
||||
dofile(advtrains.modpath.."/craft_items.lua")
|
||||
|
||||
if digtron then
|
||||
dofile(advtrains.modpath.."/digtron.lua")
|
||||
end
|
||||
|
||||
--load/save
|
||||
|
||||
|
@ -309,7 +311,7 @@ function advtrains.load()
|
|||
end
|
||||
init_load=true
|
||||
no_action=false
|
||||
atprint("[load_all]Loaded advtrains save files")
|
||||
atlog("[load_all]Loaded advtrains save files")
|
||||
end
|
||||
|
||||
--## MAIN SAVE ROUTINE ##
|
||||
|
@ -324,6 +326,6 @@ function advtrains.save()
|
|||
if atlatc then
|
||||
atlatc.save()
|
||||
end
|
||||
atprint("[save_all]Saved advtrains save files")
|
||||
atlog("[save_all]Saved advtrains save files")
|
||||
end
|
||||
minetest.register_on_shutdown(advtrains.save)
|
||||
|
|
|
@ -52,17 +52,14 @@ local function ndbset(x,y,z,v)
|
|||
end
|
||||
|
||||
|
||||
local path=minetest.get_worldpath().."/advtrains_ndb2"
|
||||
--load
|
||||
--nodeids get loaded by advtrains init.lua and passed here
|
||||
function ndb.load_data(data)
|
||||
ndb_nodeids = data and data.nodeids or {}
|
||||
end
|
||||
|
||||
local path=minetest.get_worldpath().."/advtrains_ndb2"
|
||||
|
||||
local file, err = io.open(path, "r")
|
||||
if not file then
|
||||
atprint("load ndb failed: ", err or "Unknown Error")
|
||||
atwarn("Couldn't load the node database: ", err or "Unknown Error")
|
||||
else
|
||||
local cnt=0
|
||||
local hst_z=file:read(2)
|
||||
|
@ -77,15 +74,16 @@ else
|
|||
hst_x=file:read(2)
|
||||
cid=file:read(2)
|
||||
end
|
||||
atprint("nodedb: read", cnt, "nodes.")
|
||||
atlog("nodedb: read", cnt, "nodes.")
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
||||
--save
|
||||
function ndb.save_data()
|
||||
local file, err = io.open(path, "w")
|
||||
if not file then
|
||||
atprint("save ndb failed: ", err or "Unknown Error")
|
||||
atwarn("Couldn't save the node database: ", err or "Unknown Error")
|
||||
else
|
||||
for y, ny in pairs(ndb_nodes) do
|
||||
for x, nx in pairs(ny) do
|
||||
|
@ -197,16 +195,8 @@ function advtrains.get_rail_info_at(pos, drives_on)
|
|||
return true, conn1, conn2, rely1, rely2, railheight
|
||||
end
|
||||
|
||||
ndb.run_lbm = function(pos, nodep)
|
||||
ndb.run_lbm = function(pos, node)
|
||||
return advtrains.pcall(function()
|
||||
local node=nodep
|
||||
if not node then
|
||||
node=minetest.get_node_or_nil(pos)
|
||||
if not node then
|
||||
--this is defintely not loaded
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local cid=ndbget(pos.x, pos.y, pos.z)
|
||||
if cid then
|
||||
--if in database, detect changes and apply.
|
||||
|
@ -214,12 +204,10 @@ ndb.run_lbm = function(pos, nodep)
|
|||
local param2 = l2b(cid)
|
||||
if not nodeid then
|
||||
--something went wrong
|
||||
atprint("nodedb: lbm nid not found", pos, "with nid", u14b(cid), "param2", param2, "cid is", cid)
|
||||
atwarn("Node Database corruption, couldn't determine node to set at", pos)
|
||||
ndb.update(pos, node)
|
||||
else
|
||||
if (nodeid~=node.name or param2~=node.param2) then
|
||||
local ori_ndef=minetest.registered_nodes[node.name]
|
||||
if ori_ndef and ori_ndef.groups.save_in_nodedb then --check if this node has been worldedited, and don't replace then
|
||||
atprint("nodedb: lbm replaced", pos, "with nodeid", nodeid, "param2", param2, "cid is", cid)
|
||||
minetest.swap_node(pos, {name=nodeid, param2 = param2})
|
||||
local ndef=minetest.registered_nodes[nodeid]
|
||||
|
@ -227,14 +215,11 @@ ndb.run_lbm = function(pos, nodep)
|
|||
ndef.on_updated_from_nodedb(pos, node)
|
||||
end
|
||||
return true
|
||||
else
|
||||
ndb.clear(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
--if not in database, take it.
|
||||
atprint("nodedb: ", pos, "not in database")
|
||||
atlog("Node Database:", pos, "was not found in the database, have you used worldedit?")
|
||||
ndb.update(pos, node)
|
||||
end
|
||||
return false
|
||||
|
@ -242,12 +227,13 @@ ndb.run_lbm = function(pos, nodep)
|
|||
end
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
minetest.register_lbm({
|
||||
name = "advtrains:nodedb_on_load_update",
|
||||
nodenames = {"group:save_in_nodedb"},
|
||||
run_at_every_load = true,
|
||||
run_on_every_load = true,
|
||||
action = ndb.run_lbm,
|
||||
interval=10,
|
||||
interval=30,
|
||||
chance=1,
|
||||
})
|
||||
|
||||
|
@ -258,8 +244,20 @@ ndb.restore_all = function()
|
|||
for y, ny in pairs(ndb_nodes) do
|
||||
for x, nx in pairs(ny) do
|
||||
for z, _ in pairs(nx) do
|
||||
if ndb.run_lbm({x=x, y=y, z=z}) then
|
||||
cnt=cnt+1
|
||||
local pos={x=x, y=y, z=z}
|
||||
local node=minetest.get_node_or_nil(pos)
|
||||
if node then
|
||||
local ori_ndef=minetest.registered_nodes[node.name]
|
||||
local ndbnode=ndb.get_node(pos)
|
||||
if ori_ndef and ori_ndef.groups.save_in_nodedb then --check if this node has been worldedited, and don't replace then
|
||||
if (ndbnode.name~=node.name or ndbnode.param2~=node.param2) then
|
||||
minetest.swap_node(pos, ndbnode)
|
||||
atwarn("Replaced",node.name,"@",pos,"with",ndbnode.name)
|
||||
end
|
||||
else
|
||||
ndb.clear(pos)
|
||||
atwarn("Found ghost node (former",ndbnode.name,") @",pos,"deleting")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -283,3 +281,22 @@ end
|
|||
|
||||
advtrains.ndb=ndb
|
||||
|
||||
local ptime=0
|
||||
|
||||
minetest.register_chatcommand("at_restore_ndb",
|
||||
{
|
||||
params = "", -- Short parameter description
|
||||
description = "Write node db back to map", -- Full description
|
||||
privs = {train_operator=true, worldedit=true}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
return advtrains.pcall(function()
|
||||
if not minetest.check_player_privs(name, {server=true}) and os.time() < ptime+30 then
|
||||
return false, "Please wait at least 30s from the previous execution of /at_restore_ndb!"
|
||||
end
|
||||
ndb.restore_all()
|
||||
ptime=os.time()
|
||||
return true
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# Whether to print debug information on advtrains to chat and debug.txt
|
||||
# Ob Debuginformationen in die Chatkonsole und debug.txt ausgegeben werden sollen
|
||||
advtrains_debug (Print advtrains debug messages) bool false
|
|
@ -27,7 +27,6 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
inventory_image="advtrains_retrosignal_inv.png",
|
||||
drop="advtrains:retrosignal_off",
|
||||
description=attrans("Lampless Signal (@1)", attrans(r..rotation)),
|
||||
on_rightclick=switchfunc,
|
||||
sunlight_propagates=true,
|
||||
groups = {
|
||||
cracky=3,
|
||||
|
@ -62,7 +61,6 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
inventory_image="advtrains_signal_inv.png",
|
||||
drop="advtrains:signal_off",
|
||||
description=attrans("Signal (@1)", attrans(r..rotation)),
|
||||
on_rightclick=switchfunc,
|
||||
groups = {
|
||||
cracky=3,
|
||||
not_blocking_trains=1,
|
||||
|
|
|
@ -185,19 +185,19 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
|
|||
description = dispname,
|
||||
inventory_image = imgprefix.."_placer.png",
|
||||
wield_image = imgprefix.."_placer.png",
|
||||
groups={},
|
||||
groups={advtrains_trackplacer=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return advtrains.pcall(function()
|
||||
local name = placer:get_player_name()
|
||||
if not name then
|
||||
return itemstack
|
||||
return itemstack, false
|
||||
end
|
||||
if pointed_thing.type=="node" then
|
||||
local pos=pointed_thing.above
|
||||
local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0})
|
||||
if advtrains.is_protected(pos,name) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return itemstack
|
||||
return itemstack, false
|
||||
end
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to
|
||||
and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then
|
||||
|
@ -207,7 +207,7 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
|
|||
end
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
return itemstack, true
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -154,7 +154,7 @@ ap.t_30deg_straightonly={
|
|||
},
|
||||
slopenodes={},
|
||||
rotation={"", "_30", "_45", "_60"},
|
||||
increativeinv={st},
|
||||
increativeinv={"st"},
|
||||
}
|
||||
ap.t_30deg_straightonly_noplacer={
|
||||
regstep=1,
|
||||
|
@ -179,7 +179,7 @@ ap.t_30deg_straightonly_noplacer={
|
|||
},
|
||||
slopenodes={},
|
||||
rotation={"", "_30", "_45", "_60"},
|
||||
increativeinv={st},
|
||||
increativeinv={"st"},
|
||||
}
|
||||
ap.t_45deg={
|
||||
regstep=2,
|
||||
|
@ -310,7 +310,7 @@ function advtrains.register_tracks(tracktype, def, preset)
|
|||
},
|
||||
mesecons=mesecontbl,
|
||||
luaautomation=luaautomation,
|
||||
drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"),
|
||||
drop = (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"),
|
||||
}
|
||||
end
|
||||
local function cycle_conns(conns, rotid)
|
||||
|
|
|
@ -193,6 +193,9 @@ function advtrains.train_step_a(id, train, dtime)
|
|||
train.path_dist[-1]=vector.distance(train.last_pos, train.last_pos_prev)
|
||||
train.path_extent_min=-1
|
||||
train.path_extent_max=0
|
||||
train.min_index_on_track=-1
|
||||
train.max_index_on_track=0
|
||||
|
||||
--[[
|
||||
Bugfix for trains randomly ignoring ATC rails:
|
||||
- Paths have been invalidated. 1 gets executed and ensures an initial path
|
||||
|
@ -355,7 +358,7 @@ function advtrains.train_step_a(id, train, dtime)
|
|||
local path_pregen_keep=20
|
||||
local offtrack_keep=4
|
||||
local gen_front_keep= path_pregen_keep
|
||||
local gen_back_keep= - train.trainlen - path_pregen_keep
|
||||
local gen_back_keep= math.floor(- train.trainlen - path_pregen_keep)
|
||||
|
||||
local delete_min=math.min(train.max_index_on_track - offtrack_keep, math.floor(train.index)+gen_back_keep)
|
||||
local delete_max=math.max(train.min_index_on_track + offtrack_keep, math.floor(train.index)+gen_front_keep)
|
||||
|
@ -482,11 +485,14 @@ function advtrains.pathpredict(id, train, regular)
|
|||
|
||||
local maxn=train.path_extent_max or 0
|
||||
while maxn < gen_front do--pregenerate
|
||||
local conway
|
||||
if train.max_index_on_track == maxn then
|
||||
atprint("maxn conway for ",maxn,train.path[maxn],maxn-1,train.path[maxn-1])
|
||||
local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on)
|
||||
conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on)
|
||||
end
|
||||
if conway then
|
||||
train.path[maxn+1]=conway
|
||||
train.max_index_on_track=maxn
|
||||
train.max_index_on_track=maxn+1
|
||||
else
|
||||
--do as if nothing has happened and preceed with path
|
||||
--but do not update max_index_on_track
|
||||
|
@ -500,11 +506,14 @@ function advtrains.pathpredict(id, train, regular)
|
|||
|
||||
local minn=train.path_extent_min or -1
|
||||
while minn > gen_back do
|
||||
local conway
|
||||
if train.min_index_on_track == minn then
|
||||
atprint("minn conway for ",minn,train.path[minn],minn+1,train.path[minn+1])
|
||||
local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on)
|
||||
conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on)
|
||||
end
|
||||
if conway then
|
||||
train.path[minn-1]=conway
|
||||
train.min_index_on_track=minn
|
||||
train.min_index_on_track=minn-1
|
||||
else
|
||||
--do as if nothing has happened and preceed with path
|
||||
--but do not update min_index_on_track
|
||||
|
|
|
@ -17,6 +17,10 @@ function r.fire_event(pos, evtdata)
|
|||
|
||||
|
||||
local arrowconn = railtbl.arrowconn
|
||||
if not arrowconn then
|
||||
atwarn("LuaAutomation ATC interface rail at",ph,": Incomplete Data! Please visit position and click 'Save'!")
|
||||
return
|
||||
end
|
||||
|
||||
--prepare ingame API for ATC. Regenerate each time since pos needs to be known
|
||||
--If no train, then return false.
|
||||
|
|
Loading…
Reference in New Issue