Pixies Journal Library

First of all I wanted to say thank you again Pixie for the great work and help you give us all. All credit goes to Pixie as it is his/her Library just changed somethings.

Ok so I had the library in game working with my object journal then I changed characters and was no longer able to take notes no matter which way I went in editor. So I thought it must be some thing in the library so opened up lib with notepad++ and bam there it was marked as 'player' when I was looking for 'game.pov' so I changed the 3 spots where it called for 'player' into 'game.pov' and works great. So I wanted to share for newbies that might have trouble with that as I did heres the new library

<library>
  <!--

A very simple module that lets the writer easily put a journal into the game.
To use:

1. Create at item to be used as a journal as normal
2. In the start script on the game item, set up the journal
  a. Call the SetJournalObject with the item you created in
     step 1 as the parameter (as an object)
  b. Optionally, call the SetJournalFont to define how the
     journal text will be displayed. There are three parameters.
     SetJournalFont(font name as string, font size as integer, colour as string)
3. Anywhere in you game where you want an event noted (if the player
   is carrying her journal), invoke the AddToJournal command, with
   the string to be added as a parameter.

Feel free to modify this code as you wish.

The Pixie
the_pix at hotmail dot com

  -->

  <template name="ReadJournal">You read your journal:</template>
  
  <template name="WriteInJournal">You add the following text to your journal:</template>
  
  <dynamictemplate name="JournalNotHeld">"You're not holding your " + object.alias</dynamictemplate>
  
  <object name="journal_object">
    <inherit name="editor_object" />
    <entries type="list"></entries>
    <alias type="string"></alias>
    <held_object type="object">journal_object</held_object>
  </object>

  <command name="append">
    <pattern>-#text#</pattern>
    <script>
      AddToJournal (text)
    </script>
  </command>

  <command name="note">
    <pattern>note</pattern>
    <script>
      msg (Template("WriteInJournal"))
      get input {
	    s = result
        UserAddToJournal (s)
        msg (s)
	  }
    </script>
  </command>

  <command name="journal_command">
    <pattern>journal</pattern>
    <script>
      ReadJournal
    </script>
  </command>

  <function name="SetJournalFont" parameters="font, size, colour">
    journal_object.font = font
    journal_object.size = size
    journal_object.colour = colour
  </function>
  
  <function name="AddToJournal" parameters="entry">
    if (journal_object.held_object.parent = game.pov) {
      list add (journal_object.entries, entry)
    }
  </function>
  
  <function name="UserAddToJournal" parameters="entry"><![CDATA[
    if (journal_object.held_object.parent <> game.pov) {
      msg (DynamicTemplate("JournalNotHeld", journal_object.held_object))
    }
    else {
      list add (journal_object.entries, entry)
    }
  ]]></function>
  
  <function name="ReadJournal"><![CDATA[
    if (journal_object.held_object.parent <> game.pov) {
      msg (DynamicTemplate("JournalNotHeld", journal_object.held_object))
    }
    else {
      msg (Template("ReadJournal"))
      if (HasString(journal_object, "font")) {
        SetFontName (journal_object.font)
        SetForegroundColour (journal_object.colour)
        SetFontSize (journal_object.size)
      }
      else {
        SetFontName ("Comic Sans MS")
        SetForegroundColour ("Blue")
      }
      foreach (s, journal_object.entries) {
        msg (s)
      }
      SetFontName (journal_object.defaultfont)
      SetFontSize (journal_object.defaultfontsize)
      SetForegroundColour (journal_object.defaultforeground)
    }
  ]]></function>
  
  <function name="SetJournalObject" parameters="obj">
    journal_object.held_object = obj
    journal_object.defaultforeground = game.defaultforeground
    journal_object.defaultfontsize = game.defaultfontsize
    journal_object.defaultfont = game.defaultfont
  </function>
</library>

So now when you change your character you can still use your journal :)
Hope it helps some one like it did me

Mike


just a quick note:

you have to be careful with using 'game.pov' as it will apply the whatever stuff you're using it for, to whoever is your currently controlled Player Object (pov: game.pov). For example, if I have a quest/mission that I only want its reward to be given to a specific Player Object, then I don't want to use the 'game.pov' as it would give that reward to whoever is my currently controlled Player Object, instead of giving the reward only for the specific Player Object (which would have to be referenced/checked for specifically, in place of using 'game.pov')


