From 1f39842f3cdac4cf8e1ea1df0f51958af68b1d37 Mon Sep 17 00:00:00 2001 From: Mossmanikin Date: Fri, 20 Dec 2013 19:13:37 +0100 Subject: [PATCH] Write on paper 0.0.9 --- .gitattributes | 22 ++ .gitignore | 215 +++++++++++ memorandum/depends.txt | 1 + memorandum/init.lua | 351 ++++++++++++++++++ .../textures/alternates/memorandum_eraser.png | Bin 0 -> 469 bytes memorandum/textures/memorandum_eraser.png | Bin 0 -> 510 bytes .../textures/memorandum_letter_empty.png | Bin 0 -> 379 bytes .../textures/memorandum_letter_text.png | Bin 0 -> 214 bytes memorandum/textures/memorandum_letters.png | Bin 0 -> 235 bytes memorandum/textures/memorandum_message.png | Bin 0 -> 332 bytes modpack.txt | 0 11 files changed, 589 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 memorandum/depends.txt create mode 100644 memorandum/init.lua create mode 100644 memorandum/textures/alternates/memorandum_eraser.png create mode 100644 memorandum/textures/memorandum_eraser.png create mode 100644 memorandum/textures/memorandum_letter_empty.png create mode 100644 memorandum/textures/memorandum_letter_text.png create mode 100644 memorandum/textures/memorandum_letters.png create mode 100644 memorandum/textures/memorandum_message.png create mode 100644 modpack.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..412eeda --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9d6bd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,215 @@ +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist/ +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg diff --git a/memorandum/depends.txt b/memorandum/depends.txt new file mode 100644 index 0000000..331d858 --- /dev/null +++ b/memorandum/depends.txt @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/memorandum/init.lua b/memorandum/init.lua new file mode 100644 index 0000000..4d4900f --- /dev/null +++ b/memorandum/init.lua @@ -0,0 +1,351 @@ +----------------------------------------------------------------------------------------------- +local title = "Memorandum" +local version = "0.0.9" +local mname = "memorandum" +----------------------------------------------------------------------------------------------- +-- { left , bottom , front , right , top , back } +local sheet = { -1/2 , -1/2 , -1/2 , 1/2 , -7/16 , 1/2 } +local info = 'On this piece of paper is written: "' +local sign = '" Signed by ' + +minetest.register_craftitem(":default:paper", { + description = "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}) + itemstack:take_item() + return itemstack + end + end, +}) + +minetest.register_node("memorandum:letter_empty", { + drawtype = "nodebox", + tiles = {"memorandum_letter_empty.png"}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + node_box = {type = "fixed", fixed = sheet}, + 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", + stack_max = 1, + groups = {not_in_creative_inventory=1}, + on_use = function(itemstack, user, pointed_thing) + local player = user:get_player_name() + local text = itemstack:get_metadata() + local scnt = string.sub (text, -2, -1) + if scnt == "00" then + mssg = string.sub (text, 1, -3) + sgnd = "" + elseif tonumber(scnt) == nil then -- to support previous versions + mssg = string.sub (text, 37, -1) + sgnd = "" + else + mssg = string.sub (text, 1, -scnt -3) + sgnd = string.sub (text, -scnt-2, -3) + end + if scnt == "00" or tonumber(scnt) == nil then + minetest.chat_send_player(player, info..mssg..'" Unsigned', false) + else + minetest.chat_send_player(player, info..mssg..sign..sgnd, false) + end + 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 text = itemstack:get_metadata() + local scnt = string.sub (text, -2, -1) + if scnt == "00" then + mssg = string.sub (text, 1, -3) + sgnd = "" + elseif tonumber(scnt) == nil then -- to support previous versions + mssg = string.sub (text, 37, -1) + sgnd = "" + else + 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 scnt == "00" or tonumber(scnt) == nil then + meta:set_string("infotext", info..mssg..'" Unsigned') + else + meta:set_string("infotext", info..mssg..sign..sgnd) + end + meta:set_string("text", mssg) + meta:set_string("signed", sgnd) + itemstack:take_item() + return itemstack + end + end, +}) + +minetest.register_node("memorandum:letter_written", { + drawtype = "nodebox", + tiles = {"memorandum_letter_empty.png^memorandum_letter_text.png"}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + node_box = {type = "fixed", fixed = sheet}, + 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 +end + +minetest.register_tool("memorandum:eraser", { + description = "Eraser", + inventory_image = "memorandum_eraser.png", + wield_image = "memorandum_eraser.png^[transformR90",--^[transformFX", + wield_scale = {x = 0.5, y = 0.5, z = 1}, + on_use = function(itemstack, user, pointed_thing) + local pt = pointed_thing + if pt and pt.under then + local node = minetest.get_node(pt.under) + local meta = minetest.get_meta(pt.under) + local player = user:get_player_name() + local signer = meta:get_string("signed") + if string.find(node.name, "memorandum:letter_written") then + if signer == player or signer == "" then + meta:set_string( + "formspec", + "size[10,7]".. + "field[1,1;8.5,1;text; Edit Text;${text}]".. + "field[1,3;4.25,1;signed; Edit Signature;${signed}]".. + "button_exit[0.75,5;4.25,1;text,signed;Done]" + ) + if not minetest.setting_getbool("creative_mode") then + return eraser_wear(itemstack, user, pointed_thing, 30) + else + return {name="memorandum:eraser", count=1, wear=0, metadata=""} + end + end + end + end + end, +}) + +minetest.register_node("memorandum:message", { + description = "Message in a Bottle", + drawtype = "plantlike", + tiles = {"vessels_glass_bottle.png^memorandum_message.png"}, + inventory_image = "vessels_glass_bottle_inv.png^memorandum_message.png", + wield_image = "vessels_glass_bottle.png^memorandum_message.png", + paramtype = "light", + selection_box = { + type = "fixed", + fixed = {-1/4, -1/2, -1/4, 1/4, 4/10, 1/4} + }, + stack_max = 1, + groups = {vessel=1,dig_immediate=3,attached_node=1,not_in_creative_inventory=1}, + --sounds = default.node_sound_glass_defaults(), + on_use = function(itemstack, user, pointed_thing) + local pt = pointed_thing + if pt.under then + local there = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z} + local meta = minetest.get_meta(there) + local text = itemstack:get_metadata() + local scnt = string.sub (text, -2, -1) + if scnt == "00" then + mssg = string.sub (text, 1, -3) + sgnd = "" + elseif tonumber(scnt) == nil then -- to support previous versions + mssg = string.sub (text, 37, -1) + sgnd = "" + else + mssg = string.sub (text, 1, -scnt -3) + sgnd = string.sub (text, -scnt-2, -3) + end + if minetest.get_node(there).name == "air" then + minetest.add_node(there, {name="memorandum:letter_written", param2=math.random(0,3)}) + if scnt == "00" or tonumber(scnt) == nil then + meta:set_string("infotext", info..mssg..'" Unsigned') + else + meta:set_string("infotext", info..mssg..sign..sgnd) + end + meta:set_string("text", mssg) + meta:set_string("signed", sgnd) + itemstack:take_item() + user:get_inventory():add_item("main", {name="vessels:glass_bottle", count=1, wear=0, metadata=""}) + return itemstack + end + end + 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 meta = minetest.get_meta(there) + local text = itemstack:get_metadata() + local scnt = string.sub (text, -2, -1) + if scnt == "00" then + mssg = string.sub (text, 1, -3) + sgnd = "" + elseif tonumber(scnt) == nil then -- to support previous versions + mssg = string.sub (text, 37, -1) + sgnd = "" + else + mssg = string.sub (text, 1, -scnt -3) + sgnd = string.sub (text, -scnt-2, -3) + end + if minetest.get_node(there).name == "air" then + minetest.add_node(there, {name="memorandum:message"}) + meta:set_string("text", mssg) + meta:set_string("signed", sgnd) + itemstack:take_item() + return itemstack + 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() + if string.len(signed) < 10 then + signcount = "0"..string.len(signed) + end + if signed == '" Unsigned' then + signcount = "00" + end + digger:get_inventory():add_item("main", {name="memorandum:message", count=1, wear=0, metadata=text..signed..signcount}) + end + minetest.remove_node(pos) + end, +}) + +if minetest.get_modpath("farming") ~= nil then +minetest.register_craft({ + type = "shapeless", + output = "memorandum:eraser", + recipe = {"farming:bread"}, +}) +end +if minetest.get_modpath("candles") ~= nil then +minetest.register_craft({ + type = "shapeless", + output = "memorandum:eraser", + recipe = {"candles:wax"}, +}) +end +if minetest.get_modpath("bees") ~= nil then +minetest.register_craft({ + type = "shapeless", + output = "memorandum:eraser", + recipe = {"bees:honey_comb"}, +}) +end +if minetest.get_modpath("technic") ~= nil then +minetest.register_craft({ + type = "shapeless", + output = "memorandum:eraser", + recipe = {"technic:raw_latex"}, +}) +end + +--[[minetest.register_craft({ + type = "shapeless", + output = "default:paper", + recipe = {"memorandum:letter","memorandum:eraser"}, + replacements = { + {"memorandum:eraser", "memorandum:eraser"} + }, +})]] +----------------------------------------------------------------------------------------------- +print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...") +----------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/memorandum/textures/alternates/memorandum_eraser.png b/memorandum/textures/alternates/memorandum_eraser.png new file mode 100644 index 0000000000000000000000000000000000000000..4ec390e1b2ae6c89d60cd2bd58511e9e8c4b3690 GIT binary patch literal 469 zcmV;`0V@89P)N2bPDNB8 zb~7$DE-^7j^FlWO00B`+L_t(IPqmZXOTthbhQ0F-ESFLiMNkkd0zaot+gR%S+S$|0aLsxpaZYnYEJu*WJ|H6F_C$+yHO zcyZgWG|?fOt%1xy&uWn|3^dg%$l@VHAsQ?gJQYaId$?1QP6X4Q1gkHx>NL5Oiy@ym zKsFii3p(Zv`VZN6dt70#GpWHImdRIzR_7sRqbylSbHQg|w0LxM9=)zW8Z=l7Yj_7! zPohBJe1;=}*c!Zc56bcx=S%*Q`Tl}jjH9ZYlk^Le3P&5kje`F^tlhtbzZ!i42UFoa%brE!00000 LNkvXXu0mjf<4?g| literal 0 HcmV?d00001 diff --git a/memorandum/textures/memorandum_eraser.png b/memorandum/textures/memorandum_eraser.png new file mode 100644 index 0000000000000000000000000000000000000000..1b2508403ca293873752380fd7480289a379f6be GIT binary patch literal 510 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qRNAp5A0004PNklxGX&w`GXc zUIzpDo}3a&c>xuV({L_$e#Dm9s1^l?WdW^5ktBF9QYdm0wel4>_Lw+t5rE6mKnvhp zh(h4QprE^(YtZN9FF3@Q0N9fN;?biSZP>*wgk8+;w-89w@J{9|77|GMe5jt8YC0T=xy zIOSBF{U!R}`Ec`pVWS7ydd%NsZ+*2_)9YHmSie!S;Nz>C|0`Q96~zA>e#x}pm`lvI z<|FDp?^q=bW=;^_@Jl}Bz><}J6`1=b=Q@PuTApaQ|6@;q$aL{qJ973-65$m1qCwTATlk-&*$b z|36RL|GR%%{rm3whHbfn!oB9}4O6qH7dDEhsT}{ycxivb4|Re0Oi9)X_q-!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP*sqp zi(`m|e{zBZYlO3ciA{yHz3^F~nt{YC4=jW%Dl zYSgTe~DWM4f DFDXIB literal 0 HcmV?d00001 diff --git a/memorandum/textures/memorandum_letters.png b/memorandum/textures/memorandum_letters.png new file mode 100644 index 0000000000000000000000000000000000000000..fb255007c636834dd4bc6f408765829fd749b53a GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP*u98 zi(`m|e{zC^47ug%pKr1qz|UUJ?yXMHvze+VTtx Y7j_?LKXBw<0nkbYPgg&ebxsLQ0LFkwng9R* literal 0 HcmV?d00001 diff --git a/memorandum/textures/memorandum_message.png b/memorandum/textures/memorandum_message.png new file mode 100644 index 0000000000000000000000000000000000000000..8a821575019a6bfdb59836a62659e014bc18f75a GIT binary patch literal 332 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|KvlavT^vI!{F4(7F#Y@g|9nHw#+3)P*)Hv=|9s}Zv{?DS`8Q^L-M>=j zm%V3Oz#FDXIfs{5yubGDc6*tx%GsX=%<}hdn#p(kzrT0apZ|TlzSBL*M9(xxKTrE( zU%X@g+!SU9sRgtC%ip}~I?uepZ1Q@^Cr#&mo%-LZ+4VS=54Gw ai($EY>&2DTjxT`TVDNPHb6Mw<&;$S*9*PqH literal 0 HcmV?d00001 diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29