Compare commits
5 Commits
bdb04fa763
...
4bcdbf9340
Author | SHA1 | Date |
---|---|---|
Ilya Zhuravlev | 4bcdbf9340 | |
Ilya Zhuravlev | 2ba54495d0 | |
Ilya Zhuravlev | 8adff6ee99 | |
Ilya Zhuravlev | 4684781a44 | |
Ilya Zhuravlev | b7f5921ea3 |
25
crafts.lua
|
@ -14,18 +14,37 @@ minetest.register_craft({
|
||||||
{ 'default:stick','', 'default:stick' },
|
{ 'default:stick','', 'default:stick' },
|
||||||
}})
|
}})
|
||||||
|
|
||||||
minetest.register_craft({
|
--[[minetest.register_craft({
|
||||||
output = 'painting:palette 1',
|
output = 'painting:palette 1',
|
||||||
recipe = {
|
recipe = {
|
||||||
{ 'group:dye', 'group:dye', 'group:dye' },
|
{ 'group:dye', 'group:dye', 'group:dye' },
|
||||||
{ 'group:dye', '', 'group:dye' },
|
{ 'group:dye', '', 'group:dye' },
|
||||||
{ 'group:dye', 'group:dye', 'group:dye' },
|
{ 'group:dye', 'group:dye', 'group:dye' },
|
||||||
|
}})]]
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'painting:canvas_16 1',
|
||||||
|
recipe = {
|
||||||
|
{ '', '', '' },
|
||||||
|
{ '', '', '' },
|
||||||
|
{ 'default:paper', '', '' },
|
||||||
|
}})
|
||||||
|
|
||||||
|
--[[
|
||||||
|
--other sizes work bad =(
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'painting:canvas_32 1',
|
||||||
|
recipe = {
|
||||||
|
{ '', '', '' },
|
||||||
|
{ 'default:paper', 'default:paper', '' },
|
||||||
|
{ 'default:paper', 'default:paper', '' },
|
||||||
}})
|
}})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'painting:canvas 1',
|
output = 'painting:canvas_64 1',
|
||||||
recipe = {
|
recipe = {
|
||||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||||
}})
|
}})
|
||||||
|
]]
|
||||||
|
|
79
init.lua
|
@ -17,9 +17,11 @@ textures = {
|
||||||
white = "white.png", yellow = "yellow.png",
|
white = "white.png", yellow = "yellow.png",
|
||||||
orange = "orange.png", red = "red.png",
|
orange = "orange.png", red = "red.png",
|
||||||
violet = "violet.png", blue = "blue.png",
|
violet = "violet.png", blue = "blue.png",
|
||||||
green = "green.png", magenta = "pink.png",
|
green = "green.png", magenta = "magenta.png",
|
||||||
cyan = "cyan.png", lightgrey = "lightgrey.png",
|
cyan = "cyan.png", grey = "grey.png",
|
||||||
darkgrey = "darkgrey.png", black = "black.png"
|
darkgrey = "darkgrey.png", black = "black.png",
|
||||||
|
darkgreen = "darkgreen.png", brown="brown.png",
|
||||||
|
pink = "pink.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
thickness = 0.1
|
thickness = 0.1
|
||||||
|
@ -31,7 +33,7 @@ picbox = {
|
||||||
}
|
}
|
||||||
|
|
||||||
picnode = {
|
picnode = {
|
||||||
description = "pic",
|
description = "Picture",
|
||||||
tiles = { "white.png" },
|
tiles = { "white.png" },
|
||||||
inventory_image = "painted.png",
|
inventory_image = "painted.png",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
@ -72,7 +74,6 @@ picent = {
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local data = meta:get_string("painting:picturedata")
|
local data = meta:get_string("painting:picturedata")
|
||||||
data = minetest.deserialize(data)
|
data = minetest.deserialize(data)
|
||||||
|
|
||||||
if not data.grid then return end
|
if not data.grid then return end
|
||||||
self.object:set_properties({textures = { to_imagestring(data.grid, data.res) }})
|
self.object:set_properties({textures = { to_imagestring(data.grid, data.res) }})
|
||||||
end
|
end
|
||||||
|
@ -92,7 +93,7 @@ paintent = {
|
||||||
local name = puncher:get_wielded_item():get_name()
|
local name = puncher:get_wielded_item():get_name()
|
||||||
name = string.split(name, "_")[2]
|
name = string.split(name, "_")[2]
|
||||||
if not textures[name] then return end
|
if not textures[name] then return end
|
||||||
|
|
||||||
--get player eye level
|
--get player eye level
|
||||||
local ppos = puncher:getpos()
|
local ppos = puncher:getpos()
|
||||||
ppos = { x = ppos.x, y = ppos.y+(1.5 + 1/16), z = ppos.z }
|
ppos = { x = ppos.x, y = ppos.y+(1.5 + 1/16), z = ppos.z }
|
||||||
|
@ -119,6 +120,10 @@ paintent = {
|
||||||
|
|
||||||
self.grid[x][y]=colors[name]
|
self.grid[x][y]=colors[name]
|
||||||
self.object:set_properties({textures = { to_imagestring(self.grid, self.res) }})
|
self.object:set_properties({textures = { to_imagestring(self.grid, self.res) }})
|
||||||
|
|
||||||
|
local wielded = puncher:get_wielded_item()
|
||||||
|
wielded:add_wear(65535/256)
|
||||||
|
puncher:set_wielded_item(wielded)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
|
@ -137,22 +142,37 @@ paintent = {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- just pure magic
|
||||||
|
local walltoface = {-1, -1, 1, 3, 0, 2}
|
||||||
|
|
||||||
--paintedcanvas picture inventory item
|
--paintedcanvas picture inventory item
|
||||||
paintedcanvas = {
|
paintedcanvas = {
|
||||||
|
description = "Painted Canvas",
|
||||||
inventory_image = "painted.png",
|
inventory_image = "painted.png",
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
--place node
|
--place node
|
||||||
local placerpos = placer:getpos()
|
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local dir = sub(pos, placerpos)
|
|
||||||
local fd = minetest.dir_to_facedir(dir)
|
local under = pointed_thing.under
|
||||||
|
local above = pointed_thing.above
|
||||||
|
local dir = {
|
||||||
|
x = under.x - above.x,
|
||||||
|
y = under.y - above.y,
|
||||||
|
z = under.z - above.z
|
||||||
|
}
|
||||||
|
local wm = minetest.dir_to_wallmounted(dir)
|
||||||
|
|
||||||
|
local fd = walltoface[wm + 1]
|
||||||
|
if fd == -1 then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
minetest.env:add_node(pos, { name = "painting:pic",
|
minetest.env:add_node(pos, { name = "painting:pic",
|
||||||
param2 = fd,
|
param2 = fd,
|
||||||
paramtype2 = "none" })
|
paramtype2 = "none" })
|
||||||
|
|
||||||
--save metadata
|
--save metadata
|
||||||
local data = itemstack:get_metadata()
|
local data = itemstack:get_metadata()
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
@ -178,6 +198,7 @@ paintedcanvas = {
|
||||||
|
|
||||||
--canvas inventory item
|
--canvas inventory item
|
||||||
canvas = {
|
canvas = {
|
||||||
|
description = "Canvas",
|
||||||
inventory_image = "default_paper.png",
|
inventory_image = "default_paper.png",
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
}
|
}
|
||||||
|
@ -189,7 +210,7 @@ canvasbox = {
|
||||||
}
|
}
|
||||||
|
|
||||||
canvasnode = {
|
canvasnode = {
|
||||||
description = "canvas",
|
description = "Canvas",
|
||||||
tiles = { "white.png" },
|
tiles = { "white.png" },
|
||||||
inventory_image = "painted.png",
|
inventory_image = "painted.png",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
@ -238,7 +259,7 @@ easelbox = {
|
||||||
}
|
}
|
||||||
|
|
||||||
easel = {
|
easel = {
|
||||||
description = "easel",
|
description = "Easel",
|
||||||
tiles = { "default_wood.png" },
|
tiles = { "default_wood.png" },
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
@ -250,8 +271,8 @@ easel = {
|
||||||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2 },
|
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2 },
|
||||||
|
|
||||||
on_punch = function(pos, node, player)
|
on_punch = function(pos, node, player)
|
||||||
local wielded = player:get_wielded_item():get_name()
|
local wielded_raw = player:get_wielded_item():get_name()
|
||||||
wielded = string.split(wielded, "_")
|
wielded = string.split(wielded_raw, "_")
|
||||||
|
|
||||||
local name = wielded[1]
|
local name = wielded[1]
|
||||||
local res = tonumber(wielded[2])
|
local res = tonumber(wielded[2])
|
||||||
|
@ -267,7 +288,7 @@ easel = {
|
||||||
minetest.env:add_node(pos, { name = "painting:canvasnode",
|
minetest.env:add_node(pos, { name = "painting:canvasnode",
|
||||||
param2 = fd,
|
param2 = fd,
|
||||||
paramtype2 = "none" })
|
paramtype2 = "none" })
|
||||||
|
|
||||||
local dir = dirs[fd]
|
local dir = dirs[fd]
|
||||||
pos = { x = pos.x - 0.01 * dir.x, y = pos.y, z = pos.z - 0.01 * dir.z }
|
pos = { x = pos.x - 0.01 * dir.x, y = pos.y, z = pos.z - 0.01 * dir.z }
|
||||||
|
|
||||||
|
@ -279,7 +300,7 @@ easel = {
|
||||||
p.fd = fd
|
p.fd = fd
|
||||||
|
|
||||||
meta:set_int("has_canvas", 1)
|
meta:set_int("has_canvas", 1)
|
||||||
local itemstack = ItemStack("painting:canvas")
|
local itemstack = ItemStack(wielded_raw)
|
||||||
player:get_inventory():remove_item("main", itemstack)
|
player:get_inventory():remove_item("main", itemstack)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -296,6 +317,14 @@ easel = {
|
||||||
|
|
||||||
--brushes
|
--brushes
|
||||||
|
|
||||||
|
local function table_copy(t)
|
||||||
|
local t2 = {}
|
||||||
|
for k,v in pairs(t) do
|
||||||
|
t2[k] = v
|
||||||
|
end
|
||||||
|
return t2
|
||||||
|
end
|
||||||
|
|
||||||
brush = {
|
brush = {
|
||||||
description = "brush",
|
description = "brush",
|
||||||
inventory_image = "default_tool_steelaxe.png",
|
inventory_image = "default_tool_steelaxe.png",
|
||||||
|
@ -314,8 +343,8 @@ minetest.register_entity("painting:picent", picent)
|
||||||
minetest.register_node("painting:pic", picnode)
|
minetest.register_node("painting:pic", picnode)
|
||||||
|
|
||||||
minetest.register_craftitem("painting:canvas_16", canvas)
|
minetest.register_craftitem("painting:canvas_16", canvas)
|
||||||
minetest.register_craftitem("painting:canvas_32", canvas)
|
--minetest.register_craftitem("painting:canvas_32", canvas)
|
||||||
minetest.register_craftitem("painting:canvas_64", canvas)
|
--minetest.register_craftitem("painting:canvas_64", canvas)
|
||||||
|
|
||||||
minetest.register_craftitem("painting:paintedcanvas", paintedcanvas)
|
minetest.register_craftitem("painting:paintedcanvas", paintedcanvas)
|
||||||
minetest.register_entity("painting:paintent", paintent)
|
minetest.register_entity("painting:paintent", paintent)
|
||||||
|
@ -328,8 +357,18 @@ revcolors = {}
|
||||||
|
|
||||||
for color, _ in pairs(textures) do
|
for color, _ in pairs(textures) do
|
||||||
table.insert(revcolors, color)
|
table.insert(revcolors, color)
|
||||||
|
local brush_new = table_copy(brush)
|
||||||
minetest.register_tool("painting:brush_"..color, brush)
|
brush_new.description = color:gsub("^%l", string.upper).." brush"
|
||||||
|
brush_new.inventory_image = "painting_brush_"..color..".png"
|
||||||
|
minetest.register_tool("painting:brush_"..color, brush_new)
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "painting:brush_"..color,
|
||||||
|
recipe = {
|
||||||
|
{"dye:"..color},
|
||||||
|
{"default:stick"},
|
||||||
|
{"default:stick"}
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, color in ipairs(revcolors) do
|
for i, color in ipairs(revcolors) do
|
||||||
|
|
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 571 B |
After Width: | Height: | Size: 571 B |
After Width: | Height: | Size: 570 B |
After Width: | Height: | Size: 568 B |
After Width: | Height: | Size: 563 B |
After Width: | Height: | Size: 567 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 575 B |
After Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 571 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 128 B |