add scraper to remove paint from items
parent
926bd4cec2
commit
c1d4dd5f5c
1
init.lua
1
init.lua
|
@ -15,7 +15,6 @@ mypaint.colors = {
|
||||||
pink = {"Pink", "FE2E9A"},
|
pink = {"Pink", "FE2E9A"},
|
||||||
violet = {"Violet", "7f007f"},
|
violet = {"Violet", "7f007f"},
|
||||||
yellow = {"Yellow", "ffff00"},
|
yellow = {"Yellow", "ffff00"},
|
||||||
clear = {"Clear", "000000:0"},
|
|
||||||
}
|
}
|
||||||
mypaint.paintables = {}
|
mypaint.paintables = {}
|
||||||
|
|
||||||
|
|
39
paint.lua
39
paint.lua
|
@ -28,8 +28,9 @@ function paint_node(pos, node, col, itemstack)
|
||||||
local s, e
|
local s, e
|
||||||
local nname = node.name
|
local nname = node.name
|
||||||
s, e = string.find(nname, "_[^_]+$")
|
s, e = string.find(nname, "_[^_]+$")
|
||||||
|
local color
|
||||||
if s and e then
|
if s and e then
|
||||||
local color = string.sub(nname, s + 1, e)
|
color = string.sub(nname, s + 1, e)
|
||||||
if mypaint.colors[color] then
|
if mypaint.colors[color] then
|
||||||
nname = string.sub(nname, 1, s - 1)
|
nname = string.sub(nname, 1, s - 1)
|
||||||
if color == col then
|
if color == col then
|
||||||
|
@ -40,8 +41,16 @@ function paint_node(pos, node, col, itemstack)
|
||||||
|
|
||||||
for name, colors in pairs(mypaint.paintables) do
|
for name, colors in pairs(mypaint.paintables) do
|
||||||
if (nname == name) then
|
if (nname == name) then
|
||||||
if colors[col] then
|
if not col then
|
||||||
minetest.set_node(pos,{name = name.."_"..col, param2 = node.param2})
|
if color then
|
||||||
|
minetest.set_node(pos, {name = name, param2 = node.param2})
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not colors[col] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.set_node(pos, {name = name.."_"..col, param2 = node.param2})
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
local wear = itemstack:get_wear() + 65535 / BRUSH_USES
|
local wear = itemstack:get_wear() + 65535 / BRUSH_USES
|
||||||
if wear < 65535 then
|
if wear < 65535 then
|
||||||
|
@ -49,11 +58,10 @@ function paint_node(pos, node, col, itemstack)
|
||||||
else
|
else
|
||||||
itemstack = ItemStack("mypaint:brush")
|
itemstack = ItemStack("mypaint:brush")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_tool("mypaint:brush", {
|
minetest.register_tool("mypaint:brush", {
|
||||||
|
@ -72,6 +80,19 @@ minetest.register_tool("mypaint:brush", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_tool("mypaint:scraper", {
|
||||||
|
description = "Paint Scraper",
|
||||||
|
inventory_image = "mypaint_scraper.png",
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
if pointed_thing.type ~= "node" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = pointed_thing.under
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
return paint_node(pos, node, nil, itemstack)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
for color, entry in pairs(mypaint.colors) do
|
for color, entry in pairs(mypaint.colors) do
|
||||||
local desc = entry[1]
|
local desc = entry[1]
|
||||||
local cstring = entry[2]
|
local cstring = entry[2]
|
||||||
|
@ -182,3 +203,11 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'mypaint:scraper',
|
||||||
|
recipe = {
|
||||||
|
{'default:steel_ingot', ''},
|
||||||
|
{'', 'group:stick'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue