mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
added support to 2 colors
This commit is contained in:
parent
a12b583c43
commit
bcf2732e49
3 changed files with 62 additions and 30 deletions
|
@ -11,6 +11,7 @@ function airutils.get_staticdata(self) -- unloaded/unloads ... is now saved
|
||||||
stored_owner = self.owner,
|
stored_owner = self.owner,
|
||||||
stored_hp = self.hp_max,
|
stored_hp = self.hp_max,
|
||||||
stored_color = self._color,
|
stored_color = self._color,
|
||||||
|
stored_color_2 = self._color_2,
|
||||||
stored_power_lever = self._power_lever,
|
stored_power_lever = self._power_lever,
|
||||||
stored_driver_name = self.driver_name,
|
stored_driver_name = self.driver_name,
|
||||||
stored_last_accell = self._last_accell,
|
stored_last_accell = self._last_accell,
|
||||||
|
@ -31,6 +32,7 @@ function airutils.on_activate(self, staticdata, dtime_s)
|
||||||
self.owner = data.stored_owner
|
self.owner = data.stored_owner
|
||||||
self.hp_max = data.stored_hp
|
self.hp_max = data.stored_hp
|
||||||
self._color = data.stored_color
|
self._color = data.stored_color
|
||||||
|
self._color_2 = data.stored_color_2
|
||||||
self._power_lever = data.stored_power_lever
|
self._power_lever = data.stored_power_lever
|
||||||
self.driver_name = data.stored_driver_name
|
self.driver_name = data.stored_driver_name
|
||||||
self._last_accell = data.stored_last_accell
|
self._last_accell = data.stored_last_accell
|
||||||
|
@ -47,7 +49,7 @@ function airutils.on_activate(self, staticdata, dtime_s)
|
||||||
self._register_parts_method(self)
|
self._register_parts_method(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
airutils.param_paint(self, self._color)
|
airutils.param_paint(self, self._color, self._color_2)
|
||||||
|
|
||||||
self.object:set_armor_groups({immortal=1})
|
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
|
-- deal with painting or destroying
|
||||||
if itmstck then
|
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
|
if not self.driver and toolcaps and toolcaps.damage_groups
|
||||||
and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then
|
and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then
|
||||||
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
||||||
|
@ -591,29 +593,40 @@ function airutils.on_rightclick(self, clicker)
|
||||||
--=========================
|
--=========================
|
||||||
elseif not self.driver_name then
|
elseif not self.driver_name then
|
||||||
if self.owner == name or minetest.check_player_privs(clicker, {protection_bypass=true}) 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
|
local itmstck=clicker:get_wielded_item()
|
||||||
if clicker:get_player_control().sneak == true then
|
local item_name = ""
|
||||||
-- flight instructor mode
|
if itmstck then item_name = itmstck:get_name() end
|
||||||
self._instruction_mode = true
|
|
||||||
airutils.attach(self, clicker, true)
|
if itmstck then
|
||||||
else
|
if airutils.set_param_paint(self, clicker, itmstck, 2) == false then
|
||||||
-- no driver => clicker is new driver
|
|
||||||
self._instruction_mode = false
|
if clicker:get_player_control().aux1 == true then --lets see the inventory
|
||||||
airutils.attach(self, clicker)
|
airutils.show_vehicle_trunk_formspec(self, clicker, airutils.trunk_slots)
|
||||||
end
|
else
|
||||||
self._elevator_angle = 0
|
if is_under_water then return end
|
||||||
self._rudder_angle = 0
|
--remove pax to prevent bug
|
||||||
self._command_is_given = false
|
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
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> You aren't the owner of this machine."))
|
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> You aren't the owner of this machine."))
|
||||||
|
|
|
@ -360,15 +360,23 @@ function airutils.add_paintable_part(self, entity_ref)
|
||||||
table.insert(self._paintable_parts, entity_ref:get_luaentity())
|
table.insert(self._paintable_parts, entity_ref:get_luaentity())
|
||||||
end
|
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 = ""
|
local item_name = ""
|
||||||
if itmstck then item_name = itmstck:get_name() end
|
if itmstck then item_name = itmstck:get_name() end
|
||||||
|
|
||||||
if item_name == "automobiles_lib:painter" or item_name == "bike:painter" then
|
if item_name == "automobiles_lib:painter" or item_name == "bike:painter" then
|
||||||
--painting with bike painter
|
--painting with bike painter
|
||||||
local meta = itmstck:get_meta()
|
local meta = itmstck:get_meta()
|
||||||
local colstr = meta:get_string("paint_color")
|
local colour = meta:get_string("paint_color")
|
||||||
airutils.param_paint(self, colstr)
|
|
||||||
|
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
|
return true
|
||||||
else
|
else
|
||||||
--painting with dyes
|
--painting with dyes
|
||||||
|
@ -382,11 +390,16 @@ function airutils.set_param_paint(self, puncher, itmstck)
|
||||||
end]]--
|
end]]--
|
||||||
--lets paint!!!!
|
--lets paint!!!!
|
||||||
local color = (item_name:sub(indx+1)):gsub(":", "")
|
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(color ..' '.. dump(colstr))
|
||||||
--minetest.chat_send_all(dump(airutils.colors))
|
--minetest.chat_send_all(dump(airutils.colors))
|
||||||
if colstr then
|
if colstr then
|
||||||
airutils.param_paint(self, colstr)
|
airutils.param_paint(self, colstr, colstr_2)
|
||||||
itmstck:set_count(itmstck:get_count()-1)
|
itmstck:set_count(itmstck:get_count()-1)
|
||||||
if puncher ~= nil then puncher:set_wielded_item(itmstck) end
|
if puncher ~= nil then puncher:set_wielded_item(itmstck) end
|
||||||
return true
|
return true
|
||||||
|
@ -400,12 +413,14 @@ end
|
||||||
local function _paint(self, l_textures, colstr, paint_list, mask_associations)
|
local function _paint(self, l_textures, colstr, paint_list, mask_associations)
|
||||||
paint_list = paint_list or self._painting_texture
|
paint_list = paint_list or self._painting_texture
|
||||||
mask_associations = mask_associations or self._mask_painting_associations
|
mask_associations = mask_associations or self._mask_painting_associations
|
||||||
|
|
||||||
for _, texture in ipairs(l_textures) do
|
for _, texture in ipairs(l_textures) do
|
||||||
for i, texture_name in ipairs(paint_list) do --textures list
|
for i, texture_name in ipairs(paint_list) do --textures list
|
||||||
local indx = texture:find(texture_name)
|
local indx = texture:find(texture_name)
|
||||||
if indx then
|
if indx then
|
||||||
l_textures[_] = texture_name.."^[multiply:".. colstr --paint it normally
|
l_textures[_] = texture_name.."^[multiply:".. colstr --paint it normally
|
||||||
local mask_texture = mask_associations[texture_name] --check if it demands a maks too
|
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
|
if mask_texture then --so it then
|
||||||
l_textures[_] = "("..l_textures[_]..")^("..texture_name.."^[mask:"..mask_texture..")" --add the mask
|
l_textures[_] = "("..l_textures[_]..")^("..texture_name.."^[mask:"..mask_texture..")" --add the mask
|
||||||
end
|
end
|
||||||
|
@ -416,18 +431,22 @@ local function _paint(self, l_textures, colstr, paint_list, mask_associations)
|
||||||
end
|
end
|
||||||
|
|
||||||
--painting
|
--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 not self then return end
|
||||||
if colstr then
|
if colstr then
|
||||||
self._color = colstr
|
self._color = colstr
|
||||||
|
self._color_2 = colstr_2
|
||||||
local l_textures = self.initial_properties.textures
|
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) --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})
|
self.object:set_properties({textures=l_textures})
|
||||||
|
|
||||||
if self._paintable_parts then --paint individual parts
|
if self._paintable_parts then --paint individual parts
|
||||||
for i, part_entity in ipairs(self._paintable_parts) do
|
for i, part_entity in ipairs(self._paintable_parts) do
|
||||||
local p_textures = part_entity.initial_properties.textures
|
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, 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})
|
part_entity.object:set_properties({textures=p_textures})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
BIN
textures/airutils_painting_2.png
Executable file
BIN
textures/airutils_painting_2.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
Loading…
Add table
Reference in a new issue