From bcf2732e492ed87706dba6a44dd2318d048f1a19 Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 18 Jun 2023 13:59:31 -0300 Subject: [PATCH] added support to 2 colors --- lib_planes/entities.lua | 61 +++++++++++++++++++------------ lib_planes/utilities.lua | 31 +++++++++++++--- textures/airutils_painting_2.png | Bin 0 -> 5541 bytes 3 files changed, 62 insertions(+), 30 deletions(-) create mode 100755 textures/airutils_painting_2.png diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index edfd7eb..884cb35 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -11,6 +11,7 @@ function airutils.get_staticdata(self) -- unloaded/unloads ... is now saved stored_owner = self.owner, stored_hp = self.hp_max, stored_color = self._color, + stored_color_2 = self._color_2, stored_power_lever = self._power_lever, stored_driver_name = self.driver_name, stored_last_accell = self._last_accell, @@ -31,6 +32,7 @@ function airutils.on_activate(self, staticdata, dtime_s) self.owner = data.stored_owner self.hp_max = data.stored_hp self._color = data.stored_color + self._color_2 = data.stored_color_2 self._power_lever = data.stored_power_lever self.driver_name = data.stored_driver_name self._last_accell = data.stored_last_accell @@ -47,7 +49,7 @@ function airutils.on_activate(self, staticdata, dtime_s) self._register_parts_method(self) end - airutils.param_paint(self, self._color) + airutils.param_paint(self, self._color, self._color_2) self.object:set_armor_groups({immortal=1}) @@ -524,7 +526,7 @@ function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage) -- deal with painting or destroying if itmstck then - if airutils.set_param_paint(self, puncher, itmstck) == false then + if airutils.set_param_paint(self, puncher, itmstck, 1) == false then if not self.driver and toolcaps and toolcaps.damage_groups and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then --airutils.hurt(self,toolcaps.damage_groups.fleshy - 1) @@ -591,29 +593,40 @@ function airutils.on_rightclick(self, clicker) --========================= elseif not self.driver_name then if self.owner == name or minetest.check_player_privs(clicker, {protection_bypass=true}) then - if clicker:get_player_control().aux1 == true then --lets see the inventory - airutils.show_vehicle_trunk_formspec(self, clicker, airutils.trunk_slots) - else - if is_under_water then return end - --remove pax to prevent bug - if self._passenger then - local pax_obj = minetest.get_player_by_name(self._passenger) - airutils.dettach_pax(self, pax_obj) - end - --attach player - if clicker:get_player_control().sneak == true then - -- flight instructor mode - self._instruction_mode = true - airutils.attach(self, clicker, true) - else - -- no driver => clicker is new driver - self._instruction_mode = false - airutils.attach(self, clicker) - end - self._elevator_angle = 0 - self._rudder_angle = 0 - self._command_is_given = false + local itmstck=clicker:get_wielded_item() + local item_name = "" + if itmstck then item_name = itmstck:get_name() end + + if itmstck then + if airutils.set_param_paint(self, clicker, itmstck, 2) == false then + + if clicker:get_player_control().aux1 == true then --lets see the inventory + airutils.show_vehicle_trunk_formspec(self, clicker, airutils.trunk_slots) + else + if is_under_water then return end + --remove pax to prevent bug + if self._passenger then + local pax_obj = minetest.get_player_by_name(self._passenger) + airutils.dettach_pax(self, pax_obj) + end + + --attach player + if clicker:get_player_control().sneak == true then + -- flight instructor mode + self._instruction_mode = true + airutils.attach(self, clicker, true) + else + -- no driver => clicker is new driver + self._instruction_mode = false + airutils.attach(self, clicker) + end + self._elevator_angle = 0 + self._rudder_angle = 0 + self._command_is_given = false + end + + end end else minetest.chat_send_player(name, core.colorize('#ff0000', " >>> You aren't the owner of this machine.")) diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index 57f861c..e3aac00 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -360,15 +360,23 @@ function airutils.add_paintable_part(self, entity_ref) table.insert(self._paintable_parts, entity_ref:get_luaentity()) end -function airutils.set_param_paint(self, puncher, itmstck) +function airutils.set_param_paint(self, puncher, itmstck, mode) + mode = mode or 1 local item_name = "" if itmstck then item_name = itmstck:get_name() end if item_name == "automobiles_lib:painter" or item_name == "bike:painter" then --painting with bike painter local meta = itmstck:get_meta() - local colstr = meta:get_string("paint_color") - airutils.param_paint(self, colstr) + local colour = meta:get_string("paint_color") + + local colstr = self._color + local colstr_2 = self._color_2 + + if mode == 1 then colstr = colour end + if mode == 2 then colstr_2 = colour end + + airutils.param_paint(self, colstr, colstr_2) return true else --painting with dyes @@ -382,11 +390,16 @@ function airutils.set_param_paint(self, puncher, itmstck) end]]-- --lets paint!!!! local color = (item_name:sub(indx+1)):gsub(":", "") - local colstr = airutils.colors[color] + + local colstr = self._color + local colstr_2 = self._color_2 + if mode == 1 then colstr = airutils.colors[color] end + if mode == 2 then colstr_2 = airutils.colors[color] end + --minetest.chat_send_all(color ..' '.. dump(colstr)) --minetest.chat_send_all(dump(airutils.colors)) if colstr then - airutils.param_paint(self, colstr) + airutils.param_paint(self, colstr, colstr_2) itmstck:set_count(itmstck:get_count()-1) if puncher ~= nil then puncher:set_wielded_item(itmstck) end return true @@ -400,12 +413,14 @@ end local function _paint(self, l_textures, colstr, paint_list, mask_associations) paint_list = paint_list or self._painting_texture mask_associations = mask_associations or self._mask_painting_associations + for _, texture in ipairs(l_textures) do for i, texture_name in ipairs(paint_list) do --textures list local indx = texture:find(texture_name) if indx then l_textures[_] = texture_name.."^[multiply:".. colstr --paint it normally local mask_texture = mask_associations[texture_name] --check if it demands a maks too + --minetest.chat_send_all(texture_name .. " -> " .. dump(mask_texture)) if mask_texture then --so it then l_textures[_] = "("..l_textures[_]..")^("..texture_name.."^[mask:"..mask_texture..")" --add the mask end @@ -416,18 +431,22 @@ local function _paint(self, l_textures, colstr, paint_list, mask_associations) end --painting -function airutils.param_paint(self, colstr) +function airutils.param_paint(self, colstr, colstr_2) + colstr_2 = colstr_2 or colstr if not self then return end if colstr then self._color = colstr + self._color_2 = colstr_2 local l_textures = self.initial_properties.textures l_textures = _paint(self, l_textures, colstr) --paint the main plane + l_textures = _paint(self, l_textures, colstr_2, self._painting_texture_2) --paint the main plane self.object:set_properties({textures=l_textures}) if self._paintable_parts then --paint individual parts for i, part_entity in ipairs(self._paintable_parts) do local p_textures = part_entity.initial_properties.textures p_textures = _paint(part_entity, p_textures, colstr, self._painting_texture, self._mask_painting_associations) + p_textures = _paint(part_entity, p_textures, colstr_2, self._painting_texture_2, self._mask_painting_associations) part_entity.object:set_properties({textures=p_textures}) end end diff --git a/textures/airutils_painting_2.png b/textures/airutils_painting_2.png new file mode 100755 index 0000000000000000000000000000000000000000..0c02eafcf1636ea2eece0fb5cff784f3cde1f70a GIT binary patch literal 5541 zcmeHKdss|s7avDzN+E}?s%gq)_~t%S&D4}`YRaUh%M_wLGrMV;=3*|*6e8k;E=q`^ zP%f!Bha92sNf%{`k`I*#hhlOqm+0Fw?$3Ar@jT!8&pgkbz4v<8`mMEo@7n8q-wnY* zekMj%Mlcx6gzoRdgzl5H7hE6uw|g-Pz+ie;lEWh9OhAc{NX4=I1P~!ll7I+M#gB!- zR5vSFi*oPHG9LMB%5pu&o`yRBa!6k`!bmuWsTQy~%1hBs+dKpEP}PApXFq8Au`BX3 zSe@%0ZW*?+D@eGT;n{KhKq2qykXx&DjlNxCl^t%rK1C;p;ok^&}aY z@tUc6MYybT;avAyu$yxZwC9|je9B}Xg#pIgy|DR;%dy|h1BkU;LZumx5CZIVGIZ_( z*6&c)34#sbb9crTmn#WH)zz|>_g{!lkU{CCx!wQHci59noBSM}bn`NJ*5=L1_r;1E zO@^m$0I$b}oN;*ZYsfwuufT}q;@^k+3d<8t*e)NEg$m~U1^>0Vv9r3R5B{2(aUscZ zS_m)Ne%F4vukX|@N3SQ3g0@+K{qn-=0aGWT?WRe<%9xe^L7wzqe4dobpSF=|&~|%% z8f^A)cFcp!b?TFkj9DnJ;Y{2XLp6NP(4O7SqkpL={VO|+bFy4n=PvFu8pFXktMkWs z9c(RJ6QbCkpSZWE$g_ORTFrb}o&GV*_Dy#mc5btD%kEdYl-HIOcoj_8jI2w9dFva; zEvV0#X_G(J^tr|P1^Ut{2y^DvMv7=|Q>Vp5Y4Eu8OmeEa`tfVRzU6D+yfcQy`mYTC zC|7J=a5Tiz`-UZNm#k-;d9?I~wa4t1cfEer>hpTmi=W!3Suh)~_*h53#MfDbwrtoE z64#E|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