Page 1 of 1

[Solved] Adding choices to _history_list

Posted: Wed May 02, 2018 8:57 am
by kalesco
I have searched for hours and tried different approaches but nothing would give me what I need.

In order to have a logbook of all questions and answers in an educational game I need the choices the user makes to be added to _history_list.
Now, the history is a list which holds HistoryEntry objects. Unfortunately I don't know how to create such an object or add/append it to the list.
It's possible to add a line/list element to _history_list, but it will not follow history functionality.
I experimented with building my own list, which means doubling all of the text :-( not good.

Please, can anyone help me to append choices to the _history_list? Please!

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:10 am
by Ocelot
Judging from this documentation page: https://www.renpy.org/doc/html/history.html
you need to do something like:

Code: Select all

entry = HistoryEntry()
entry.kind = "adv"
entry.who = None
entry.what = "choice1"

_history_list.append(entry)

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:16 am
by kalesco
Thank you for your answer, it's what I had tried already.

It says "HistoryEntry not defined"

It seems I am not able to create a new instance of a HistoryEntry() :( ?

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:20 am
by kalesco
Oh. your reply was edited while I was answering...

(The code needs to be in a python block or have $ in front of each line)
Same problem:

Code: Select all

NameError: name 'HistoryEntry' is not defined.

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:22 am
by Ocelot
If it does not work, try following:
$ narrator.add_history(kind="adv", who=narrator.name, what="choice1")

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:25 am
by kalesco
That's not throwing an error so far!!
Thank you I will test it.

Do you have any insight why it's working with a character / why it needs a character?

Thank you very much for your help!!

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:29 am
by Ocelot
At first I looked how game adds new entries in history. For some reason same way didn't work for you, so I just suggested to call part of character code responsible for adding new entries directly. It worked. Something strange here, bu I cannot investigate further right now.

Re: Adding choices to _history_list

Posted: Wed May 02, 2018 9:37 am
by kalesco
it works for my game, thank you so much, you have spared me lots and lots of copied lines! :D