Problems with script in event

Hey there,


Im pretty new to RPG Maker and new to this forum as I only made an account to get help with this problem that i can't find a solution for anywhere. (PS sorry if this is posted in the wrong place)


So basically whenever I am adding a script to an event and I write into a new line it makes the script unusable. Pictures of whats happening may help:


When I write the script and it goes onto a new line:

Spoiler
cap1.PNGcap2.PNG



When I write a script and it doesn't go onto a new line:

Spoiler
cap3.PNGcap4.PNG



The scripts only ever work when i write it over one line because for some reason it adds extra characters where I do not when its goes over multiple. I dont know if im missing something obvious here but I i have no idea what to do. Any help would be appreciated 🙂
1) the event command script is controlled by the Game Interpreter class, and it can only use commands that are available inside that class. you cannot call script commands unless they were given to the game interpreter. And that requires extra line in the script itself in the script editor, which is why usually all scripts list the commands they enabled for use in the events.


2) a new line usually breaks the script command, unless it is made in a way that the interpreter understands that something will follow on the next line.


This means you either have to use temporary variables to store halfway results for the next line, or be very careful where to insert manual linebreaks in a way that the interpreter understands the command continues (the automatic linebreak positions almost never work here)
If you use a constant for an argument, that is really doing nothing productive as an argument at least.


The point of arguments is that they can be changed to whatever and based on them, the method returns different values.


Now, if you pass a constant as an argument, it loses it's point, so you can simply move that constant to the method itself and get rid of that argument.


That can shorten the script call you make in events as a bonus.


In any case, like Andar wrote, you must break the line in a way that the engine knows that there will be something coming on the next line.


In your example, it would look like this:


Kernel.pbReceiveItem(
PBItems:😛okeBall,5)


But removing that constant from there and including it directly in the method would make that look like:


Kernel.pbReceiveItem(5)


Which is much shorter, and there is no need to needlessly copy/paste the same argument over and over again.


To make a little correction for what Andar wrote in point 1, you can use module methods from anywhere in any class/module, so you can use what you wrote from the interpreter without any issues. Methods called on global variables can also be used freely.

Original thread: https://forums.rpgmakerweb.com/threads/problems-with-script-in-event.66819/