Using a Common Event [review please]

Hi all.

 

So I'm still learning what I can do... Here's what I've done tonight, I was wondering if anyone would review how I've gone about things and suggest any better ways. This solution works, but is the best way? I don't know.

 

 

My Aim: have an area in the middle of my map (a room). Make this an area where if the user presses the action button, the rooms description or a cryptic clue is displayed.

 

What I didn't want to do is create an event and copy/paste it over a heap of tiles. that just seemed lazy and inefficient.

 

 

How I have done it is placed a set of Region1 ID's in the middle of the room, created a parallel process that when it detects my player is in the RegionID, moves the RoomDescription event and places it under the Player

 

For the first room, I wanted the Player to get a notification and a hint to say "Hey, look around" Here's what I've done so far for the first room (Which is working):

 

 


Code:
Event: EV001 Trigger: Parallel Process on Autorun

Control Variables: [0003:PlayersX] = Player's Map X
Control Variables: [0003:PlayersY] = Player's Map X

Conditional Branch: Script: $game_player.region_id == 1
     Show Balloon Icon: Player, Light Bulb

     Conditional Branch: Variable [0001:Helped] == 0
          Text: The centre of a room is a good place to
                Press [Action button] to look around
          Control Variables: )0001:Helped] ++1
     Else
     Branch End
Set Event Location: [RoomDesc], Variable [0003][0004]
Else
Branch End
Wait 5 Frame(s)

and a simple event for the room text

 


Code:
Event: RoomDesc Trigger: Action Button
Text: The room's text goes here

 

For every other room, i don't want to display the light bulb or the text, I just want to move the event.

 

So I thought, this is probably best suited to a Common Event as I don't want to copy/paste and edit this for every room... 

 

I changed my Autorun to have:


Code:
Control Switches: [0003:RoomText] = ON
Call Common Event: [RoomInfo]
Control Select Switch: A =ON

 

and set up the Common Event

 


Code:
CommonEvent: RoomInfo. Trigger Parallel Process. Condition Switch 0003:RoomText

Control Variables: [0003:PlayersX] = Player's Map X
Control Variables: [0003:PlayersY] = Player's Map X
Conditional Branch: Script: $game_player.region_id == 1
     Set Event Location: [RoomDesc], Variable [0003][0004]
Else
Branch End
Wait 5 Frame(s)

 

WOOHOO. This worked.

 

so what I am left with is creating an event called RoomDesc on every room and setting up the text inside it.

 

Based on the fact that word wrapping doesn't exactly play a part of the text boxes, I assume that this is the best way for me to put in my room info and have decent control over how it looks.

 

I considered if it was a possibility to have the parallel process create a RoomDesc event in the map when the player enters it and populate it with the text for the room from scripts - but this doesn't seem feasible.

 

or is it?

 

Have I gone about this the right way? Is there a better way to do this?

 
A Common Event is the right idea, to avoid having to repeat the same event dozens of times. 

What you can do is put the text into a Variable (they can store anything, not just numbers) using a script call like:

$game_variables[3]="This is some text"

Then, when you use \V[3] that will display the text "This is some text."

So you can store one line of text each in a single variable, then print one variable per line.  I know the text boxes don't automatically word wrap on their own, which is why I don't recommend having one variable with all of the text.  So your script call would look like this:

$game_variables[3]="This is my first line"

$game_variables[4]="This is my second line"

Then you just add \V[3], hit Return and add \V[4] for the next line.
Thanks whitesphere.

As this is my first play with the software and i've had it less than a week still, i'll go without placing the text in variables for now and just keep it in mind for something I can do. thanks for the info on how to implement.

Thanks for checking that I'm using the common event correctly. Much appreciated.

`Andy.
I've found a problem with the common event... Not sure if there is a way around it.

I figured "hey, perhaps I could add to this to make the room exits, rather than copy an event over and over to match the width of a doorway.

So I added an event ExitNorth - a standard player touch and Transfer Player event. Across my exit I placed Region60

all fine.

until I went to the next room, added copied in ExitNorth, set a new destination and then made an ExitEast and assigned it Region61.

I went into edit the CommonEvent and it updated all the event names based on the events in the new room.

For example:

The CommonEvent read: Set Event Location: [ExitNorth], Variable [0003][0004]

After editing that line became: Set Event Location: [], Variable [0003][0004]

Another event became: Set Event Location: [Ev009], Variable [0003][0004]

After a bit of testing it seems to be that, if I want to use this CommonEvent in all my rooms to control the exits using Regions, I have to keep the Name and Order of the events the same in every room.

I can see that it is doing this because when I add the Set Event Location, it brings up the list of events as 005:ExitNorth, 008:ExitEast etc... yet on a different map this displays as 001:ExitNorth, 002:ExitEast...

So for example, when I create a room I would need to create 4 events for ExitNorth, ExitEast, ExitSouth, ExitWest in order so the background eventID would be 001, 002, 003 and 004 so if I ever edit the CommonEvent the mapping doesn't get messed up.

While this can be done of course, its a pain and doesn't leave room for much messing around as I go and deleting and creating events on whim...

A solution to this problem would be to not use the Set Event Location command, but rather use a script to trigger that command, with the script referencing the name of the event regardless of the eventID.

This would allow me to use a common naming schema for my events but not have to worry about the eventID in the background.

Is this possible? Have I made sense?

Original thread: https://forums.rpgmakerweb.com/threads/using-a-common-event-review-please.36539/