Event script box - line limit?

Hi all. So I'm currently working on a script which involves interacting with events on the map, which call to my script, passing the event number(event_id). I have found a rather annoying limitation in the event script box - there is a very short line limit. Anything over that limit gets placed in a second line which breaks up the script and renders it useless. So, my plan was to put this in the script box of each event that's necessary:


$arcane_circle.run($game_map.events[@event_id].id)


However when you type it in it breaks it between "events" and "[@events_id]", which gives the error "unexpected tLBRACK, expecting ')'".


After some experimentation I was able to get it to work by instead calling to a common event which goes:


event = $game_map.events[@event_id].id


$arcane_circle.run(event)


Which works fine, and is actually a bit neater so I'm happy. But I was just wondering if there's any way round this as it seems quite limiting and is possibly an issue I'll encounter in the future. Is this a common problem people have encountered? Is there a scripter's tool which works round this? (I did look!)


Many thanks!
Sounds like you don't have the latest version of the engine, which enlarged the script box a bit.


It's still not unlimited, so if you're writing something big, you should probably consider putting it in an actual script, and using a script call, instead of putting the whole thing into a script command.


Why would you use this:


event = $game_map.events[@event_id].id


This is going to the map, finding the event with id @event_id, and putting that event's id into the event variable.  You're using the current event id to get the current event id.  Why don't you just use @event_id?


$arcane_circle.run(@event_id)


You call the variable event, but it's actually the event's id that's going into the variable, so I assume your $arcane_circle.run takes an event id and not the event itself.
Like Shaz wrote, there are some issues with the code you used.


Shaz already explained them, so I will just show you how you can make your own bigger script calls into much shorter ones...

Spoiler
class Game_Interpreter

def whatever_name(*arguments_here)
# Your code goes here...
end

end

This goes into the script editor, NOT in an evented script call!


In the above example (well, more like a sample), we put a method inside the Game_Interpreter class.


Game_Interpreter methods can be run from any events just by calling the method.


So, using this in an event:

Spoiler
whatever_name(*arguments_here)

You just executed the method you coded into the Game_Interpreter class


You can make unlimited amount of methods in that class, so this way, you can shorten your more complicated script calls into one-liners.


You can also use modules in a similar way. That would have the benefit of being able to execute them from any class/module as well.


Also, you can break code lines in the script call box too, but you have to be smart about it.


You will have to do it in a way that clearly shows that there is something else coming on the next line which is still part of the code.


For example:

Spoiler
# The below code is correct, but there isn't any important line breaks.
ary = [1,2,3,4,5]
val = some_longer_method_name * (ary[$game_variables[25]] + 1)
do_something(val)

# The below code will throw an error:
ary = [1,2,3,4,5]
val = some_longer_method_name * (ary[$game_variables[25]]
+ 1)
do_something(val)

# The below code will not throw any errors, and will be executed without issues.
ary = [1,2,3,4,5]
val = some_longer_method_name * (ary[$game_variables[25]] +
1)
do_something(val)

The examples are a bit weird for sure, I didn't want to think too much on them. 😛


As you can see, the 2nd example triggers an error, because you didn't close your opened bracket on the line, and the system got no indication that it should continue looking for something in the next line.


But the 3rd example made sure that the system will check on the next line, because the last thing on the line is a + sign, which means the code should continue, so the next line will be checked.
Thanks for your help guys. Guess I was doing it a dumb way after all. I'm sorta piecing how the engine works by trial and error.


What you mention about adding methods to the interpreter is really interesting, I can see a lot of uses for that.


I have another question which is sorta-related to how events and the script editor interact with each other, if that's OK.


I'm trying, from my script, to present the player with various message boxes and options. Doing this from the event editor would of course be a breeze, but making it happen by code has stumped me. I've been looking at the game_interpreter and I can see that conditional branches are created by the @indent variable, but I can't work out how to make that happen from the script.


So far I can make make a message box and options appear with the following lines:


$game_message.add("Do something here?")
setup_choices([["Yes", "No"], 1])


And copying across the setup_choices method. But of course when you select an option it crashes, because I haven't defined what happens after.


I could probably skip this whole thing by creating a brand new scene and setting the event handlers myself, but that presents itself with other problems.
You don't need to create a new scene, just a simple selectable window.


You could pass the choices as arguments in that window class, make your commands based on that.


When the player confirms the window, store the answer anywhere you want (the default $game_variables or make your own globally accessible variable for it, doesn't matter).


After this, do your regular condition branches in the event, do different things for different answers.


Don't forget to dispose the window properly when the player made the choice also. 


I don't know how proficient you are in Ruby coding, or if you ever worked with Window classes in the engine before, so don't know how much detail you need for this. 


Check how the default Window classes work (specifically the Window_Command class), it should be a good starting point.
I'm not a nooblet with Ruby, but I'm not an expert either. Definitely getting better though. I'll give that a try then, have a play around. Thanks again.

Original thread: https://forums.rpgmakerweb.com/threads/event-script-box-line-limit.70274/