mirror of
https://github.com/APercy/automobiles_pck
synced 2025-11-18 20:47:59 +01:00
added Bike painter support
This commit is contained in:
parent
670f038e81
commit
bc55c94470
@ -672,34 +672,7 @@ minetest.register_entity("automobiles_buggy:buggy", {
|
||||
return
|
||||
end
|
||||
|
||||
--painting
|
||||
local split = string.split(item_name, ":")
|
||||
local color, indx, _
|
||||
if split[1] then _,indx = split[1]:find('dye') end
|
||||
if indx then
|
||||
for clr,_ in pairs(automobiles_lib.colors) do
|
||||
local _,x = split[2]:find(clr)
|
||||
if x then color = clr end
|
||||
end
|
||||
else
|
||||
color = false
|
||||
end
|
||||
|
||||
if color then
|
||||
|
||||
--lets paint!!!!
|
||||
--local color = item_name:sub(indx+1)
|
||||
local colstr = automobiles_lib.colors[color]
|
||||
--minetest.chat_send_all(color ..' '.. dump(colstr))
|
||||
if colstr then
|
||||
automobiles_lib.paint(self, colstr)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
puncher:set_wielded_item(itmstck)
|
||||
end
|
||||
-- end painting
|
||||
|
||||
else -- deal damage
|
||||
|
||||
if automobiles_lib.set_paint(self, puncher, itmstck) == false then
|
||||
local is_admin = false
|
||||
is_admin = minetest.check_player_privs(puncher, {server=true})
|
||||
--minetest.chat_send_all('owner '.. self.owner ..' - name '.. name)
|
||||
|
||||
@ -699,34 +699,7 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
return
|
||||
end
|
||||
|
||||
--painting
|
||||
local split = string.split(item_name, ":")
|
||||
local color, indx, _
|
||||
if split[1] then _,indx = split[1]:find('dye') end
|
||||
if indx then
|
||||
for clr,_ in pairs(automobiles_lib.colors) do
|
||||
local _,x = split[2]:find(clr)
|
||||
if x then color = clr end
|
||||
end
|
||||
else
|
||||
color = false
|
||||
end
|
||||
|
||||
if color then
|
||||
|
||||
--lets paint!!!!
|
||||
--local color = item_name:sub(indx+1)
|
||||
local colstr = automobiles_lib.colors[color]
|
||||
--minetest.chat_send_all(color ..' '.. dump(colstr))
|
||||
if colstr then
|
||||
automobiles_lib.paint(self, colstr)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
puncher:set_wielded_item(itmstck)
|
||||
end
|
||||
-- end painting
|
||||
|
||||
else -- deal damage
|
||||
|
||||
if automobiles_lib.set_paint(self, puncher, itmstck) == false then
|
||||
local is_admin = false
|
||||
is_admin = minetest.check_player_privs(puncher, {server=true})
|
||||
--minetest.chat_send_all('owner '.. self.owner ..' - name '.. name)
|
||||
|
||||
@ -47,6 +47,42 @@ function automobiles_lib.minmax(v,m)
|
||||
return math.min(math.abs(v),m)*minekart.sign(v)
|
||||
end
|
||||
|
||||
function automobiles_lib.set_paint(self, puncher, itmstck)
|
||||
local item_name = ""
|
||||
if itmstck then item_name = itmstck:get_name() end
|
||||
|
||||
if item_name == "bike:painter" then
|
||||
--painting with bike painter
|
||||
local meta = itmstck:get_meta()
|
||||
local colstr = meta:get_string("paint_color")
|
||||
automobiles_lib.paint(self, colstr)
|
||||
return true
|
||||
else
|
||||
--painting with dyes
|
||||
local split = string.split(item_name, ":")
|
||||
local color, indx, _
|
||||
if split[1] then _,indx = split[1]:find('dye') end
|
||||
if indx then
|
||||
for clr,_ in pairs(automobiles_lib.colors) do
|
||||
local _,x = split[2]:find(clr)
|
||||
if x then color = clr end
|
||||
end
|
||||
--lets paint!!!!
|
||||
--local color = item_name:sub(indx+1)
|
||||
local colstr = automobiles_lib.colors[color]
|
||||
--minetest.chat_send_all(color ..' '.. dump(colstr))
|
||||
if colstr then
|
||||
automobiles_lib.paint(self, colstr)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
puncher:set_wielded_item(itmstck)
|
||||
return true
|
||||
end
|
||||
-- end painting
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--painting
|
||||
function automobiles_lib.paint(self, colstr)
|
||||
if colstr then
|
||||
|
||||
@ -645,34 +645,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
||||
return
|
||||
end
|
||||
|
||||
--painting
|
||||
local split = string.split(item_name, ":")
|
||||
local color, indx, _
|
||||
if split[1] then _,indx = split[1]:find('dye') end
|
||||
if indx then
|
||||
for clr,_ in pairs(automobiles_lib.colors) do
|
||||
local _,x = split[2]:find(clr)
|
||||
if x then color = clr end
|
||||
end
|
||||
else
|
||||
color = false
|
||||
end
|
||||
|
||||
if color then
|
||||
|
||||
--lets paint!!!!
|
||||
--local color = item_name:sub(indx+1)
|
||||
local colstr = automobiles_lib.colors[color]
|
||||
--minetest.chat_send_all(color ..' '.. dump(colstr))
|
||||
if colstr then
|
||||
automobiles_lib.paint(self, colstr)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
puncher:set_wielded_item(itmstck)
|
||||
end
|
||||
-- end painting
|
||||
|
||||
else -- deal damage
|
||||
|
||||
if automobiles_lib.set_paint(self, puncher, itmstck) == false then
|
||||
local is_admin = false
|
||||
is_admin = minetest.check_player_privs(puncher, {server=true})
|
||||
--minetest.chat_send_all('owner '.. self.owner ..' - name '.. name)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user