diff options
author | W3RQ01 <w3.rq01@gmail.com> | 2023-03-17 19:37:04 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2023-03-17 20:29:31 +0100 |
commit | 11d3620086ab191cea0c0266c84980f4f479a981 (patch) | |
tree | fcd979273c2a4852e94a39df3b8787a312768991 | |
parent | 764be1bda4363c7dd1ad60df2e3df0d7f040ae9b (diff) | |
download | basic_trains-11d3620086ab191cea0c0266c84980f4f479a981.tar.gz basic_trains-11d3620086ab191cea0c0266c84980f4f479a981.tar.bz2 basic_trains-11d3620086ab191cea0c0266c84980f4f479a981.zip |
Japanese Train: Add Livery Feature
-rw-r--r-- | advtrains_train_japan/init.lua | 28 | ||||
-rw-r--r-- | advtrains_train_japan/textures/advtrains_engine_japan_livery.png | bin | 0 -> 13213 bytes | |||
-rw-r--r-- | advtrains_train_japan/textures/advtrains_wagon_japan_livery.png | bin | 0 -> 17772 bytes |
3 files changed, 28 insertions, 0 deletions
diff --git a/advtrains_train_japan/init.lua b/advtrains_train_japan/init.lua index 190197a..578e472 100644 --- a/advtrains_train_japan/init.lua +++ b/advtrains_train_japan/init.lua @@ -3,9 +3,33 @@ local S = attrans -- note: scharfenberg coupler is defined in advtrains core advtrains.register_coupler_type("train_japan_interwagon", attrans("Japanese Train Inter-Wagon Connection")) +local function set_livery(self, puncher, itemstack, data) + local meta = itemstack:get_meta() + local color = meta:get_string("paint_color") + if color and color:find("^#%x%x%x%x%x%x$") then + local alpha = tonumber(meta:get_string("alpha")) + if alpha == 0 then + data.livery = self.base_texture + else + data.livery = self.base_texture.."^("..self.base_livery.."^[colorize:"..color..":255)" + end + self:set_textures(data) + end +end + +local function set_textures(self, data) + if data.livery then + self.object:set_properties({textures={data.livery}}) + end +end + advtrains.register_wagon("engine_japan", { mesh="advtrains_engine_japan.b3d", textures = {"advtrains_engine_japan.png"}, + base_texture = "advtrains_engine_japan.png", + base_livery = "advtrains_engine_japan_livery.png", + set_textures = set_textures, + set_livery = set_livery, drives_on={default=true}, max_speed=20, seats = { @@ -79,6 +103,10 @@ advtrains.register_wagon("engine_japan", { advtrains.register_wagon("wagon_japan", { mesh="advtrains_wagon_japan.b3d", textures = {"advtrains_wagon_japan.png"}, + base_texture = "advtrains_wagon_japan.png", + base_livery = "advtrains_wagon_japan_livery.png", + set_textures = set_textures, + set_livery = set_livery, drives_on={default=true}, max_speed=20, seats = { diff --git a/advtrains_train_japan/textures/advtrains_engine_japan_livery.png b/advtrains_train_japan/textures/advtrains_engine_japan_livery.png Binary files differnew file mode 100644 index 0000000..d26e7e3 --- /dev/null +++ b/advtrains_train_japan/textures/advtrains_engine_japan_livery.png diff --git a/advtrains_train_japan/textures/advtrains_wagon_japan_livery.png b/advtrains_train_japan/textures/advtrains_wagon_japan_livery.png Binary files differnew file mode 100644 index 0000000..7e0963a --- /dev/null +++ b/advtrains_train_japan/textures/advtrains_wagon_japan_livery.png |