[Mod] Guidebook Library [guidebooks]

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

[Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Image
A heavily extended version of an API from ocular_networks, guidebooks is a library mod which allows the creation of in-game documentation in the form of an item.
This item is called a 'book' internally (although it doesn't have to be a book to the user) and will open a formspec when used.
This formspec is easy to create, as you only need a width, height, and background image.
Each book can hold up to 28 'sections' which can hold pages, or subsections.
subsections can only hold pages.
pages are defined using two text fields but also support the use of a custom formspec string.

(This mod doesn't add any content on its own)
Spoiler

Code: Select all

-- API --

- Creating a new book 
guideBooks.Common.register_guideBook("modname:itemname", { --modname is the name of your mod, itemname is whatever you want
	description_short="Book",                              -- The name of your book
	description_long="A book about books",                 -- an optional field to give your book an extra description
	inventory_image="modname_book.png",                    -- The image of the book when in the inventory
	wield_image="modname_book_wield.png",                  -- An optional image of the book when in the hand
	style={                                                -- a table of values that describe how your book looks
		cover={                                            --- The very first page of your book
			w=5,                                           ---- how wide should the cover be?
			h=8,                                           ---- how tall should the cover be? 
			bg="modname_cover.png",                        ---- the file name of an image to use for the cover
			next="modname_next.png"                        ---- the filename of an image to use for the 'next page' button
		},
		page={                                             --- The generic page style
			w=10,                                          ---- How wide is the book? (2*cover width works best)
			h=8,                                           ---- How tall is the book? (usually same as cover height)
			bg="modname_bg.png",                           ---- the background image for the open book
			next="modname_next.png",                       ---- the filename of an image to use for the 'next page' button
			prev="modname_prev.png",                       ---- the filename of an image to use for the 'previous page' button
			start="modname_start.png"                      ---- the filename of an image to use for the 'first page' button
		},
		buttonGeneric="modname_button.png",                --- A generic button image
	}
})


-- Adding a section 
currently a maximum of 28 sections per index is supported, meaning a book can store 784 sections if all of the sections in the main index are masters.
(this can be circumvented by building custom directories using the 'extra' field of a page, but is not recommended)

guideBooks.Common.register_section(
	"modname:itemname",             -- The name of a registered book
	"section_1",                    -- The name to give the section, only string values supported
	{                               -- A list of preset values (you could also put page definitions here.)
		description="Section 1",    --- The display name of the section
		hidden=false,               --- Whether the section is visible in the main index (set to true to hide)
		master=false,               --- Whether this section leads to an index (set to true to create a new index under this section)
		slave=false,                --- Set to false to show in the main index, set to the name of another section to show in that index. cannot be used with master=true
		Pages={                		--- The pages to preload into the section (use only for certain instances when required)
			Index={}                ---- A special page used only by the 'Main' section that loads after the cover
		}
	}
)

The sections 'Hidden' and 'Main' exist in any book by default

-- adding pages
guideBooks.Common.register_page(
	"modname:itemname",                                       -- The name of a registered book
	"section_1",                                              -- The name of a section in the book
	1,                                                        -- the page number (or name in the case of special pages such as Index)
	{                                                         -- content definition
		text1="foo bar",                                      --- the text to display on the first half of the page
		text2="lorem ipsum dolor sit amet",                   --- the text to display on the second half of the page
		extra="background[0,0;5,8;modname_image.png;false]"   --- A minetest formspec string used to add extra content to a page, such as an image
	}
)

The page 'Index' exists in the 'Main' section by default but can be overriden.
Spoiler
Image
Image
Image
Image
Image
Download latest
Github
license of media and source: CC-BY-SA 4.0

no dependencies
Last edited by PolySaken on Wed Sep 16, 2020 20:37, edited 2 times in total.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: [Mod] Guidebook Library [guidebooks]

by runs » Post

Oh, impressive. It reminds me the Bethesda Games books :-)

CalebJ
Member
Posts: 407
Joined: Sat Dec 29, 2018 19:21
GitHub: KaylebJay
IRC: KaylebJay
In-game: CalebJ
Location: Tunnelers' Abyss

Re: [Mod] Guidebook Library [guidebooks]

by CalebJ » Post

Very impressive indeed! This looks well done, I'll try it out soon :)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Glad you guys like it! I'm planning to make support for unlockable sections, so that there is a degree of progression to the books.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Guidebook Library [guidebooks]

by Sokomine » Post

Looks very nice. Hope this and other book mods get a wider use on servers.
A list of my mods can be found here.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Sokomine wrote:Looks very nice. Hope this and other book mods get a wider use on servers.
I've noticed that people don't seem to use the books in default much or at all in servers, which is pretty much the only place other than maps they might be useful.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] Guidebook Library [guidebooks]

by Lone_Wolf » Post

Neat! I'll have to try this out...
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Lone_Wolf wrote:Neat! I'll have to try this out...
Could you show me your results? I'd like to know what people are using it for in order to tailor it to better suit a broader range of uses.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] Guidebook Library [guidebooks]

by Lone_Wolf » Post

PolySaken wrote:
Lone_Wolf wrote:Neat! I'll have to try this out...
Could you show me your results? I'd like to know what people are using it for in order to tailor it to better suit a broader range of uses.
Sure, may be a while yet though. I have a few things to code until I get to the point where I'm adding books into the game lol
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Lone_Wolf wrote:
PolySaken wrote:
Lone_Wolf wrote:Neat! I'll have to try this out...
Could you show me your results? I'd like to know what people are using it for in order to tailor it to better suit a broader range of uses.
Sure, may be a while yet though. I have a few things to code until I get to the point where I'm adding books into the game lol
That's cool. What are you making?
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

double post
Last edited by PolySaken on Sat Nov 16, 2019 04:05, edited 2 times in total.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

edit: removed doublepost
Last edited by PolySaken on Sat Nov 16, 2019 04:05, edited 1 time in total.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

The bug causing locked sections to show up when they're not supposed to has been fixed, Along with the ordering system.
Sections will now display in the order of registration rather than size.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Attention: A bug has been discovered that causes crashing and corruption when more than one book is registered. Unless you have a fix, I wouldn't recommend using this mod for now.
(I have no idea why this bug is happening, it seems to be part of the show_formspec code)
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] Guidebook Library [guidebooks]

