Writable Books...

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Writable Books...

by TenPlus1 » Tue Feb 10, 2015 11:06

For players wanting to write inside books and have other players read them, here is the latest book code that has been submitted to minetest_game as a feature request... <fingers crossed> it will be included in default minetest :)

Note: VanessaE's latest homedecor mod has writable books also but the following code word-wraps books when being read.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--= Book (use to read or write to)

minetest.register_craftitem(":default:book", {
   description = "Book",
   inventory_image = "default_book.png",
   groups = {book=1},
   stack_max = 1,
   on_use = function(itemstack, user, pointed_thing)
      local player_name = user:get_player_name()
      local data = minetest.deserialize(itemstack:get_metadata())
      local title, text, owner = "", "", player_name
      if data then
         title, text, owner = data.title, data.text, data.owner
      end
      local formspec
      if owner == player_name then
         formspec = "size[8,8]"..default.gui_bg.. -- default.gui_bg_img..
            "field[0.5,1;7.5,0;title;Title:;"..
               minetest.formspec_escape(title).."]"..
            "textarea[0.5,1.5;7.5,7;text;Contents:;"..
               minetest.formspec_escape(text).."]"..
            "button_exit[2.5,7.5;3,1;save;Save]"
         minetest.show_formspec(user:get_player_name(), "default:book", formspec)
      else
         formspec = "size[8,8]"..default.gui_bg.. -- default.gui_bg_img..
            "button_exit[7,0.25;1,0.5;close;x]"..
            "label[0.5,0;"..minetest.formspec_escape(title).."]"..
            "label[0.5,0.5;by "..owner.."]"..
            "textarea[0.5,1.5;7.5,7;text;;"..
               minetest.formspec_escape(text).."]"
         minetest.show_formspec(user:get_player_name(), "default:lockedbook", formspec)
      end
   end,
})

minetest.register_on_player_receive_fields(function(player, form_name, fields)
   if form_name ~= "default:book" or not fields.save then
      return
   end
   local stack = player:get_wielded_item()
   if minetest.get_item_group(stack:get_name(), "book") == 0 then
      return
   end
   local data = minetest.deserialize(stack:get_metadata())
   if not data then data = {} end
   data.title, data.text, data.owner =
      fields.title, fields.text, player:get_player_name()
   stack:set_metadata(minetest.serialize(data))
   player:set_wielded_item(stack)
end)
 

User avatar
davidthecreator
Member
 
Posts: 179
Joined: Mon Aug 18, 2014 19:48
In-game: DavidDoesMinetest

Re: Writable Books...

by davidthecreator » Thu Feb 12, 2015 15:52

That would make a good thing to default I also hope it will get adder to default game
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Writable Books...

by Krock » Thu Feb 12, 2015 20:02

A good idea :)
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Writable Books...

by TenPlus1 » Fri Feb 13, 2015 10:14

...and if you want to re-use a book that someone else gave you, place book in crafting with 1 white dye to erase contents and return an empty book :)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craft({
   output = 'default:book',
   recipe = {
      {'default:book', 'dye:white', ''},
   },
})
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Writable Books...

by Sokomine » Fri Mar 06, 2015 05:23

Nice idea! Hope this gets merged. So far, books are only craft items. They could be used for messages with this change.
A list of my mods can be found here.
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Writable Books...

by sofar » Mon May 04, 2015 20:21

Can you add a "copy book" recipe? Where you combine a written book and an empty book to create a second written book (and obviously retain the original one as well)?
 

twoelk
Member
 
Posts: 1092
Joined: Fri Apr 19, 2013 16:19

Re: Writable Books...

by twoelk » Tue May 05, 2015 10:43

Sokomine wrote:Nice idea! Hope this gets merged. So far, books are only craft items. They could be used for messages with this change.


hm maybe a guestbook function?
So that contents can be added but not easily deletet.
Like the signs on Mt.Meru on Landrush server that state who managed it to the top.
Thinking further in this direction there could be an achievement reward triggered by adding an entry to a guestbook.
This could be made into some gameplay function like "collect 10 mountaineer badges" or "visit 5 touristic highlights on this server".

Of course such a guestbook could also be used in the traditionall way to collect praise or feedback for something ;-P

