pop-up text events

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
Hi all.


I have been trying to create an event so that when a player approaches a door (to a shop, for example) a text box appears saying something like 'weapon shop' at the top of the screen. That alone is obviously very simple, but I'd like to set it up so that the player doesn't have to hit the enter key to remove the box. Instead the enter key will cause them to enter the shop. If the player does not want to enter the building then they can continue to move as normal. I tried setting up a 'player touch' event outside the shop that runs a common event as a parallel process (if player is facing 'up', then show message), but it gets stuck on the message. I'd like the player to be able to move out of the square without pressing the enter key.


Is this possible with normal eventing? Any suggestions would be very welcome!


Thanks.
 

SaburoX

Veteran
Veteran
Joined
Jan 27, 2013
Messages
87
Reaction score
8
Primarily Uses
By default you can set text to skip to the next message by adding a \^ to the end of a message.  If there's no next message, it effectively just has the one line appear and disappear without the player needing to do anything further. If you want the text to be instant you add a \> at the beginning of your  text and a \< at the end. There are also wait codes of \.  and \| to add waits to the text (15 frames and 60 respectively) so it doesn't disappear to quickly, you'd add those before the skip code. 


Put it all together and you'd have a show text that reads something like

\>Blacksmith\<\.\.\^
That would have a text window that says "Blacksmith" immediately (without the word being spelled out a letter at a time), that hangs around for half a second (or 30 frames) before disappearing.


If you wanted to get a little fancier and use a script. Yanfly's Event Window may work for your purposes if you used its script call in tandem with a player touch event in front of each door. You'd end up with additional functions that would probably need to be commented out provided you didn't want them, though.
 

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
awesome. I forgot about the wait codes. I'll try that.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@SaburoX using that will let the game wait until the message is disposed and so you keep being stuck in front of the door while the message is displayed (30 frames in your case). While it is a short time the player is still stuck in front of the door for that time.


@gsuk what you want to achieve is possible via normal eventing but you need to use the "script call" command in the 3rd page.


I would do this using the shop door event and a parallel process like this:

  1. Set your event first page priority to be "Same as Characters" and trigger to be "Player Touch".
  2. Set your event second page to be the real door event (you can use the one generated by default or you can create one).

Now that you have your two pages event you have to edit the first page. Add a script call command and write this:



@shop_name = "Blacksmith"
$shop_name_window = Window_Base.new(0, 0, Graphics.width, 72)
$shop_name_window.draw_text_ex(0, 0, @shop_name)
$game_switches[insert_number] = true


You can change the shop name as you need and you can set the switch ($game_switches[insert_number]) by changing insert_number with a real number.


Example: $game_switches[1] will trigger the switch number 1


Now let the event store player X and Y in two variables (Control Variables -> Game Data -> Player Map X. The same goes for Player Map Y). In my example I'll use X as the variable id where player x is stored and Y for whe one containing player y. Remember to change them with real numbers.


Once you did this move to your second page. If you did everything fine it should appear as a normal door event. Set a condition for that page and set that condition to be the switch you used in the first page. Now you have to add another script call command and write the following:



$game_switches[insert_number] = false
$shop_name_window.dispose


Now your door event displays a text with the shop name and it is deleted when you enter the shop.


Here we are...now you are walking, your event displays your shop name and you decide to not visit the shop and go away...



But...wait! When I don't want to enter the shop the window with the shop name doesn't disappear!
Don't worry, we are going to fix this too. Create another event (Parallel Process this time) and set a a condition for that one. Its condition will be that the switch you used is on. If you are going to use this trick for EVERY shop I would say to create it as a common event.


In your parallel process use a script call and write this:



@same_x = ($game_player.x == $game_variables[X])
@same_y = ($game_player.y == $game_variables[Y])
unless (@same_x && @same_y)
$game_switches[insert_reset_switch_number] = true
$game_switches[insert_number] = false
end


"insert_number" is the switch ID of the switch you used in your door event. "insert_reset_switch_number" is the ID of a new switch we're going to use to reset our events. This event basically turns itself off when the player moves and activates a reset switch.


Now we have our parallel process event. The last thing we have to do is to add a third page to our door event and set it to be a parallel process (don't forget the door graphic or it will blur). The condition for this page is that the switch you decided to use to reset is ON.


Add a script call here and write this:



$shop_name_window.dispose
$game_switches[insert_reset_switch_number] = false


This will dispose your shop name window and turn off your reset switch allowing you to go back to your first event page.



I hope this was helpful. I didn't test it and I didn't provide any image because at the moment I can't. As soon as I can I will edit this post adding images.


However if you want to know how to effectively use script calls to create windows you can take a look at this tutorial. In my opinion it is a really good one.


EDIT: you have to call the window as a global variable using $shop_name_window instead of @shop_name_window. Apparently the parallel process cannot access instance variables. This also means you can put $shop_name_window.dispose in your common event without having to use a third page on your shop event. Up to you if you want to do it or not but if you do you have to change a few things.
 
Last edited by a moderator:

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
thanks so much for that. I came back to this thread to say exactly that - the player has to wait the 30 frames.


The other thing I'd like it to do is say, for example, 'Blacksmith Press action button to enter shop'. I want that message to remain on-screen until the player moves out of the square (solved) or presses the enter key (so they enter the shop). Currently, pressing enter only removes the message and you have to press it again to enter the shop using the normal action button event on the door (does that make sense?). Is there something in the script call that could be added to allow this feature?


To clarify: when I stand facing the shop door (not just walking past) a message appears saying the above and remains on screen. If player walks away, the message disappears and play continues as normal. If they hit Enter, they enter the shop.


I also have LOTS of doors on many maps. Hopefully I won't need too many extra events thus causing the game to run slowly.


Thanks for putting the time into your reply - I was actually expecting only 'thats not possible without a script.' :D
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
In my solution you have to walk in the door direction instead of pressing enter but it is the same as you described. If you want to do it by pressing the action button change the trigger of the door event's second page in my previous answer to "Action Button" instead of "Player Touch". That's enough to do the trick.


EDIT: in my previous post there is an error because a parallel process apparently cannot access instance variables. Instead of using @shop_name_window in your script call use $shop_name_window. I'll edit that one too.
 
Last edited by a moderator:

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
Hi.


I tried the method you gave but am having problems. I tried it with one door. I've attached screenshots of the events. Here's the situation:


The door is to a house (called Stableview). The switch numbers I have used are 622 (for the first game_switch ID - I called it StableviewDoor) and 623 (for the reset switch - I called it SVdoorReset).


Variables 302 and 303 are for the event that gets the XY position of the player.


Instead of having the player need to 'push' the door by walking into it, I put the event in front of the door so the message pops up when they stand on the square rather than a player touching the door (so page 1 of the event is Below Character rather than Same As Character).


I think I have set up the events correctly, but as soon as I exit the house (player starts the game in the house) I get the following error message:


Script 'game interpreter' line 1411: NoMethodError occurred.


Undefined method 'dispose' for nil:NilClass.


Is there an error in my eventing?


Thanks

Door page1.png

Door page2.png

Door page3.png

getXYevent.png
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Create another event (Parallel Process this time) and set a a condition for that one. Its condition will be that the switch you used is on.


The error is quite simple: you didn't set a condition for your parallel process. It has to run ONLY when your window is active (which means your switch "StableviewDoor" must be on).


Everything else seems fine. If you fix this it should work.
 
Last edited by a moderator:

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
That's awesome! It works now. Thanks so much - you're a legend!


Can close thread.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top