From 02128d6ac2d7a94ea1955967f8b652e2ed2ce8c3 Mon Sep 17 00:00:00 2001 From: Mossmanikin Date: Thu, 26 Dec 2013 20:05:11 +0100 Subject: [PATCH] Write on Paper 0.1.0 Letters can be pinned to a wall. --- memorandum/init.lua | 155 ++++++++++++++++-- .../textures/not in use/memorandum_seal.png | Bin 0 -> 431 bytes modpack.txt | 5 + 3 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 memorandum/textures/not in use/memorandum_seal.png diff --git a/memorandum/init.lua b/memorandum/init.lua index 4d4900f..6723a72 100644 --- a/memorandum/init.lua +++ b/memorandum/init.lua @@ -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 diff --git a/memorandum/textures/not in use/memorandum_seal.png b/memorandum/textures/not in use/memorandum_seal.png new file mode 100644 index 0000000000000000000000000000000000000000..6c5208a95f3a9c9c70d865b1c5552cd15449f33e GIT binary patch literal 431 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|Kx5@RT^vI!{O3;o%f=KaaP&FnuVv@IcW!d=a;a+n=K-V^x$ir>{`Se( zT=}T9@;Nh$)85^Q+-!b+M^a+c)&u1c+dk;MXO*uoTH>pHYgMLV@tXKwfhxsDOI&Sl z?Ga-Y{HNu_bT#eXE~^K-%O-O;iJaW3Ct%cB(!g=mu*M+C>fVu!%RRi5CMqn6RhP1p zFl1>xY^+%ncS}{$+T!D-?l%27b5ai<+9sQSvVzgeK~y15zRf>0Df8WZCXP(C@5%;G zr6pvNjcrkfpQFQ~u#%3y1MAT_!^BmW?3es V%}LGr?}6dT;OXk;vd$@?2>>TIq}Kod literal 0 HcmV?d00001 diff --git a/modpack.txt b/modpack.txt index e69de29..fee68b7 100644 --- a/modpack.txt +++ b/modpack.txt @@ -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. \ No newline at end of file