Last night's work
This commit is contained in:
parent
a260c4a33a
commit
1708e2d461
45 changed files with 1359 additions and 1347 deletions
39
mods/ITEMS/vox_fabric/fabric_patterns.lua
Normal file
39
mods/ITEMS/vox_fabric/fabric_patterns.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
-- Fabric Patterns Management
|
||||
|
||||
local modpath = minetest.get_modpath("vox_fabric")
|
||||
local patterns_file = modpath .. "/textures/patterns.json"
|
||||
local patterns = {}
|
||||
|
||||
-- Load predefined patterns
|
||||
local file = io.open(patterns_file, "r")
|
||||
if file then
|
||||
local content = file:read("*a")
|
||||
file:close()
|
||||
patterns = minetest.parse_json(content) or {}
|
||||
end
|
||||
|
||||
-- Register predefined patterns as Pattern Template items
|
||||
for _, pattern in ipairs(patterns.patterns or {}) do
|
||||
minetest.register_craftitem("vox_fabric:pattern_" .. pattern.id, {
|
||||
description = "Pattern: " .. (pattern.title or pattern.id),
|
||||
inventory_image = "patterns/" .. pattern.id .. ".png",
|
||||
groups = {pattern = 1},
|
||||
})
|
||||
end
|
||||
|
||||
-- Pattern Template Item
|
||||
minetest.register_craftitem("vox_fabric:pattern_template", {
|
||||
description = "Pattern Template",
|
||||
inventory_image = "pattern_template.png",
|
||||
groups = {template = 1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
-- Interaction with Pattern Template
|
||||
local meta = itemstack:get_meta()
|
||||
local pattern_id = meta:get_string("pattern_id")
|
||||
if pattern_id and pattern_id ~= "" then
|
||||
minetest.chat_send_player(user:get_player_name(), "Pattern ID: " .. pattern_id)
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "This template has no pattern.")
|
||||
end
|
||||
end,
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue