Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED] Question on method call syntax and Event Spawner Script

Hi, I'm using SephirothSpawn's Event Spawner script (version 2) from his testbed v3 (i've tried it in v4, and it's also the same exact behavior), and I have a couple questions, which are probably syntax related.

So, I got the sample code to run, as long as I don't use any parameters.
Code:
Event_Spawner::Presets.sample_event_a
correctly creates an event using that method based on the default parameters of:  x=0,y=0,save=true.
Now, when I try to send some coordinates to the method, for example:
Code:
Event_Spawner::Presets.sample_event_a(3,3,true)
Then I get an error: SyntaxError occurred while running script.

This call is inside a normal action button event on a single map in a clean project with just the SDK and Event Spawner scripts added. 
For reference, here is the method header that I am trying to call:
Code:
def self.sample_event_a(x = 0, y = 0, save = true)

Now, just to make it more interesting.  If I copy the code that is in that function into my action button event's script call, as follows:
Code:
Event_Spawner.create_event(3, 3, 
'Sample Event A')
Event_Spawner.set_page_graphic
({'c_name' => '002-Fighter02'})
Event_Spawner.add_event_command(101, 
['I am a spawned event'])
Event_Spawner.end_event(true)
Then the event is indeed created at that location (3,3), but the graphic doesn't show up!

I am at a loss as to what is wrong here.
Am I calling the method wrong?  Why doesn't it show the graphic when I just copy the code into my event?
Any advice is appreciated.  Thank you for your time.
 
Well, I don't sure that you put those scripts in events function "Call Script" or in Script Editor.

Because in "Call Script", there is the limitation in length of script per line. [Its limit is 12 lines]

And in call script... This one
Code:
Event_Spawner.create_event(3, 3, 'Sample Event A')
Event_Spawner.set_page_graphic({'c_name' => '002-Fighter02'})
Event_Spawner.add_event_command(101, ['I am a spawned event'])
Event_Spawner.end_event(true)

is different from the one you posted
Code:
Event_Spawner.create_event(3, 3, 
'Sample Event A')
Event_Spawner.set_page_graphic
({'c_name' => '002-Fighter02'})
Event_Spawner.add_event_command(101, 
['I am a spawned event'])
Event_Spawner.end_event(true)

Because RMXP will think that they're in different line.

So you can keep text in variable first, e.g.
Code:
t = "I am a spawned event"
Event_Spawner.add_event_command(101,t)

========================
I hope this help~^^

==============================>
Edited: Read your post again and found out that you called it in event~
 
Thanks for your response!  After some experimenting, it does help, and brings up more question marks.

The reason the lines are cut off is because I copied it directly from the script box in an event.  They are all technically on the same line, the box just isn't wide enough to show it.

So, I made a new script in the script editor, defined a simple method, and called that instead of having the script directly in the event box.  And that worked!  The graphic showed up.  So I added parameters to that function, and so I can now do what I want.  I also found that the preset function works when it is inside the script editor, and not an event box.

So, my problem is solved.  Thank you!  But I do want to know why I couldn't put it inside an Event's Script box?  It wasn't over the 12 line limit you mentioned.
 
The problem you got is not about 12 lines problem, but it is about the limit of script's length in 1 line on 'Call Script'.

I've the way to fix that though, so just PM me if you're interesting~
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top