ps. I could use one for my Northern Inn and I could imagine Bulldog on VE-creative would be delighted to use them in in his growing eat and sleep network. :-D
 

User avatar
Dopium
Member
 
Posts: 233
Joined: Sat Jun 09, 2012 15:43

Re: Writable Books...

by Dopium » Tue May 05, 2015 14:42

+1 without a doubt this would add another element to mp survival gameplay. Even though it can be a mod, would be a nice addition to the default game. Books are not much use if you can't write in them :)
 

red
Member
 
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Writable Books...

by red » Wed May 06, 2015 21:44

I took all the code for the books in this topic and made it in to a mod.Here is the zip file.
Edit
divieded books into locked books and books. Locked book can olny be edited by the player that wrote them and books can be edited by any one. New download here
Old download here
Attachments
books_plus.zip
(1.33 KiB) Downloaded 131 times
Last edited by red on Sun May 10, 2015 10:15, edited 1 time in total.
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

Re: Writable Books...

by domtron vox » Thu May 07, 2015 18:08

twoelk wrote:hm maybe a guestbook function?
So that contents can be added but not easily deletet.


This could be done without the player actually editing the book. Have a book on a lecturn that is readable only but has a button at the top that says "add name". clicking on said button would append the character's name if it isn't already in the book.

twoelk wrote:Of course such a guestbook could also be used in the traditional way to collect praise or feedback for something ;-P

I see this being done with a "mail drop" type chest. Get a book. Write suggestions and feedback. Drop it in the mail drop chest.
 

twoelk
Member
 
Posts: 1092
Joined: Fri Apr 19, 2013 16:19

Re: Writable Books...

by twoelk » Thu May 07, 2015 18:48

hm , press a button? hmm

Ha, I could imagine some book of rules that is presented at first join.
"press the button if you have read and understood the rules"
and the name gets added to a list.
Breaking the rules gets the name erased so on the next join one is forced to read the rules again.

hm ...
or multiple buttons for multiple choice tests ...
or dialog trees
or ...
 

red
Member
 
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Writable Books...

by red » Sat May 09, 2015 12:43

Modified the source code for the mod to make the default book editable by anyone and make a locked book that can olny be edited by the orginal player. A locked book can be crafted using a iron ingot and a book.

Edit added texture for locked book and updated .zip file to have it.
Attachments
books_plus.zip
(6.01 KiB) Downloaded 151 times
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Writable Books...

by Napiophelios » Sun May 10, 2015 14:35

red wrote:Modified the source code for the mod to make the default book editable by anyone and make a locked book that can olny be edited by the orginal player. A locked book can be crafted using a iron ingot and a book.

Edit added texture for locked book and updated .zip file to have it.


it would be cool if unlocked, written-to books could be converted
to a locked status without losing their contents.
also if players could add multiple pages/tabs instead of one long entry.

regardless,nice work.
this is pretty neat.
 

red
Member
 
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Writable Books...

by red » Sun May 10, 2015 15:54

Napiophelios wrote:
it would be cool if unlocked, written-to books could be converted
to a locked status without losing their contents.

I am planing on creating a writing table with will allowed you to copy the text from one book to another. I already have a nodebox made for the table I only need to figure out how the formspec works.
also if players could add multiple pages/tabs instead of one long entry.

That dosn't sound too hard to do, will look into it.

regardless,nice work.
this is pretty neat.

Thank you
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Writable Books...

by Napiophelios » Sun May 10, 2015 17:44

Just a thought... if the tool-tip/description were changed to the book's title once written-to,
would make looking through a bookshelf much more interesting.
 

red
Member
 
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Writable Books...

by red » Sun May 10, 2015 18:56

Napiophelios wrote:Just a thought... if the tool-tip/description were changed to the book's title once written-to,
would make looking through a bookshelf much more interesting.

Yes it would be, sadly it isn't possibly with the current lua api.
 

red
Member
 
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Writable Books...

by red » Mon May 11, 2015 19:20

Tenplus1 under what license is the code you pasted in the frist post?
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Writable Books...

by TenPlus1 » Tue May 12, 2015 06:17

WTFL license... you can do what you like with it...
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 11 guests

cron