diff options
author | orwell96 <orwell@bleipb.de> | 2017-10-25 12:33:12 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2017-10-25 12:34:49 +0200 |
commit | c5256fb3aa64ef0b287c2e59460af92deaebdbe5 (patch) | |
tree | 3ffb5e8e513785c0a256bb1ee833ed577d95a38d | |
parent | e4b3d293d299cfe43b116ed3d3afd927b915329c (diff) | |
download | advtrains-c5256fb3aa64ef0b287c2e59460af92deaebdbe5.tar.gz advtrains-c5256fb3aa64ef0b287c2e59460af92deaebdbe5.tar.bz2 advtrains-c5256fb3aa64ef0b287c2e59460af92deaebdbe5.zip |
Some workaround fixes for Linuxworks server
Trains no longer get deleted when there's no rail
Fast item to create subway train
-rw-r--r-- | advtrains/trainlogic.lua | 6 | ||||
-rw-r--r-- | advtrains_train_subway/init.lua | 49 |
2 files changed, 51 insertions, 4 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 228c3a0..ea7ea60 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -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 diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua index 8864e92..5f48a3c 100644 --- a/advtrains_train_subway/init.lua +++ b/advtrains_train_subway/init.lua @@ -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, + }) |