Help with script calls

Hey guys..

I'm very new to using script calls so I'm sure this may look ugly to those who know what they're doing lol. if someone could help me out and fix this script that would be amazing. I'm definitely doing something wrong, i just dont know what. I'm trying to call this script as a common event.

SCRIPT:

if ("$dataEnemies[4].isStateAffected(11)") { $gameScreen.showPicture(1, IMAGE01, Upper Left, 0, 0, 50, 50, 255, Normal) $gameInterpreter.wait(120); $gameScreen.erasePicture(1); "$dataEnemies[4].removeState(11);" }



Thanks so much for the help!
Dave
How are you calling it as a common event? Common events set to autorun/parallel process don't run during battle, unless you've got a script/plugin to cause it. So the only way you'll get that to run is by attaching it to an item or skill.

Why are you doing it all as script calls? Everything you have there can be done with event commands.

Get rid of all the quotes around things. The only thing you need quotes around is the image name, and that's the one place where you don't have them.

But why are you doing it all as script calls?
Exactly, I'll be running this common event by attaching it to a skill.

To make a long story short, the reason for this being done all as a script call is because usually I would want 10+ pictures display one after the other. These images will be determined by which enemy is affected by the state checked in the code. Rather then tediously adding event commands for every single enemy, I would rather write the script call in an external text editor and be able to replace the image names MUCH faster by simply using a text replacement function.

Anyway!! I tried what you recommended and im still getting an error when I call the script. I removed all the quotes in the script except I added them around the image name.

Here's the code with the edits..

if ($dataEnemies[4].isStateAffected(11)) { $gameScreen.showPicture(1, "IMAGE01", Upper Left, 0, 0, 50, 50, 255, Normal) $gameInterpreter.wait(120); $gameScreen.erasePicture(1); $dataEnemies[4].removeState(11);}

I'm getting the error

"SyntaxError
missing ) after argument list"
You can still do all the other commands as event commands.

Upper Left and Normal are not valid options. Put 0 instead. Also put ; after the showPicture command and before the wait command.
if ($dataEnemies[4].isStateAffected(11)) { $gameScreen.showPicture(1, “IMAGE01”, 0, 0, 0, 50, 50, 255, 0); $gameInterpreter.wait(120); $gameScreen.erasePicture(1); $dataEnemies[4].removeState(11);}

Now getting the error
SyntaxError
Invalid or unexpected token
Just do it with events. Use a script call for the show picture if you have to, but do the rest with events. In the time you've taken to do all this testing, come here for help, wait for help, and try again only to have further issues, your common event could have been finished and you could have completed other stuff as well.
I agree with Shaz, looks like this can all be done with much less bother using event commands. 😅

For education's sake, though:
  • $dataEnemies refers to the database data; the enemies you face in-game are "instances" of enemies from the database. I think in this case it should be $gameTroop.members()[4]
  • $gameInterpreter doesn't exist. On the map, the main interpreter is tied to $gameMap; in battle it seems to be a member of $gameTroop ($gameTroop._interpreter). I've had a bit of trouble before when trying to use wait in a script, though, so your results may vary...
  • For readability's sake: put each line of code on its own line! 😅

Original thread: https://forums.rpgmakerweb.com/threads/help-with-script-calls.92213/