by Lone_Wolf » Post

PolySaken wrote:Attention: A bug has been discovered that causes crashing and corruption when more than one book is registered. Unless you have a fix, I wouldn't recommend using this mod for now.
(I have no idea why this bug is happening, it seems to be part of the show_formspec code)
What's the error?
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Lone_Wolf wrote:
PolySaken wrote:Attention: A bug has been discovered that causes crashing and corruption when more than one book is registered. Unless you have a fix, I wouldn't recommend using this mod for now.
(I have no idea why this bug is happening, it seems to be part of the show_formspec code)
What's the error?
The index page is not showing, despite all of the checks being met. In the rare event that it does, it shows for a few microseconds at most before crashing the game.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] Guidebook Library [guidebooks]

by Pyrollo » Post

Hypertext formspec element and its markup language can improve your mod's look and feel. It's not yet in stable version, but you can yet test it on dev version.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Pyrollo wrote:Hypertext formspec element and its markup language can improve your mod's look and feel. It's not yet in stable version, but you can yet test it on dev version.
Excuse me if I'm missing something, but this doesn't seem all that relevant. (Unless it's a general suggestion, In which case I'll look into it.)
Last edited by PolySaken on Tue Dec 10, 2019 22:39, edited 1 time in total.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

-removed doublepost-
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

good news! I managed to fix the bug. (apparently setting the player's wielded item from inside on_player_receive_fields will cause any following code to terminate. i worked around this by using minetest.after(0))
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by Wuzzy » Post

This reminds me of Documentation System. :D

How does this mod differ?

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Wuzzy wrote:This reminds me of Documentation System. :D

How does this mod differ?
All the documentation is stored in and presented as actual in game book items. Also it can be used for lore or anything else, it's just a way to make predefined books with fancy menus and graphics.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by Wuzzy » Post

Ah, interesting. This could be useful in other ways as well, for example create in-game lore as well. Nice.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] Guidebook Library [guidebooks]

by PolySaken » Post

Putting the code ptype=true into your book's definition will now make it ignore the text2 element of every page. Useful for making books that act like digital screens or magic stone tablets.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Merak
Member
Posts: 116
Joined: Sat Nov 05, 2016 20:34

Re: [Mod] Guidebook Library [guidebooks]

by Merak » Post

The white text color on a light brown background is difficult to read because of little contrast.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 12 guests