Fullscreen Choices

Hiya and thanks for listening.

1. How can I change the size and position of a Choices window? I am using Yanfly plugins, so any plugin solution would have to play nice with those. Script is fine as well.

2. Is there a way to call a new Choices window in response to one of the choices? I have been fumbling around with this code:

Code:
test_choice = function () {
    $gameScreen.showPicture(1, "Event_1_bg", 0, 0, 0, 100, 100, 255, 0);
    $gameMessage.add('Select');
    $gameMessage.setChoices(['Give another choice', 'Bye'], 0, -1);
    $gameMessage.setChoiceCallback(function (choice) {
        if (choice === 0) {
            //ANOTHER MOSTLY IDENTICAL FUNCTION
            test_choice_2();
        }
    });
}

However, test_choice_2 will run the picture code and do nothing else. I'm guessing that somehow making a choice closes the Choice window, and the callback happens before that, or is in some other way blocked during that process. I know you can do this through the event system, but I'm not sure how to replicate this in script.

Ultimately, what I'm trying to achieve is game that moves from full-page choice to full-page choice, I guess something like a visual novel, with occasional shifts to battles and back to choices. I've had to scale this idea back repeatedly and this is the smallest version I can think of, but I'm still stuck.
I think your biggest problem comes from using script functions instead of event commands.

the event commands are integrated into the main game loop with flags and tokens, but in the script functions you have to do all that manually.

as a result it is extremely easy to use a show choice inside another show choice when using events.
but with the script functions, you need to time your commands inside the game loop to have multiple commands in sequence instead of the game loop interpreter only processing the last command given in a single frame.

I strongly suggest you try to do the same with event commands first before deciding which place and where you want to use script functions.
I think your biggest problem comes from using script functions instead of event commands.

the event commands are integrated into the main game loop with flags and tokens, but in the script functions you have to do all that manually.

as a result it is extremely easy to use a show choice inside another show choice when using events.
but with the script functions, you need to time your commands inside the game loop to have multiple commands in sequence instead of the game loop interpreter only processing the last command given in a single frame.

I strongly suggest you try to do the same with event commands first before deciding which place and where you want to use script functions.
For readability, let's define an 'encounter' as a discreet moment in the game with a unique background, dynamically allocated choices, and the ability to move to either another encounter, battle, or game over state.

My intention is to have encounters generated semi-randomly according to prior encounters and scripted logic. If the game starts at Encounter A, B, or C, then moves on to A, B, C, D or E, minus whichever was picked before, I'm already quite deep into event branches. I admit I could probably do this unless there is some finite limit on the steps in the eventing page, but it would be an immense page.

