Compare commits
5 Commits
bdb04fa763
...
4bcdbf9340
Author | SHA1 | Date |
---|---|---|
Ilya Zhuravlev | 4bcdbf9340 | |
Ilya Zhuravlev | 2ba54495d0 | |
Ilya Zhuravlev | 8adff6ee99 | |
Ilya Zhuravlev | 4684781a44 | |
Ilya Zhuravlev | b7f5921ea3 |
23
crafts.lua
|
@ -14,18 +14,37 @@ minetest.register_craft({
|
|||
{ 'default:stick','', 'default:stick' },
|
||||
}})
|
||||
|
||||
minetest.register_craft({
|
||||
--[[minetest.register_craft({
|
||||
output = 'painting:palette 1',
|
||||
recipe = {
|
||||
{ '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({
|
||||
output = 'painting:canvas 1',
|
||||
output = 'painting:canvas_64 1',
|
||||
recipe = {
|
||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||
{ 'default:paper', 'default:paper', 'default:paper' },
|
||||
}})
|
||||
]]
|
||||
|
|
73
init.lua
|
@ -17,9 +17,11 @@ textures = {
|
|||
white = "white.png", yellow = "yellow.png",
|
||||
orange = "orange.png", red = "red.png",
|
||||
violet = "violet.png", blue = "blue.png",
|
||||
green = "green.png", magenta = "pink.png",
|
||||
cyan = "cyan.png", lightgrey = "lightgrey.png",
|
||||
darkgrey = "darkgrey.png", black = "black.png"
|
||||
green = "green.png", magenta = "magenta.png",
|
||||
cyan = "cyan.png", grey = "grey.png",
|
||||
darkgrey = "darkgrey.png", black = "black.png",
|
||||
darkgreen = "darkgreen.png", brown="brown.png",
|
||||
pink = "pink.png"
|
||||
}
|
||||
|
||||
thickness = 0.1
|
||||
|
@ -31,7 +33,7 @@ picbox = {
|
|||
}
|
||||
|
||||
picnode = {
|
||||
description = "pic",
|
||||
description = "Picture",
|
||||
tiles = { "white.png" },
|
||||
inventory_image = "painted.png",
|
||||
drawtype = "nodebox",
|
||||
|
@ -72,7 +74,6 @@ picent = {
|
|||
local meta = minetest.env:get_meta(pos)
|
||||
local data = meta:get_string("painting:picturedata")
|
||||
data = minetest.deserialize(data)
|
||||
|
||||
if not data.grid then return end
|
||||
self.object:set_properties({textures = { to_imagestring(data.grid, data.res) }})
|
||||
end
|
||||
|
@ -119,6 +120,10 @@ paintent = {
|
|||
|
||||
self.grid[x][y]=colors[name]
|
||||
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,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
|
@ -137,17 +142,32 @@ paintent = {
|
|||
end
|
||||
}
|
||||
|
||||
-- just pure magic
|
||||
local walltoface = {-1, -1, 1, 3, 0, 2}
|
||||
|
||||
--paintedcanvas picture inventory item
|
||||
paintedcanvas = {
|
||||
description = "Painted Canvas",
|
||||
inventory_image = "painted.png",
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--place node
|
||||
local placerpos = placer:getpos()
|
||||
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",
|
||||
param2 = fd,
|
||||
|
@ -178,6 +198,7 @@ paintedcanvas = {
|
|||
|
||||
--canvas inventory item
|
||||
canvas = {
|
||||
description = "Canvas",
|
||||
inventory_image = "default_paper.png",
|
||||
stack_max = 99,
|
||||
}
|
||||
|
@ -189,7 +210,7 @@ canvasbox = {
|
|||
}
|
||||
|
||||
canvasnode = {
|
||||
description = "canvas",
|
||||
description = "Canvas",
|
||||
tiles = { "white.png" },
|
||||
inventory_image = "painted.png",
|
||||
drawtype = "nodebox",
|
||||
|
@ -238,7 +259,7 @@ easelbox = {
|
|||
}
|
||||
|
||||
easel = {
|
||||
description = "easel",
|
||||
description = "Easel",
|
||||
tiles = { "default_wood.png" },
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
|
@ -250,8 +271,8 @@ easel = {
|
|||
groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 2 },
|
||||
|
||||
on_punch = function(pos, node, player)
|
||||
local wielded = player:get_wielded_item():get_name()
|
||||
wielded = string.split(wielded, "_")
|
||||
local wielded_raw = player:get_wielded_item():get_name()
|
||||
wielded = string.split(wielded_raw, "_")
|
||||
|
||||
local name = wielded[1]
|
||||
local res = tonumber(wielded[2])
|
||||
|
@ -279,7 +300,7 @@ easel = {
|
|||
p.fd = fd
|
||||
|
||||
meta:set_int("has_canvas", 1)
|
||||
local itemstack = ItemStack("painting:canvas")
|
||||
local itemstack = ItemStack(wielded_raw)
|
||||
player:get_inventory():remove_item("main", itemstack)
|
||||
end,
|
||||
|
||||
|
@ -296,6 +317,14 @@ easel = {
|
|||
|
||||
--brushes
|
||||
|
||||
local function table_copy(t)
|
||||
local t2 = {}
|
||||
for k,v in pairs(t) do
|
||||
t2[k] = v
|
||||
end
|
||||
return t2
|
||||
end
|
||||
|
||||
brush = {
|
||||
description = "brush",
|
||||
inventory_image = "default_tool_steelaxe.png",
|
||||
|
@ -314,8 +343,8 @@ minetest.register_entity("painting:picent", picent)
|
|||
minetest.register_node("painting:pic", picnode)
|
||||
|
||||
minetest.register_craftitem("painting:canvas_16", canvas)
|
||||
minetest.register_craftitem("painting:canvas_32", canvas)
|
||||
minetest.register_craftitem("painting:canvas_64", canvas)
|
||||
--minetest.register_craftitem("painting:canvas_32", canvas)
|
||||
--minetest.register_craftitem("painting:canvas_64", canvas)
|
||||
|
||||
minetest.register_craftitem("painting:paintedcanvas", paintedcanvas)
|
||||
minetest.register_entity("painting:paintent", paintent)
|
||||
|
@ -328,8 +357,18 @@ revcolors = {}
|
|||
|
||||
for color, _ in pairs(textures) do
|
||||
table.insert(revcolors, color)
|
||||
|
||||
minetest.register_tool("painting:brush_"..color, brush)
|
||||
local brush_new = table_copy(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
|
||||
|
||||
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 |