From b71c72b4ab4d50c8f3a3a6ccbe15427548e1d2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Sun, 1 Dec 2019 12:08:28 +0100 Subject: [PATCH] Add experimental liveries feature Please do not use this in your train mods yet, this may be subject to changes! --- advtrains/wagons.lua | 25 +++++++++++++++++++------ 1 file 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 + 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 self.custom_may_destroy then - if not self.custom_may_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) then - return - end - end - + if not self:destroy() then return end local inv = puncher:get_inventory()