From 5f377f7b6c3530635064aa5d7d11f034c6eece45 Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Sat, 12 Nov 2016 21:47:23 +0100 Subject: Depends on Mesecons --- depends.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends.txt b/depends.txt index 20aa884..aca967d 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,2 @@ default -mesecons? \ No newline at end of file +mesecons -- cgit v1.2.3 From 633d514f5b63d28d80a5c0981ee3e99b61899c41 Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Thu, 22 Dec 2016 12:02:44 +0100 Subject: Added stop and reverse rail --- textures/advtrains_dtrack_rail_stop.png | Bin 0 -> 2860 bytes textures/advtrains_dtrack_stop_placer.png | Bin 0 -> 280 bytes tracks.lua | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 textures/advtrains_dtrack_rail_stop.png create mode 100644 textures/advtrains_dtrack_stop_placer.png diff --git a/textures/advtrains_dtrack_rail_stop.png b/textures/advtrains_dtrack_rail_stop.png new file mode 100644 index 0000000..3cfd75f Binary files /dev/null and b/textures/advtrains_dtrack_rail_stop.png differ diff --git a/textures/advtrains_dtrack_stop_placer.png b/textures/advtrains_dtrack_stop_placer.png new file mode 100644 index 0000000..82622db Binary files /dev/null and b/textures/advtrains_dtrack_stop_placer.png differ diff --git a/tracks.lua b/tracks.lua index 99dbb27..0b7d125 100644 --- a/tracks.lua +++ b/tracks.lua @@ -584,6 +584,30 @@ for _,rot in ipairs({"", "_30", "_45", "_60"}) do minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot) end +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_stop", + texture_prefix="advtrains_dtrack_stop", + models_prefix="advtrains_dtrack", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail_stop.png", + description="Stop and reverse rail", + formats={}, + get_additional_definiton = function(def, preset, suffix, rotation) + return { + advtrains = { + on_train_enter=function(pos, train_id) + local train = advtrains.trains[train_id]; + local endsp = train.tarvelocity; + train.tarvelocity = 0; + train.velocity = 0; + minetest.after(10,function(t,sp) train.movedir = -train.movedir; t.tarvelocity=sp; end, train, endsp); + end + } + } + end +}, t_30deg_straightonly) + + if mesecon then advtrains.register_tracks("default", { nodename_prefix="advtrains:dtrack_detector_off", -- cgit v1.2.3 From 7a1c4990d9bc9e7eaed980425a628afb500d6d6e Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Thu, 22 Dec 2016 12:06:26 +0100 Subject: Revert "Depends on Mesecons" This reverts commit 5f377f7b6c3530635064aa5d7d11f034c6eece45. Master no longer has hard-dependency on mesecons. --- depends.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends.txt b/depends.txt index aca967d..20aa884 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,2 @@ default -mesecons +mesecons? \ No newline at end of file -- cgit v1.2.3 From b4b4936b15127b48f527eccdcee0a5de82a2a2fb Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Thu, 22 Dec 2016 12:54:02 +0100 Subject: Added mechanism to avoid double-detection --- tracks.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tracks.lua b/tracks.lua index 0b7d125..ffca506 100644 --- a/tracks.lua +++ b/tracks.lua @@ -600,7 +600,8 @@ advtrains.register_tracks("default", { local endsp = train.tarvelocity; train.tarvelocity = 0; train.velocity = 0; - minetest.after(10,function(t,sp) train.movedir = -train.movedir; t.tarvelocity=sp; end, train, endsp); + minetest.swap_node(pos, {name="advtrains:dtrack".."_"..suffix..rotation, param2=minetest.get_node(pos).param2}) + minetest.after(10,function(t,sp,pos) train.movedir = -train.movedir; t.tarvelocity=sp; minetest.swap_node(pos, {name="advtrains:dtrack_stop".."_"..suffix..rotation, param2=minetest.get_node(pos).param2}); end, train, endsp,pos); end } } -- cgit v1.2.3 From 176ee0627ebc397c60650fc5b059829788fe3cdc Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Thu, 29 Dec 2016 00:27:07 +0100 Subject: Added privilege to remove trains --- trainlogic.lua | 10 ++++++---- wagons.lua | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/trainlogic.lua b/trainlogic.lua index 5e3936f..94dcb69 100644 --- a/trainlogic.lua +++ b/trainlogic.lua @@ -325,10 +325,12 @@ function advtrains.train_step(id, train, dtime) if found_uids[w_id] then --print(w_id.." still loaded") elseif advtrains.wagon_save[w_id] then - --print(w_id.." not loaded, but save available") - --spawn a new and initialize it with the properties from wagon_save - local le=minetest.env:add_entity(ori_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() - le:init_from_wagon_save(w_id) + --print(w_id.." not loaded, but save available") + --spawn a new and initialize it with the properties from wagon_save + local le=minetest.add_entity(ori_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() + if le then -- Don't crash if traintype has been removed + le:init_from_wagon_save(w_id) + end else print(w_id.." not loaded and no save available") --what the hell... diff --git a/wagons.lua b/wagons.lua index ca31590..8a96c39 100644 --- a/wagons.lua +++ b/wagons.lua @@ -2,6 +2,15 @@ --local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end local print=function() end +minetest.register_privilege("train_place", { + description = "Player can place trains on tracks not owned by player", + give_to_singleplayer= false, +}); +minetest.register_privilege("train_remove", { + description = "Player can remove trains not owned by player", + give_to_singleplayer= false, +}); + local wagon={ collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, --physical = true, @@ -164,9 +173,9 @@ function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direct if not puncher or not puncher:is_player() then return end - if self.owner and puncher:get_player_name()~=self.owner then - minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it.") - return + if self.owner and puncher:get_player_name()~=self.owner and (not minetest.check_player_privs(puncher, {train_remove = true })) then + minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it."); + return end if minetest.setting_getbool("creative_mode") then @@ -534,7 +543,7 @@ function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img) return end - local node=minetest.env:get_node_or_nil(pointed_thing.under) + local node=minetest.get_node_or_nil(pointed_thing.under) if not node then print("[advtrains]Ignore at placer position") return itemstack end local nodename=node.name if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then @@ -544,7 +553,7 @@ function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img) 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), traintype) - local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) + local ob=minetest.add_entity(pointed_thing.under, "advtrains:"..sysname) if not ob then print("[advtrains]couldn't add_entity, aborting") end -- cgit v1.2.3 From 0030409dd34f611b90861a528d6735a44dd663f2 Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Wed, 18 Jan 2017 22:47:26 +0100 Subject: Revert "Added stop and reverse rail" This reverts commit 633d514f5b63d28d80a5c0981ee3e99b61899c41. Conflicts: tracks.lua --- textures/advtrains_dtrack_rail_stop.png | Bin 2860 -> 0 bytes textures/advtrains_dtrack_stop_placer.png | Bin 280 -> 0 bytes tracks.lua | 25 ------------------------- 3 files changed, 25 deletions(-) delete mode 100644 textures/advtrains_dtrack_rail_stop.png delete mode 100644 textures/advtrains_dtrack_stop_placer.png diff --git a/textures/advtrains_dtrack_rail_stop.png b/textures/advtrains_dtrack_rail_stop.png deleted file mode 100644 index 3cfd75f..0000000 Binary files a/textures/advtrains_dtrack_rail_stop.png and /dev/null differ diff --git a/textures/advtrains_dtrack_stop_placer.png b/textures/advtrains_dtrack_stop_placer.png deleted file mode 100644 index 82622db..0000000 Binary files a/textures/advtrains_dtrack_stop_placer.png and /dev/null differ diff --git a/tracks.lua b/tracks.lua index ffca506..99dbb27 100644 --- a/tracks.lua +++ b/tracks.lua @@ -584,31 +584,6 @@ for _,rot in ipairs({"", "_30", "_45", "_60"}) do minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot) end -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack_stop", - texture_prefix="advtrains_dtrack_stop", - models_prefix="advtrains_dtrack", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail_stop.png", - description="Stop and reverse rail", - formats={}, - get_additional_definiton = function(def, preset, suffix, rotation) - return { - advtrains = { - on_train_enter=function(pos, train_id) - local train = advtrains.trains[train_id]; - local endsp = train.tarvelocity; - train.tarvelocity = 0; - train.velocity = 0; - minetest.swap_node(pos, {name="advtrains:dtrack".."_"..suffix..rotation, param2=minetest.get_node(pos).param2}) - minetest.after(10,function(t,sp,pos) train.movedir = -train.movedir; t.tarvelocity=sp; minetest.swap_node(pos, {name="advtrains:dtrack_stop".."_"..suffix..rotation, param2=minetest.get_node(pos).param2}); end, train, endsp,pos); - end - } - } - end -}, t_30deg_straightonly) - - if mesecon then advtrains.register_tracks("default", { nodename_prefix="advtrains:dtrack_detector_off", -- cgit v1.2.3 From 647b3c8a4c80689fef41663fdad3619d006d38ac Mon Sep 17 00:00:00 2001 From: Gabriel Pérez-Cerezo Date: Wed, 18 Jan 2017 23:28:23 +0100 Subject: Removed last occurrence of minetest.env --- advtrains/advtrains/trainlogic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 5bedfec..d2c86a4 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -487,7 +487,7 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) if not wagon then if advtrains.wagon_save[w_id] then --spawn a new and initialize it with the properties from wagon_save - wagon=minetest.env:add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() + wagon=minetest.add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() if not wagon then minetest.chat_send_all("[advtrains] Warning: Wagon "..advtrains.wagon_save[w_id].entity_name.." does not exist. Make sure all required modules are loaded!") else -- cgit v1.2.3