Write on Paper 0.1.0
Letters can be pinned to a wall.
This commit is contained in:
parent
1f39842f3c
commit
02128d6ac2
@ -1,6 +1,6 @@
|
||||
-----------------------------------------------------------------------------------------------
|
||||
local title = "Memorandum"
|
||||
local version = "0.0.9"
|
||||
local version = "0.1.0"
|
||||
local mname = "memorandum"
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- { left , bottom , front , right , top , back }
|
||||
@ -13,10 +13,18 @@ minetest.register_craftitem(":default:paper", {
|
||||
inventory_image = "default_paper.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pt = pointed_thing
|
||||
local direction = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local there = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
|
||||
if minetest.get_node(there).name == "air" then
|
||||
minetest.add_node(there, {name="memorandum:letter_empty", param2=direction})
|
||||
local walldir = minetest.dir_to_wallmounted(placer:get_look_dir())
|
||||
local floordir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local below = {x=pt.above.x, y=pt.above.y-1, z=pt.above.z}
|
||||
local node_under = minetest.get_node(pt.under)
|
||||
local node_below = minetest.get_node(below)
|
||||
if minetest.get_node(pt.above).name=="air"
|
||||
and not minetest.registered_nodes[node_under.name].buildable_to then
|
||||
if not minetest.registered_nodes[node_below.name].buildable_to then
|
||||
minetest.add_node(pt.above, {name="memorandum:letter_empty", param2=floordir})
|
||||
else
|
||||
minetest.add_node(pt.above, {name="memorandum:letter_empty_2", param2=walldir})
|
||||
end
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
@ -25,7 +33,10 @@ minetest.register_craftitem(":default:paper", {
|
||||
|
||||
minetest.register_node("memorandum:letter_empty", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"memorandum_letter_empty.png"},
|
||||
tiles = {
|
||||
"memorandum_letter_empty.png",
|
||||
"memorandum_letter_empty.png^[transformFY" -- mirror
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
@ -70,6 +81,56 @@ minetest.register_node("memorandum:letter_empty", {
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("memorandum:letter_empty_2", {
|
||||
drawtype = "signlike",
|
||||
tiles = {
|
||||
"memorandum_letter_empty.png",
|
||||
"memorandum_letter_empty.png^[transformFY" -- mirror
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
selection_box = { type = "wallmounted"},
|
||||
groups = {snappy=3,dig_immediate=3,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string(
|
||||
"formspec",
|
||||
"size[10,7]"..
|
||||
"field[1,1;8.5,1;text; Write a Letter;${text}]"..
|
||||
"field[1,3;4.25,1;signed; Sign Letter (optional);${signed}]"..
|
||||
"button_exit[0.75,5;4.25,1;text,signed;Done]"
|
||||
)
|
||||
meta:set_string("infotext", info..'"')
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
fields.text = fields.text
|
||||
fields.signed = fields.signed
|
||||
--[[print((sender:get_player_name() or "").." wrote \""..fields.text..
|
||||
"\" to paper at "..minetest.pos_to_string(pos))]]
|
||||
local direction = minetest.env:get_node(pos).param2
|
||||
if fields.text ~= "" then
|
||||
minetest.add_node(pos, {name="memorandum:letter_written", param2=direction})
|
||||
end
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("signed", "")
|
||||
meta:set_string("infotext", info..fields.text..'" Unsigned')
|
||||
if fields.signed ~= "" then
|
||||
meta:set_string("signed", fields.signed)
|
||||
meta:set_string("infotext", info..fields.text..sign..fields.signed)
|
||||
end
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
if digger:is_player() and digger:get_inventory() then
|
||||
digger:get_inventory():add_item("main", {name="default:paper", count=1, wear=0, metadata=""})
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("memorandum:letter", {
|
||||
description = "Letter",
|
||||
inventory_image = "default_paper.png^memorandum_letters.png",
|
||||
@ -97,9 +158,12 @@ minetest.register_craftitem("memorandum:letter", {
|
||||
end,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pt = pointed_thing
|
||||
local there = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
|
||||
local direction = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local meta = minetest.get_meta(there)
|
||||
local walldir = minetest.dir_to_wallmounted(placer:get_look_dir())
|
||||
local floordir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local below = {x=pt.above.x, y=pt.above.y-1, z=pt.above.z}
|
||||
local node_under = minetest.get_node(pt.under)
|
||||
local node_below = minetest.get_node(below)
|
||||
local meta = minetest.get_meta(pt.above)
|
||||
local text = itemstack:get_metadata()
|
||||
local scnt = string.sub (text, -2, -1)
|
||||
if scnt == "00" then
|
||||
@ -112,8 +176,13 @@ minetest.register_craftitem("memorandum:letter", {
|
||||
mssg = string.sub (text, 1, -scnt -3)
|
||||
sgnd = string.sub (text, -scnt-2, -3)
|
||||
end
|
||||
if minetest.env:get_node(there).name == "air" then
|
||||
minetest.add_node(there, {name="memorandum:letter_written", param2=direction})
|
||||
if minetest.get_node(pt.above).name == "air"
|
||||
and not minetest.registered_nodes[node_under.name].buildable_to then
|
||||
if not minetest.registered_nodes[node_below.name].buildable_to then
|
||||
minetest.add_node(pt.above, {name="memorandum:letter_written", param2=floordir})
|
||||
else
|
||||
minetest.add_node(pt.above, {name="memorandum:letter_written_2", param2=walldir})
|
||||
end
|
||||
if scnt == "00" or tonumber(scnt) == nil then
|
||||
meta:set_string("infotext", info..mssg..'" Unsigned')
|
||||
else
|
||||
@ -129,7 +198,10 @@ minetest.register_craftitem("memorandum:letter", {
|
||||
|
||||
minetest.register_node("memorandum:letter_written", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"memorandum_letter_empty.png^memorandum_letter_text.png"},
|
||||
tiles = {
|
||||
"memorandum_letter_empty.png^memorandum_letter_text.png",
|
||||
"memorandum_letter_empty.png^[transformFY" -- mirror
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
@ -183,6 +255,65 @@ minetest.register_node("memorandum:letter_written", {
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("memorandum:letter_written_2", {
|
||||
drawtype = "signlike",
|
||||
tiles = {
|
||||
"memorandum_letter_empty.png^memorandum_letter_text.png",
|
||||
"memorandum_letter_empty.png^[transformFY" -- mirror
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
selection_box = { type = "wallmounted"},
|
||||
groups = {snappy=3,dig_immediate=3,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local item = sender:get_wielded_item()
|
||||
if item:get_name() == "memorandum:eraser" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
fields.text = fields.text
|
||||
fields.signed = fields.signed
|
||||
--[[print((sender:get_player_name() or "").." wrote \""..fields.text..
|
||||
"\" to paper at "..minetest.pos_to_string(pos))]]
|
||||
local direction = minetest.env:get_node(pos).param2
|
||||
if fields.text == "" then
|
||||
minetest.add_node(pos, {name="memorandum:letter_empty", param2=direction})
|
||||
end
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("signed", "")
|
||||
meta:set_string("infotext", info..fields.text..'" Unsigned')
|
||||
if fields.signed ~= "" then
|
||||
meta:set_string("signed", fields.signed)
|
||||
meta:set_string("infotext", info..fields.text..sign..fields.signed)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
if digger:is_player() and digger:get_inventory() then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local text = meta:get_string("text")
|
||||
local signed = meta:get_string("signed")
|
||||
local signcount = string.len(signed)
|
||||
local item = digger:get_wielded_item()
|
||||
local inv = digger:get_inventory()
|
||||
if string.len(signed) < 10 then
|
||||
signcount = "0"..string.len(signed)
|
||||
end
|
||||
if signed == '" Unsigned' then
|
||||
signcount = "00"
|
||||
end
|
||||
if item:get_name() == "vessels:glass_bottle" then
|
||||
inv:remove_item("main", "vessels:glass_bottle")
|
||||
inv:add_item("main", {name="memorandum:message", count=1, wear=0, metadata=text..signed..signcount})
|
||||
else
|
||||
inv:add_item("main", {name="memorandum:letter", count=1, wear=0, metadata=text..signed..signcount})
|
||||
end
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
local function eraser_wear(itemstack, user, pointed_thing, uses)
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
return itemstack
|
||||
|
BIN
memorandum/textures/not in use/memorandum_seal.png
Normal file
BIN
memorandum/textures/not in use/memorandum_seal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 431 B |
@ -0,0 +1,5 @@
|
||||
The presence of this file indicates that the current folder is a modpack.
|
||||
|
||||
|
||||
You don't have to rename this folder.
|
||||
But you can rename it as long as none of the subfolders (or any other mods you use) have the chosen name and you don't use illegal characters.
|
Loading…
Reference in New Issue
Block a user