Add experimental liveries feature

Please do not use this in your train mods yet, this may be subject to
changes!
master
Gabriel Pérez-Cerezo 2019-12-01 12:08:28 +01:00
parent ca4d65050c
commit b71c72b4ab
1 changed files with 19 additions and 6 deletions

View File

@ -114,6 +114,12 @@ function wagon:set_id(wid)
minetest.after(0.2, function() self:reattach_all() end) 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 if self.custom_on_activate then
self:custom_on_activate() self:custom_on_activate()
end end
@ -172,17 +178,24 @@ function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direct
return return
end 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() local pc=puncher:get_player_control()
if not pc.sneak then 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.")) 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 return
end 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 if not self:destroy() then return end