how can i start battle by script?

if i want start battle troopID(1),
I thought it would work if I write 'BattleManager.setup(1, false, false);'. But nothing happened.
Why are you needing to start it by script? There is an event command to do it.

This is what the event command does, once it has the troop id:
Code:
            BattleManager.setup(troopId, params[2], params[3]);
            BattleManager.setEventCallback(n => {
                this._branch[this._indent] = n;
            });
            $gamePlayer.makeEncounterCount();
            SceneManager.push(Scene_Battle);
Oh nice! Thank you very much. Of course, it can be simple, but I tried to make something with TropID as a variable. Anyway, I checked that it was working. 🙂
Well you would just replace troopId with $gameVariables.value(n) in the first line, where n is the id of the variable you want to use, with no leading zeros. It's the setting of the callback that might cause an issue. But I suppose if you do it in a Script call within an event, it might still work.
Just to be clear: the Battle Processing command has a "designation with variable" option, so you don't need a script call for that~ 🙏
but I tried to make something with TropID as a variable.
why bother? the event command already has a variable option for exactly that
its actually easier to use the event command "battle processing" with a variable than to enter that varable by script

EDIT: ninja'd
Oh, I know that. What I was going to do was work for convenience. Because I wanted to have different monsters with different weights on different maps and come out probabilistic according to the weights, after I went through JavaScript calculations, to have a battle according to the probability. I couldn't explain in detail because I was not good at English. (If you can't understand this article, I'm sorry. T.T)
OK, that explains what you are thinking - but what has us confused is why you think javascript is a convenience here.
The default encounters are already weighted, and allow all that without even once touching javascript.
In fact using javascript in what you describe is as someone wanting to travel from Paris to Brussels by first flying to New York and then taking the shortcut through Peking and Moscow...
Because I didn't use the basic encoder. I use the symbol encounter. I needed something to apply collectively to many events. 🙂
if there is an easier way, but if I don't know, I apologize. T_T

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-start-battle-by-script.131426/