Some workaround fixes for Linuxworks server
Trains no longer get deleted when there's no rail Fast item to create subway train
This commit is contained in:
parent
e4b3d293d2
commit
c5256fb3aa
|
@ -167,8 +167,7 @@ function advtrains.train_step_a(id, train, dtime)
|
|||
atprint("last_pos", advtrains.round_vector_floor_y(train.last_pos), "not loaded and not in ndb, waiting")
|
||||
return nil
|
||||
elseif node_ok==false then
|
||||
atwarn("Unable to restore train ",id,": No rail at train's position")
|
||||
advtrains.trains[id]=nil
|
||||
atprint("Unable to restore train ",id,": No rail at train's position")
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -186,8 +185,7 @@ function advtrains.train_step_a(id, train, dtime)
|
|||
atprint("last_pos_prev", advtrains.round_vector_floor_y(train.last_pos_prev), "not loaded and not in ndb, waiting")
|
||||
return nil
|
||||
elseif prevnode_ok==false then
|
||||
atwarn("Unable to restore train ",id,": No rail at train's position")
|
||||
advtrains.trains[id]=nil
|
||||
atprint("Unable to restore train ",id,": No rail at train's position")
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
@ -88,3 +88,52 @@ minetest.register_craft({
|
|||
{'default:steelblock', 'default:steelblock', 'default:steelblock'},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":advtrains:subway_train", {
|
||||
description = "Subway train, will drive forward when placed",
|
||||
inventory_image = "advtrains_subway_wagon_inv.png",
|
||||
wield_image = "advtrains_subway_wagon_inv.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return advtrains.pcall(function()
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local node=minetest.get_node_or_nil(pointed_thing.under)
|
||||
if not node then atprint("[advtrains]Ignore at placer position") return itemstack end
|
||||
local nodename=node.name
|
||||
if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then
|
||||
atprint("no track here, not placing.")
|
||||
return itemstack
|
||||
end
|
||||
if not minetest.check_player_privs(placer, {train_place = true }) and minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
|
||||
minetest.record_protection_violation(pointed_thing.under, placer:get_player_name())
|
||||
return
|
||||
end
|
||||
local conn1=advtrains.get_track_connections(node.name, node.param2)
|
||||
local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1))
|
||||
|
||||
for i=1,3 do
|
||||
local ob=minetest.add_entity(pointed_thing.under, "advtrains:"..sysname)
|
||||
if not ob then
|
||||
atprint("couldn't add_entity, aborting")
|
||||
end
|
||||
local le=ob:get_luaentity()
|
||||
|
||||
le.owner=placer:get_player_name()
|
||||
|
||||
local wagon_uid=le:init_new_instance(id, {})
|
||||
|
||||
advtrains.add_wagon_to_train(le, id)
|
||||
end
|
||||
advtrains.trains[id].velocity=2
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue