commit 1f39842f3cdac4cf8e1ea1df0f51958af68b1d37 Author: Mossmanikin Date: Fri Dec 20 19:13:37 2013 +0100 Write on paper 0.0.9 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 0000000..4ec390e Binary files /dev/null and b/memorandum/textures/alternates/memorandum_eraser.png differ diff --git a/memorandum/textures/memorandum_eraser.png b/memorandum/textures/memorandum_eraser.png new file mode 100644 index 0000000..1b25084 Binary files /dev/null and b/memorandum/textures/memorandum_eraser.png differ diff --git a/memorandum/textures/memorandum_letter_empty.png b/memorandum/textures/memorandum_letter_empty.png new file mode 100644 index 0000000..1c9f6ba Binary files /dev/null and b/memorandum/textures/memorandum_letter_empty.png differ diff --git a/memorandum/textures/memorandum_letter_text.png b/memorandum/textures/memorandum_letter_text.png new file mode 100644 index 0000000..81f27af Binary files /dev/null and b/memorandum/textures/memorandum_letter_text.png differ diff --git a/memorandum/textures/memorandum_letters.png b/memorandum/textures/memorandum_letters.png new file mode 100644 index 0000000..fb25500 Binary files /dev/null and b/memorandum/textures/memorandum_letters.png differ diff --git a/memorandum/textures/memorandum_message.png b/memorandum/textures/memorandum_message.png new file mode 100644 index 0000000..8a82157 Binary files /dev/null and b/memorandum/textures/memorandum_message.png differ diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29