GithubHelp home page GithubHelp logo

books's Introduction

Books and Bookcases

This module adds the ability to read and write books, as well as store them in bookcases. This module also adds the ability to edit books and their contents.

The following types of components can be made:

  • Book
  • Bookcase

Contribution

Use groovyw module get Booksto fetch the module.

Creating a Book

To create a book, create a prefab similar to ones found Here and add the icon from Here. For instance, to create a book called "1984", the prefab should look like:

{
  "parent" : "engine:iconItem",
  "Item" : {
    "icon" : "Books:book",
    "usage" : "ON_USER"
  },
  "DisplayName" : {
    "name" : "1984"
  },
  "Book" : {
    "tint" : [245, 222, 179, 255]
  },
  "InteractionTarget": {},
  "InteractionScreen": {
    "screen": "Books:BookScreen"
  }
} 

where book.png is the name of the icon in the prefabs folder. DisplayName and Book contain information relevant to how the book is displayed. InteractionScreen contains information relevant to how the book is interacted with. All books should have usage set to ON_USER.

Creating a bookcase

To create a bookcase, create a prefab similar to the one found Here. For example, a default bookshelf should look like:

{
  "Bookcase": {},
  "Inventory": {
    "privateToOwner": false,
    "itemSlots": [
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    ]
  },
  "RetainBlockInventory": {},
  "PlaySoundAction": {
    "sounds": "engine:click"
  },
  "InteractionTarget": {},
  "InteractionScreen": {
    "screen": "inventory:containerScreen"
  },
  "Network": {
  }
}

where itemSlots should be filled with 0s as it is empty. privateToOwner details whether or not other users have access to the bookshelf. PlaySoundAction contains the sound played for when the bookshelf is opened. InteractionScreen contains information of how the bookshelf should be interacted with.

Credits for images:

books's People

Contributors

arpan98 avatar cervator avatar darkweird avatar imaculgy avatar immortius avatar jdrueckert avatar keturn avatar naman-sopho avatar nihal111 avatar nschnitzer avatar pandacontron avatar pollend avatar qwertygiy avatar skaldarnar avatar small-jeeper avatar timverhaegen avatar waterpicker avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

books's Issues

Recipes do not display correctly in RecipeBook

image

When the player opens the recipe book and turns the page twice, to display the recipes, a nullpointer exception occurs and the recipes do not display correctly. Here is the stacktrace:

java.lang.NullPointerException: null
        at org.terasology.books.RecipeParagraph.<init>(RecipeParagraph.java:46)
        at org.terasology.books.rendering.nui.layers.BookScreen.createRecipeParagraph(BookScreen.java:176)
        at org.terasology.books.rendering.nui.layers.BookScreen.createParagraphs(BookScreen.java:159)
        at org.terasology.books.rendering.nui.layers.BookScreen.createDocument(BookScreen.java:142)
        at org.terasology.books.rendering.nui.layers.BookScreen.updatePage(BookScreen.java:226)
        at org.terasology.books.rendering.nui.layers.BookScreen.lambda$initialise$0(BookScreen.java:314)
        at org.terasology.rendering.nui.widgets.UIButton.activate(UIButton.java:208)
        at org.terasology.rendering.nui.widgets.UIButton.access$100(UIButton.java:41)
        at org.terasology.rendering.nui.widgets.UIButton$1.onMouseRelease(UIButton.java:99)
        at org.terasology.rendering.nui.internal.CanvasImpl.processMouseRelease(CanvasImpl.java:247)
        at org.terasology.rendering.nui.internal.NUIManagerInternal.mouseButtonEvent(NUIManagerInternal.java:576)
        at org.terasology.rendering.nui.internal.NUIManagerInternalMethodAccess.invoke(Unknown Source)
        at org.terasology.entitySystem.event.internal.EventSystemImpl$ByteCodeEventHandlerInfo.invoke(EventSystemImpl.java:531)
        at org.terasology.entitySystem.event.internal.EventSystemImpl.sendConsumableEvent(EventSystemImpl.java:301)
        at org.terasology.entitySystem.event.internal.EventSystemImpl.send(EventSystemImpl.java:280)
        at org.terasology.entitySystem.entity.internal.BaseEntityRef.send(BaseEntityRef.java:204)
        at org.terasology.input.InputSystem.send(InputSystem.java:367)
        at org.terasology.input.InputSystem.sendMouseEvent(InputSystem.java:354)
        at org.terasology.input.InputSystem.processMouseButtonInput(InputSystem.java:184)
        at org.terasology.input.InputSystem.processMouseInput(InputSystem.java:169)
        at org.terasology.input.InputSystem.update(InputSystem.java:129)
        at org.terasology.engine.modes.StateIngame.handleInput(StateIngame.java:192)
        at org.terasology.engine.subsystem.lwjgl.LwjglInput.postUpdate(LwjglInput.java:55)
        at org.terasology.engine.TerasologyEngine.tick(TerasologyEngine.java:467)
        at org.terasology.engine.TerasologyEngine.mainLoop(TerasologyEngine.java:421)
        at org.terasology.engine.TerasologyEngine.run(TerasologyEngine.java:397)
        at org.terasology.engine.Terasology.main(Terasology.java:155)

Support images in books

The HTML widgets in NUI currently can display images. It would be nice if books could do something similar, although that might be tricky vs. keeping the editing interface simple (how would you edit in an image?)

Integration with Quests

As a modder I would want to be able to attach quests (tasks) to a book. If the book is in a players inventory it should be active and if it is removed it should become inactive. I would want to define the book and the quest requirements in the same prefab.

As a player I would want to be able to find books in the world and acquire quests while I have said book.

See https://github.com/Terasology/QuestExamples for an example of a simple quest bound to an entity placed in the world. Update that module to depend on Books and place a book that has a quest attached to it in a chest spawned near the player. Handle logic for when the book enters and exits the player's inventory (might be some similar code in BookcaseSystem)

Cursor can be left in the opening cover when page 1 is visible

Can't actually write anything so it is a pretty minor cosmetic issue.

To replicate: open a book, without changing pages (should start with the inside of the front cover + page one visible) click in the upper left of the inside cover and a blinking cursor will appear. You can't do anything with it like write stuff.

Integration with JoshariasSurvival - recipe to create a book

I would like to be able to craft books (and bookshelves) in JoshariasSurvival.

There is a crafting system of some note in JS already and some related items. For instance I believe you can crush wood into "wood chunks" which could probably be crushed a second time in a new workstation similar to the sifting station (so you can add water) to then create "wood pulp" (optionally include an additional step that produces saw dust and use that for the wood pulp combine)

With wood pulp created you could perhaps turn it into individual pieces of parchment in a regular assembly station by using metal plates or something as involved tools. Take the pieces of parchment (5? or one per page in the final book product?) and combine again with string to get a book.

Planks also exist (and could probably be used as the flat tools rather than metal plates?) and could be used as a recipe to make a bookshelf instead of a chest.

Creativity is welcome, research pre-industrial ways of manufacturing paper to come up with different recipes if desired. Could even make a tier 2 option using the mechanized workstations in JS to fashion an outright printing press of some sort.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Few remaining issues at v1.0.0

Did some testing! Still a few issues to look for

  • The page indexing is off. I can click through a book to the right three times, then back only two times to get the front cover (page 1 is missing?)
  • Outright crashed once attempting to open a book, error below. Pretty sure it is from leaving one book on the last page then opening another.
  • Is the active page "sticky" and somehow leaking between entities? I think I could leave a book open on a specific page and a different book would then open to that page? Or maybe that's a red herring. Or the cause for the crash above
  • There is still some UI element that is eating e clicks. Try placing a chest when you spawn, without even having requested any book-related stuff via console. First e click does nothing (almost like it is being caught by something else / consumed early) then the second click opens the chest
  • Bookcase blocks still do not open, but still make the click noise. ~~~I wonder if that's related to the e click issue?~~~

Quite possibly some of these predate the recent overhaul by @Waterpicker. I just fixed a JSON formatting issue and put -SNAPSHOT back on the version number in module.txt (source should always be SNAPSHOT and Jenkins / release management handles the non-snaphots, lest things go boom). Also fixed some tabs -> spaces and a waaay outdated "craftPlace" thing

Actually, that appears to have fixed the e eating. Yay! I fixed something :-)

Crash log:

14:28:44.714 [main] INFO  o.t.logic.console.ConsoleImpl - [CONSOLE] You received an item of Books:bluebook
14:29:23.882 [main] ERROR o.terasology.engine.TerasologyEngine - Uncaught exception, attempting clean game shutdown
java.lang.IndexOutOfBoundsException: Index: 3, Size: 2
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at org.terasology.books.rendering.nui.layers.BookScreen$3.get(BookScreen.java:145)
    at org.terasology.books.rendering.nui.layers.BookScreen$3.get(BookScreen.java:136)
    at org.terasology.rendering.nui.widgets.UILabel.getText(UILabel.java:65)
    at org.terasology.rendering.nui.widgets.UILabel.onDraw(UILabel.java:89)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.layouts.relative.RelativeLayout.onDraw(RelativeLayout.java:78)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.CoreScreenLayer.onDraw(CoreScreenLayer.java:104)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.internal.NUIManagerInternal.render(NUIManagerInternal.java:468)
    at org.terasology.engine.modes.StateIngame.renderUserInterface(StateIngame.java:234)
    at org.terasology.engine.modes.StateIngame.render(StateIngame.java:218)
    at org.terasology.engine.subsystem.lwjgl.LwjglGraphics.postUpdate(LwjglGraphics.java:189)
    at org.terasology.engine.TerasologyEngine.mainLoop(TerasologyEngine.java:423)
    at org.terasology.engine.TerasologyEngine.run(TerasologyEngine.java:369)
    at org.terasology.engine.Terasology.main(Terasology.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
14:29:23.883 [main] INFO  o.terasology.engine.TerasologyEngine - Shutting down Terasology...
14:29:23.966 [main] INFO  o.t.p.i.ReadWriteStorageManager - Saving - Creating game snapshot
14:29:23.969 [main] INFO  o.t.p.i.ReadWriteStorageManager - Saving - Snapshot created: Writing phase starts
14:29:23.972 [main] INFO  o.t.n.internal.NetworkSystemImpl - Client disconnected: Cervator
14:29:23.976 [main] INFO  o.t.logic.console.ConsoleImpl - [NOTIFICATION] Player "Cervator" has left the game
14:29:23.976 [main] INFO  o.t.n.internal.NetworkSystemImpl - Network shutdown
14:29:25.282 [Saving-0] INFO  o.t.p.internal.SaveTransaction - Save game finished
14:29:28.202 [main] WARN  o.t.rendering.nui.asset.UIFormat - Field 'emptyIcon' not recognized for interface org.terasology.rendering.nui.UIWidget in {"type":"UIIconBar","id":"breathBar","icon":"engine:icons#bubble","family":"breathBar","emptyIcon":"engine:icons#burstBubble","halfIconMode":"shrink","spacing":2,"maxIcons":10,"layoutInfo":{"use-content-width":true,"use-content-height":true,"position-left":{"target":"CENTER"},"position-right":{"target":"RIGHT","widget":"healthBar"},"position-bottom":{"target":"TOP","widget":"healthBar","offset":1}}}
14:29:28.203 [main] WARN  o.t.rendering.nui.asset.UIFormat - Field 'crosshairIcon' not recognized for interface org.terasology.rendering.nui.UIWidget in {"type":"UICrosshair","id":"crosshair","crosshairIcon":"engine:gui#crosshair","layoutInfo":{"use-content-width":true,"use-content-height":true,"position-horizontal-center":{},"position-vertical-center":{}}}
14:29:28.226 [main] WARN  o.t.rendering.nui.skin.UISkinFormat - Failed to resolve UIWidget class UIInputBindButton, skipping style information
java.lang.IndexOutOfBoundsException: Index: 3, Size: 2
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at org.terasology.books.rendering.nui.layers.BookScreen$3.get(BookScreen.java:145)
    at org.terasology.books.rendering.nui.layers.BookScreen$3.get(BookScreen.java:136)
    at org.terasology.rendering.nui.widgets.UILabel.getText(UILabel.java:65)
    at org.terasology.rendering.nui.widgets.UILabel.onDraw(UILabel.java:89)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.layouts.relative.RelativeLayout.onDraw(RelativeLayout.java:78)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.CoreScreenLayer.onDraw(CoreScreenLayer.java:104)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawStyledWidget(CanvasImpl.java:406)
    at org.terasology.rendering.nui.internal.CanvasImpl.drawWidget(CanvasImpl.java:392)
    at org.terasology.rendering.nui.internal.NUIManagerInternal.render(NUIManagerInternal.java:468)
    at org.terasology.engine.modes.StateIngame.renderUserInterface(StateIngame.java:234)
    at org.terasology.engine.modes.StateIngame.render(StateIngame.java:218)
    at org.terasology.engine.subsystem.lwjgl.LwjglGraphics.postUpdate(LwjglGraphics.java:189)
    at org.terasology.engine.TerasologyEngine.mainLoop(TerasologyEngine.java:423)
    at org.terasology.engine.TerasologyEngine.run(TerasologyEngine.java:369)
    at org.terasology.engine.Terasology.main(Terasology.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
For more details, see the log files in J:\Dev\Terasology\Git\integrate\Terasology\logs\2016-06-18_14-21-06

Remove usage of default font

This ancient module still has a copy of the default font shipped under /assets/fonts - that should be deleted and the books should use one of our standard Noto fonts.

Oddly when I tried to simply delete the font files and replace the one instance in bookScreen.skin with Noto the main pages of a book no longer had any text appear. Not sure what I'm missing.

Bookcases only get special logic on an authority client

Meaning book filtering wasn't working when connected to a headless client, yet was OK on the authority in a client/server + client two player setup running locally. Probably book drops as well.

Easy fix, got it ready, but trying to get into documenting changes better.

Re-implement some unique functionality for bookcases

Way back in the olden days, in the time before time, bookcases had a filter on what items they would accept (only books, naturally). This was removed over time as the engine matured, and we might not have the original event anymore.

Mentioned briefly with more details at the bottom of #2

UI Improvement

Current UI

image

Notes on the design

  1. Some buttons are used only when others are active, e.g. the save should pop-up when the user is on edit mode
  2. The cancel button is a bit unclear: does it mean cancel of editing? cancel of the emblement (closes the book)?
  3. Edit could be incorporated more into the design I think, e.g. something like an actual quill sitting at the side and when clicked it enables you to edit the text
  4. The Add and Delete can be changed to symbols like "+" or ":wastebasket:", and their placement is a bit odd: not in the middle, nor to the side, nor somewhere specific in between
  5. The title is a bit small in my opinion. I think the fact that the page has quite some text, the user should have an easier time reading the title, so by having a wider title can give an easy summary for it
  6. I don't think we should have the buttons (or any other design e.g. like the quill I suggested) invisible like the second screenshot Niruandaleth had send (though I believe the screenshot was sent to have a blank reference)
  7. The next and previous page buttons look nice. they are simple and self-explanatory

Examples

Life is Strange

Reference

image

Comments

I think this might be a nice example, as it contains a lot of text as well. There are images play the role I described at 5 above, meaning that they play as a summary of the text, thus the user will read it only if they really want to see further details.

Reference from the article Quest log and quest path | Quests

Reference

image

Comments

I don't think it is necessary to have the buttons on top of the book, but it's an idea as well.

New book type: contract book

As somewhat of an extension to #21 I would want to be able to create a book (or even just a single piece of parchment, really - a scrip?) in-game and map text in the book to game objects. Imagine a merchant writing up a contract to acquire 20 wood trunk blocks for 2 silver pieces.

I would want to be able to enter an edit screen on a created book (or piece or parchment) and have the ability to add a text box or drop-down as a widget in-line with the text, then what I select or enter in that field should correspond to an in-game object (thus the idea for a drop-down - simply prefill with all valid objects, later probably provider some filtering/auto-complete)

A contract book/scrip likely would some hard-wired sections, unlike regular books. They might start prefilled with the selectors. The author would indicate the following things:

  • Demand - items the contract asks for
  • Reward - items the contract offers in return
  • Location - where to bring the items (and receive the reward) - this could simply be the book/scrip itself in the first iteration
  • Button - option to trigger the contract when everything is in order.

If a player has such a book/scrip that requests 5 dirt blocks in return for 2 stone blocks and presses the button with 5 dirt blocks in their inventory they should have those blocks subtracted and 2 stone blocks added.

Note that at some point it may make sense to develop a new module that simply depends on Books (such as a trading/merchant module and/or involve the existing Economy module)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.