Simple journals and Linking Books

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Simple journals and Linking Books

Postby Sirius » Wed Jul 10, 2013 3:29 am

So, as I wrote in another thread, I wanted to write two Python files to easily create journals and linking books.

I'm almost done here, both scripts work fine. If Diafero agrees, they will be released with the Offline-KI, and people modeling on Blender will just have to copy/paste some AlcScript to Blender and change a few values in it. No need to edit the python files themselves, or create and release a .pak file

I'll write tutorials explaining how to setup these books, hopefully this will make it relatively simple, even for people new at Age building.


Right now I would like to know what you think about these scripts - whether you would like more features, less, whatever you want.
I wanted to provide only the most important features, more advanced ones will have to be done with D'Lanor's dynamic book template.


Here is what each scripts will do:



xSimpleJournal.py:
Requires these arguments:
- an activator: the clickable book object
- a journal name
- the book type (notebook or normal book) (optional, default will be notebook)
- the book X and Y scale (optional)

The book content will be read from dat/<Age Name>_journals/<journal name>.txt. If these files exist, it will read from <journal name>_french.txt or <journal name>_german.txt depending of Uru's language. The cover texture, font type, additional pictures, etc, will be set directly in this journal using the Plasma HTML (is that how it's called ?). Since it seems there isn't any tutorial about Plasma HTML, I think I'll write one that covers the basics (book cover, fonts and pictures).


xSimpleLinkingBook.py:
Requires:
- an activator
- a destination Age (optional, default will be Nexus)
- a destination spawn point (optional, default will be LinkInPointDefault)
- a link panel texture (optional, default will be Nexus)
- a book cover (optional, default will be none and the book will be shown open)
- a boolean to specify whether the book is a Bahro linking stone (optional, default will be false)
- a boolean to specify whether to show the GoW stamp* (optional, default will be false)
- the book X and Y scale (optional)

* I was thinking about adding the GoW stamp that was originally designed for Sevkor, made by CalumTraveler. I don't know whether it was designed to be used only in Sevkor, though.
Can we use it ? Do you guys want it to be available on books ?

The linking book code uses the Offline-KI's Link Manager. If the Offline-KI is not installed, it will link the player either way, but right now it might link to wrong Age instances (or worse, crash the game if the Age doesn't exist). Well, I guess most people are using the Offline-KI anyway.

I also added a few features, such as:
- animated linking panels (as long as you have a .bik file !)
- fakelink, to avoid reloading the whole Age. Since the third person camera might behave wrong while linking, it is possible to force the Age to be reloaded
- broken books, ie: books with the xLinkPanelBlackVoid, which won't link the player at all

Currently, the script doesn't handle avatar animations (oneshotmods) for linking out. Linking panels, cover textures, images, etc need to be exported with the PRP (I don't fully understand how the Offline-KI manages to load jpeg files directly in Uru's folder, and put them in the book HTML...)
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby Tweek » Wed Jul 10, 2013 6:01 am

I'm all for making crafting of books easier.

Am I to assume that journals in the .txt file will be readable in a notepad then? I'm not overly keen on this idea in terms of datamining spoilers. At least with journals being in .pak files the majority of players don't really know how to sift through that.

In terms of the GoW stamp, I don't see why it couldn't be used for Ages other than Sevkor. A switch in texture could then allow others to have their own stamps on Books.
Beneath - IC Blog.
Beneath: Ages of Tweek - FB Age Dev Page.
User avatar
Tweek
 
Posts: 692
Joined: Sat Sep 29, 2007 6:37 am

Re: Simple journals and Linking Books

Postby Sirius » Wed Jul 10, 2013 8:24 am

Hmmm... If you prefer, the script could also read the journal's content from Python files. For instance, if the journal name started by "py_", the script would try to import the corresponding script instead of looking for a text file.

Using another stamp design could be nice, however this requires one or two more attributes to define the X and Y position on the page. It's feasible though.
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby Sirius » Sat Jul 13, 2013 5:25 am

Alright, the script can now read from both Python and text files. Text files are now in the ageresources folder, as Diafero requested. Python files must be named <agename>_<journalname> (+ _<language> for translations... unless you prefer to store the translation in the same Python file ?)

Anyway, I also fixed things in the linking book script. I decided to remove the code for Bahro stones from it, and create a third Python file: xSimpleBahroStone. This has the advantage to take less arguments, and the user won't have to skip python parameters that are useless for a stone (such as the book size).
Additionnaly, the script won't attempt to link to a missing Age if the link manager is not available.
The user can also provide the stamp texture and position to use.
Speaking of stamps, why is the one I'm currently using appearing streched on the Y axis ? Originally it is round...

I also used the link manager to load linking panels from JPEG files (the way the Relto bookshelf does). It loads linking panels fine, but ONLY if the book is shown opened !
Which means if the book has a cover (and therefore starts closed), no linking panel will be shown...
So, I tried to update the linking panel not only when the book pops up, but also when you turn a page.
Problem: opening the book is not considered turning a page.
The only options I have left is either always show the book opened, or set up a timer to automatically reset the linking panel each 0.5 seconds :?
Any ideas ?
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby diafero » Sat Jul 13, 2013 6:08 am

Nice progress :)

Additionnaly, the script won't attempt to link to a missing Age if the link manager is not available.
So, you're writing it in a way that it works both with and without the Offline KI? Obviously, if I put the script into the Offline KI, I could just remove the fallback code as I know it will never be triggered... so do you plan to also distribute these scripts as a separate pak file, or what's the reason for the non-Offline-KI-code? If that's your plan, I hope we don't get issues of people installing an old version of this pak over a later Offline KI, thereby downgrading parts of their system...

I also used the link manager to load linking panels from JPEG files (the way the Relto bookshelf does). It loads linking panels fine, but ONLY if the book is shown opened !
Which means if the book has a cover (and therefore starts closed), no linking panel will be shown...
So, I tried to update the linking panel not only when the book pops up, but also when you turn a page.
Problem: opening the book is not considered turning a page.
The only options I have left is either always show the book opened, or set up a timer to automatically reset the linking panel each 0.5 seconds :?
Any ideas ?
I had a long answer here explaining the system, but my browser just ate it... lucky enough, you figured it out yourself :)

So, kNotifyNextPage is not triggered when opening the book? That's weird. Probably we never noticed because linking books are typically initially opened. If you just print every event sent to OnNotify, do you get anything?

- a destination spawn point (optional, default will be LinkInPointDefault)
xLinkMgr has the notion of a "default spawn point", which for most, but not all ages is LinkInPointDefault. That's the spawn point used when calling LinkToAge with just one argument (or with the second argument set to None). IMHO that's also the one which should be used by this script when no spawn point is set.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Simple journals and Linking Books

Postby Sirius » Sat Jul 13, 2013 9:21 am

diafero wrote:So, you're writing it in a way that it works both with and without the Offline KI? Obviously, if I put the script into the Offline KI, I could just remove the fallback code as I know it will never be triggered... so do you plan to also distribute these scripts as a separate pak file, or what's the reason for the non-Offline-KI-code? If that's your plan, I hope we don't get issues of people installing an old version of this pak over a later Offline KI, thereby downgrading parts of their system...
I'm often thinking about possible issues with people not having the Offline KI (though I doubt people install fan ages without using the OKI to link to them).
But I have to admit since it's supposed to be released with the OKI, adding code in the event the OKI is not installed is totally useless (why didn't I think about this earlier ? :roll: )
I'm not going to release a non-Offline-KI version, since it would make things quite messy. I really doubt it would be of use to anybody anyway...


diafero wrote:So, kNotifyNextPage is not triggered when opening the book? That's weird. Probably we never noticed because linking books are typically initially opened. If you just print every event sent to OnNotify, do you get anything?
Nope, there isn't any event coming when you open the book... And there isn't any "open book" event in PtBookEventTypes...
I guess I'll just force the book to be opened when loading panels from JPEG images :P


diafero wrote:xLinkMgr has the notion of a "default spawn point", which for most, but not all ages is LinkInPointDefault. That's the spawn point used when calling LinkToAge with just one argument (or with the second argument set to None). IMHO that's also the one which should be used by this script when no spawn point is set.
I thought the linking manager just linked to LinkInPointDefault if no spawnpoint name was given. Then I'll make sure the script doesn't default to LinkInPointDefault but let the manager decide !
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby Sirius » Wed Jul 17, 2013 8:59 am

I am still facing two issues:

- the stamp is STILL stretched on the Y axis. I have no idea why.
However, it seems some images in BkBookImages are resized to avoid this effect - xbooksaveclothbookmark, for instance. Maybe it's just because of Plasma.

- auto-finding linking panels for books work... but it seems Bahro stones do not have the fix to replace the panel. Which means the user will still have to include the linking panel in the PRP...


Except these issues, I think the scripts work well enough. I'm writing tutorials for these. Meanwhile, if someone wants to try out the scripts...
xSimpleBooks.zip
(10.24 KiB) Downloaded 403 times
(AlcScript is included at the beginning of each Python file)
If no fix can be found for the two issues, I guess this version of the scripts will be ok for the Offline-KI.


Also, here is the GoW stamp (I managed to add an alpha channel myself and resized the picture so it's not too big). It must be imported in GUI_District_BkBookImages.prp.
xGoWStamp.zip
(80.05 KiB) Downloaded 419 times
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby diafero » Tue Jul 23, 2013 10:58 am

I'll have a look at the scripts after the exams (i.e., next weekend) :)

- auto-finding linking panels for books work... but it seems Bahro stones do not have the fix to replace the panel. Which means the user will still have to include the linking panel in the PRP...
Yes, that may indeed be. Anyone feeling like replicating the hacks Dustin made to get the dynamic image map into the book PRPs? ;-) Till then, people will have to use textures for that - but you can reference the ones in BkBookImages, so it's not necessary to copy linking images for Cyan's ages into all fan ages linking to them.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Simple journals and Linking Books

Postby Sirius » Tue Jul 23, 2013 12:05 pm

I'll have a look in the GUI, see if the stones can be fixed... And finish the tutorials, could be useful.

diafero wrote:I'll have a look at the scripts after the exams (i.e., next weekend) :)
Best of luck !
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Simple journals and Linking Books

Postby Sirius » Tue Jul 30, 2013 10:02 am

Alright, I fixed the Bahro Stones :D
BahroStones.zip
(123.56 KiB) Downloaded 414 times


I'll post the tutorials soon.
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron