aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-12-01 12:08:28 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-12-01 12:08:28 +0100
commitb71c72b4ab4d50c8f3a3a6ccbe15427548e1d2ff (patch)
tree184aca3f96b14432db63a4d365c42c20bbfa87a7
parentca4d65050ccb6ac7f7a54c491250c632a50b6d23 (diff)
downloadadvtrains-b71c72b4ab4d50c8f3a3a6ccbe15427548e1d2ff.tar.gz
advtrains-b71c72b4ab4d50c8f3a3a6ccbe15427548e1d2ff.tar.bz2
advtrains-b71c72b4ab4d50c8f3a3a6ccbe15427548e1d2ff.zip
Add experimental liveries feature
Please do not use this in your train mods yet, this may be subject to changes!
-rw-r--r--advtrains/wagons.lua25
1 files changed, 19 insertions, 6 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 8ff1d7e..924762c 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -114,6 +114,12 @@ function wagon:set_id(wid)
minetest.after(0.2, function() self:reattach_all() end)
+
+
+ if self.set_textures then
+ self:set_textures(data)
+ end
+
if self.custom_on_activate then
self:custom_on_activate()
end
@@ -172,18 +178,25 @@ function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direct
return
end
- local pc=puncher:get_player_control()
- if not pc.sneak then
- minetest.chat_send_player(puncher:get_player_name(), attrans("Warning: If you destroy this wagon, you only get some steel back! If you are sure, hold Sneak and left-click the wagon."))
- return
- end
-
if self.custom_may_destroy then
if not self.custom_may_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) then
return
end
end
+ local itemstack = puncher:get_wielded_item()
+ -- WARNING: This part of the API is guaranteed to change! DO NOT USE!
+ if self.set_livery and itemstack:get_name() == "bike:painter" then
+ self:set_livery(puncher, itemstack, data)
+ return
+ end
+ local pc=puncher:get_player_control()
+ if not pc.sneak then
+ minetest.chat_send_player(puncher:get_player_name(), attrans("Warning: If you destroy this wagon, you only get some steel back! If you are sure, hold Sneak and left-click the wagon."))
+ return
+ end
+
+
if not self:destroy() then return end
local inv = puncher:get_inventory()