Trying to make a time stamp for the Journal [SOLVED]

I have a journal which has also the basic functionality from the the Journal tutorial in the documentation. I add certain events in the story as text to a stringlist and everything works fine but I want to add a time stamp to each entry.

I just can't figure how to get the current day and time value into the entry. I can add the value into the entry but the problem is if I read the journal again later, it always displays the current timeand not the when the entry was added.


How are you adding the timestamp?

If it displays the current time, I wonder if you're using text processor directives; those are only evaluated when they're displayed. If so, you could call the ProcessText function manually when you add a string to the journal, causing the text processor to be run then.


How are you adding the timestamp?

You're right, this was the text processor. My previous attempts to make to turn the values into strings returned a error:

d = ToString(game.day)

"Error running script: Error evaluating expression 'ToString(game.day)': Object reference not set to an instance of an object."


If so, you could call the ProcessText function manually when you add a string to the journal, causing the text processor to be run then.

How does it work? I couldn't get much from the documentation's explanation.


It's simple. If you have a string s, then you can do:

s = ProcessText (s)

That will cause any text processor directives in the string s to be replaced by their output, based on the current values of any variables they use.

If you need more help with this, it might be worth sharing the code you're using. I don't know the tutorial you're using.


I used this tutorial for the entries: http://docs.textadventures.co.uk/quest/keeping_a_journal.html


The entries are in a stringlist.

plr_journal.entries = NewStringList()
list add(plr_journal.entries, "I found Moira and she wasn't happy. She gave me the missng book and I spared her life.")

I have a Journal menu in which the player can select "Read Entries" (also as a command).
To print the entries I print a message with FormatList in it.

msg ("</br>> read Journal Entries </br>" + FormatList(plr_journal.entries, "</br></br>", "</br></br>", "The Journal is empty.</br>") + "")

This prints like this:

> read Journal Entries

I have finally reached the catacombs.

I found Moira and she wasn't happy. She gave me the missng book and I spared her life.

I thought adding a time stamp each entry would look nicer but I couldn't figure it yet. Also I still don't understand how to use ProcessText. Does it need the text processor function or a string value? The time values are all integers and any attempt to use ToString results in a error.


You said you had it working but it displayed the current time when the journal entry was displayed.

So I assume you have a line something like:

list add(plr_journal.entries, "[Day {game.day}, {game.hour}:{game.minute}] I found Moira and she wasn't happy. She gave me the missng book and I spared her life.")

If you've got something like that, then you can simply change it to:

list add(plr_journal.entries, ProcessText ("[Day {game.day}, {game.hour}:{game.minute}] I found Moira and she wasn't happy. She gave me the missng book and I spared her life."))

Or you could put a string together directly:

journal_message = "Day " + game.day + ", " + game.hour + ":" + Right("0"+game.minutes, 2) + " - I found Moira and she wasn't happy"
list add (plr_journal.entries, journal_message)

Hahaha... Yes, pretty much like that.

list add(plr_journal.entries, "<b>Day: {game.day}, {game.hour}:{game.minute}</br>Turn: {game.turncount}</br></b> I found Moira and she wasn't happy. She gave me the missng book and I spared her life.")

I gonna test it later, thanks...


So, both variations doesn't print a value...

list add(plr_journal.entries, ProcessText ("[Day {game.day}, {game.hour}:{game.minute}] I found Moira and she wasn't happy. She gave me the missng book and I spared her life."))

and

journal_message = "Day " + game.day + ", " + game.hour + ":" + Right("0"+game.minutes, 2) + " - I found Moira and she wasn't happy"
list add (plr_journal.entries, journal_message)

Pirnt this:

[Day: Time: : Turn: ]


What are game.day and game.hour set to at this point?
Are you sure they're set to something?


They are all integer values and before I made my last post I have tested it with different values, but only integers.I think that's why I tried ToString in the first place... using a copy of your code brought the same result... :-(


Edit: They are all integers because, unlike Pixie's Clock Lib I don't have named days. It's just a day counter. Game starts at Day 1 and the number just increase forever.


I solved it!
After finally understanding what ToString exactly does the first try solved the error.

timestamp = "Day: " + ToString (GetInt (game, "day")) + ", Time: " + ToString (GetInt (game, "hour")) + ":" + ToString (GetInt (game, "minute")) + ""
list add (game.journal_entries, "" + timestamp + "Blablabla...")

I think I gonna set a game.timetamp attribute to a turnscript and use it whenever I write a journal entry...


Hm, when I use the object attribute game.timestamp it doesn't print the time stamp in the message.

game.timestamp = "Day: " + ToString (GetInt (game, "day")) + ", Time: " + ToString (GetInt (game, "hour")) + ":" + ToString (GetInt (game, "minute")) + ""
list add (game.journal_entries, "" + game.timestamp + "Blablabla...")

while the same code with a variable works .
timestamp = "Day: " + ToString (GetInt (game, "day")) + ", Time: " + ToString (GetInt (game, "hour")) + ":" + ToString (GetInt (game, "minute")) + ""
list add (game.journal_entries, "" + timestamp + "Blablabla...")

Edit:
Okay, now I can use ProcessText (game.timestamp) in the journal entry in order to get around this and using the object attribute.

game.timestamp = "Day: " + ToString (GetInt (game, "day")) + ", Time: " + ToString (GetInt (game, "hour")) + ":" + ToString (GetInt (game, "minute")) + ""
list add (game.journal_entries, "" + ProcessText (game.timestamp) + "Blablabla...")

Tested it with the turnscript and it works.


Just changed the whole stuff... Dunno how I never recognized that status attributes won't update if Don't use ! and now, after two years off developing... So, I've learned what a changescript is and got everything set up. That's fine but now I need in some cases Rounded Numbers to print for the player... in order to avoid messages like, "You've dealt 5,87538?12 DMG."


Hi there, Are you a Home Depot employee? Do you need help logging into your myTHDHR account? Then this article is tailor-made for you.
https://employeelogin.xyz/mythdhr-login/


Log in to post a reply.

Support

Forums