don't use 'game.pov' when you want to keep stuff in regards to your Player Objects separated/individualized/unique


if you don't care about your Player Objects sharing stuff, then use 'game.pov'


Just to clarify, what HK is referring to is the logic of the code, not the actual data, settings, etc. It could be argued that the entire point of having separate POV objects is to not share state - objects held, descriptions, locations, etc. would all be different, unique and separate for each POV. So the "don't use game.pov" line is a bit misleading, in that "stuff" is too vague to be accurate. If you want to keep separate state for different povs, then game.pov is the way to go, as you will be operating on the current pov's state, independently of the others. So that "stuff" would be separate.

If you have logic that is specific to a pov, then you have to implement it for that pov, and there are different ways to do that. In the case that HK relates above - where one POV could solve a mission but another gets the reward - then you obviously would have to write the code targeting that object. That is not a deficiency of game.pov. It would be the same if you only had one POV but wanted to give the reward to "Billy". You would clearly not use game.pov in that case (or even "player") because neither is what you want. You would just give it to Billy. If you have specific requirements, you implement specific logic.

So if you want to treat your POVs the same (shared high-level logic), then use the game.pov reference. If you want to treat your POVs differently, then you have to code that logic specificially - or better yet, if possible, use script attributes on the various POVs so that you can call the same script in all cases, but then each POV can handle the behavior separately.

But the rest of the POV's "stuff" (the data, state, location, etc) are separate and distinct. That's where using scripts on the POVs is a good way to go, if you can do it, as it allows your logic to work with the POVs the same, but the POV itself decides what will happen based on the attribute script being run.

(I just wanted this to be clear in case people took away from the previous post that using "game.pov" would somehow end up applying the same state to all the different POVs (the"if you don't care about your Player Objects sharing stuff, then use 'game.pov'"). It can mean the exact opposite, depending on how you mean "stuff".)


I wrote the library before game.pov was a thing, so it was not an issue back then.

By the way, onimike, could you edit your post so my e-mail address is not in or is disguised for bots (the_pix at hotmail dot com)? Thanks.


@HK yes I do understand what you mean as I did the same thing with a flag set to game.pov then changed player and flag was no longer reading :) But in my instance I have 2 different characters you can be(because their 2 different stories and multiple outcomes) and the 'player' character is in a main menu, so by setting the journal to game.pov i was able to switch characters and still use the journal. I just posted this for beginners having this problem as I did and really had no idea what to do lol.

@Jay Yes like I was saying to HK I understand when giving rewards or different out comes which is why used a flag after changing character so I could run certain scripts with certain players. Good idea on the attribute script I do like that idea :) and yes good looking out to both you Jay and HK because I did not think about that until yesterday when I ran into a problem with game.pov until I set my flag the right way.

@Pixie Sorry bout that I edited it out and hope it was ok for me to post this up. I just know as a non coder I have troubles with somethings and been diving into it a little more and was excited I got this working the way I needed it to.

Thanks again all of you and sorry if I messed anything up!

Mike


my apologies for the use of the ambigious usage of 'stuff' and not explaning it as accurately as Jay, as my brain was going blank, and I wasn't able to think of better words to use, and not having Jay's level of understanding of coding/quest (or I'm not able to remember/memorize/retain/recall something accurately, if I do have that accurate knowledge stored in my brain, lol, grr).

Thank you Jay for clarifying up my misleading post, and helping me and others understand this 'stuff' (sorry, lol) better (whether I can retain and recall this knowledge for the future if this comes up with/from anothernew person ... is another matter, sighs)


my brain's 'memory storage and retrieval' seems to be more faulty than computer chips, lol. I need my brain to be cyberized, replaced by a computer chip/cyber-brain, lol. Hurry up man-machine integration technology (and hope I don't suffer from "cyber brain scireosis" / cyberization rejection, lol. Referencing, Ghost in the Shell: Stand Alone Complex: https://www.youtube.com/watch?v=Aqbk0HiLYOU ) !!!!

(well... the storage may require organic material... due to the amount of data within a human brain. Just 4 grams of DNA can store the data of the entire human race / the internet: every single electronic device in the world !!! http://blogs.discovermagazine.com/d-brief/2016/04/08/dna-data-storage/#.V-CGvhwyy2k )


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums