Forcing choice window to refresh?

Bricabrac

The Storyteller
Veteran
Joined
May 24, 2016
Messages
113
Reaction score
218
First Language
Italian
Primarily Uses
RMMV
Hello! I'm failing horribly at Javascript and really need your kind help.

I'm trying to make a choice window with options that will change with the press of a button.
In order to do this, I set up my "show choice" command to have variables as values, like this:

◆Show Choices:\v[99], \v[100] (Window, Right, #1, #2)
:When \v[99]

:When \v[100]

:End
I have a parallel event that changes the variables whenever I press the key and console.logs the new value, so I know that everything works. So far, so good.
My problem: the list doesn't update.

I know that I in order to do this, I should refresh the command window, so it will re-draw the choices again. But I can't seem to find the right command! I've tried Window_choicelist.refresh(); choiceWindow.refresh(); $gameScreen.update and assorted variations with no avail.
What am I doing wrong?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Try

SceneManager._scene._messageWindow._choiceWindow.refresh()

Your first attempt won't work because you're attempting to call a function from the class definition itself rather than the instance of it that exists in your game. This only works with singleton functions, such as you'll find in DataManager.

Well, to put it more accurately, calling Window_ChoiceList.refresh() DOES call the refresh function of the class (though I believe you'd also need a .prototype. for it to work and even then it'll cause errors because it's missing information that the scene will pass to it) but that function itself won't do anything because the class itself doesn't exist in your game as an object. The instance of it is the _choiceWindow property of _messageWindow, which is itself a property of Scene_Map, which is what SceneManager._scene will return when you're on the map during play.
 

Bricabrac

The Storyteller
Veteran
Joined
May 24, 2016
Messages
113
Reaction score
218
First Language
Italian
Primarily Uses
RMMV
This works flawlessly, thank you!

Your first attempt won't work because you're attempting to call a function from the class definition itself rather than the instance of it that exists in your game. This only works with singleton functions, such as you'll find in DataManager.
I feared so, but I didn't knew how to point the program to the right instance. I guess the best solution next time is to use console.log(SceneManager._scene), so I can have a list of everything that's on the screen and all their proprieties.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
As a web designer I get confused when talking about window with RPG Maker javascript, because I was going to for a moment, suggest
PHP:
document.location = document.location.href;
Which of course will "refresh" the browser page...

Somebody just PM'ed me about sending a variable to another tab and I suggested cookies or reading url parameters because I was thinking browser tabs and I don't know why.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top