I am hoping there is a better way. I don't necessarily need to use Choice windows, but I have spent a few months working on this from various angles and I can't get anything to work cleanly. Yanfly's Common Event Menu is spot on, but again, I can't dynamically create entries.
I'd consider giving each scenario a unique "ID" number, then organising the event along these lines:
Give each "box" on the tree a number and use a variable to keep track of where you are. Use Control Variables to set a variable's value, and Conditional Branch to check that value. Then you can have it all inside a Loop, with Break Loop to end the dialogue when appropriate. It's more involved, but I think it's a neater solution overall! 😂
Spoiler: Event example - variable
Code:
◆Control Variables:#0018 DialogueStage = 1
◆Loop
  ◆If:DialogueStage = 0
    ◆Comment:End dialogue.
    ◆Break Loop
    ◆
  :End
  ◆If:DialogueStage = 1
    ◆Comment:Intro
    ◆Text:None, Window, Bottom
    :    :You don't look like you're from around here.
    ◆Show Choices:I've lived here all my life!, I came here from Newton. (Window, Right, #1, #2)
    :When I've lived here all my life! 
      ◆Control Variables:#0018 DialogueStage = 2
      ◆
    :When I came here from Newton. 
      ◆Control Variables:#0018 DialogueStage = 3
      ◆
    :End
    ◆
  :End
  ◆If:DialogueStage = 2
    ◆Comment:Mr Bowler
    ◆Text:None, Window, Bottom
    :    :Oh really? Then you must know Mr. Bowler.
    ◆Show Choices:Mr. Bowler is a good friend of mine!, Who? (Window, Right, #1, #2)
    :When Mr. Bowler is a good friend of mine! 
      ◆Control Variables:#0018 DialogueStage = 4
      ◆
    :When Who? 
      ◆Control Variables:#0018 DialogueStage = 5
      ◆
    :End
    ◆
  :End
  ◆If:DialogueStage = 3
    ◆Comment:Newton news
    ◆Text:None, Window, Bottom
    :    :Newton, eh? I heard there's trouble brewing down there.
    ◆Show Choices:I haven't heard about any trouble., Did I say Newton? I'm actually from Springville. (Window, Right, #1, #2)
    :When I haven't heard about any trouble. 
      ◆Control Variables:#0018 DialogueStage = 5
      ◆
    :When Did I say Newton? I'm actually from Springville. 
      ◆Control Variables:#0018 DialogueStage = 2
      ◆
    :End
    ◆
  :End
  ◆If:DialogueStage = 4
    ◆Comment:Liar!
    ◆Text:None, Window, Bottom
    :    :You liar! There ain't no Mr. Bowler, I made him up!
    ◆Control Variables:#0018 DialogueStage = 0
    ◆
  :End
  ◆If:DialogueStage = 5
    ◆Comment:Huh?
    ◆Text:None, Window, Bottom
    :    :Don't you worry about it. Say, do you have something
    :    :to eat? I'm starving.
    ◆Control Variables:#0018 DialogueStage = 0
    ◆
  :End
  ◆
:Repeat Above
This allows a single variable, recalculated at the end of each scenario, to determine the game progression.
I'm not sure I understand. I need to determine the next encounter semi-randomly, at the time the game moves to the next encounter. I would liken this less to a tree and more to a deck of cards. However, the rules for determining the next encounter are complex (random from a subset of the overall pool, not three encounters back-to-back, no repeating encounters, etc.)

I had also intended on determining some of the choices programmatically. For example, if an encounter offers an item or a heal, changing the 'item' choice text to name the offered item.

I understand the event system can offer a lot and I even went through it with a more experienced user when I first started, but my mechanics required some scripting. It seems like I would lose some necessary functionality if I try to do this primarily through event.

I am hoping to find a solution that meets my project where it is - using scripts to initiate encounters.
The structure I suggested simply allows you to jump from one scenario to any other, so you can avoid all that nesting (and duplication). It doesn't matter how you choose to calculate the value of the variable. You could use rocket science and braid theory as long as you end up with an integer value corresponding to a scenario ID. 😅

Also, it is not necessary to script choices simply to change their text. You can store an item name in a variable and reference that variable in the choice text using the \v[x] text code, e.g.
Spoiler: event example - get item name
◆Text:None, Window, Bottom : :Pick an item! ◆Select Item:Input, Regular Item ◆If:Input > 0 ◆Control Variables:#0006 Text = $dataItems[$gameVariables.value(1)].name ◆Text:None, Window, Bottom : :You selected item ID \v[1]. : :This item is called "\v[6]". ◆ :Else ◆Comment:Select Item was cancelled. ◆ :End
(The "Input" variable here is var ID 1, in case that was unclear.)

If you're determined to try the pure-script thing then I recommend adding a line like this at the end of your function(s):
JavaScript:
interpreter.setWaitMode('message');
This tells interpreter (which you'll need to replace with a valid event interpreter reference) to wait until the player makes a choice. Hopefully that'll solve your problem, otherwise you might need to manually add commands in the appropriate format to the interpreter instead. 👋

You may also want to include these lines for display consistency (replace the bgType/posType arguments with 0, 1, or 2 for the different options, more details here):
JavaScript:
$gameMessage.setChoiceBackground(bgType);
$gameMessage.setChoicePositionType(posType);
Some ideas for getting an interpreter reference (only need 1):
  1. Define your functions as methods of Game_Interpreter.prototype then use this in the functions.
  2. Use this in a Script command, then pass that in as a function argument.
  3. Refer to the main map/troop interpreter, $gameMap._interpreter/$gameTroop._interpreter (will probably go wrong if you use your functions in a Parallel event).
[Edit: added link to "more details here"...]
Currently, I'm trying to pass my script through a common event and reserve it. That way the Choice has to close and finish before it runs the script, which can just be a function that tells my own code what to do next. I really don't like getting in the way of a queue like that as it seems like a fast track to intermittent errors, so hopefully that puts me back in the queue in a responsible way.

I'm open to your eventing suggestion, but reading through it I'm not sure if it applies to my case. If I'm reading it right, it opens a menu to allow the player to choose an item, then sets a variable according to that selection in order to retrieve that a moment later and offer dynamic text describing the item.

That's getting pretty close, but I need the selectables themselves to be named dynamically. I can feed that info to the eventing system from my script, but I don't know how I would store strings and how I would adjust the Choice appearance.

Thanks for talking through this with me.

Original thread: https://forums.rpgmakerweb.com/threads/fullscreen-choices.147424/