Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Location Name Pop Up, Similar to Chrono Trigger Style
drykul
post Oct 6 2008, 08:17 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Ok, I'm trying to teach myself RGSS2 and one project that I've been working on is having a string of text appear when the character is at a certain X, Y coordinate, and having it dissappear when he's not, much like the Chrono Trigger location names. With a combination of Eventer's Toolbox script and an event with a conditional branch to call, I have this code:

CODE
class Loc_Window
  def initialize(location)
    @loc=location
    @location_name = Sprite.new
    @location_name.bitmap = Bitmap.new(200,32)
    @location_name.x = (544/2)-100
    @location_name.y = 416-32
    @location_name.bitmap.clear
    @location_name.bitmap.draw_text(0, 0, 200, 32, @loc.to_s, 1)
    update
  end
    
  def update
    @location_name.bitmap.clear
    @location_name.bitmap.draw_text(0, 0, 200, 32, @loc.to_s, 1)
  end
      
  def dispose
    @location_name.dispose
  end
end


Now, the text draws on screen perfectly fine when the character is in the specified X, Y coords set by Eventer's Toolbox, but I can't figure out how to call the dispose method if the character moves from that particular coordinate. The event I'm using is a parallel process:

CODE
Conditional Branch: $game_map.standing_on_tile?(38, 6)
    Script: $class=Loc_Window.new("My Place")
else
end


I guess I don't remember how to call the dispose method for this.... or I'm just missing something, but $class.dispose doesn't work.
Go to the top of the page
 
+Quote Post
   
BigEd781
post Oct 6 2008, 09:39 PM
Post #2


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




That should work, add the dispose call in the else branch. It's not going to look very good though. I would recommend inheriting from Window_Base. You can use a custom windowskin and you don't have to manage your own sprite.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 7 2008, 06:25 AM
Post #3


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Well, I kind of fixed it. When I had $class.dispose in the else condition, whenever the map with the parallel process running would load, I'd get a no method error. Apparently that was because it was trying to call the dispose method of the $class or Loc_Window which hadn't been initialized yet. I fixed this by in the beginning of the parallel process calling $class = Loc_Window.new(""), but that doesn't seem like a very good fix for the problem. If there is another way, I can't think of it. And also, after the player steps off of the given coordinate, the window does get disposed, but there's a few second delay. I assumed that it would detect as soon as the player wasn't on the coordinates anymore and then dispose, but there seems to be a delay for some reason. How can I fix that?
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 7 2008, 06:54 AM
Post #4


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Well, I found a temporary fix that I really don't like. I put on touch events all around the area to show the window with $class.dispose called in the event.... surely there is a better way to do this?
Go to the top of the page
 
+Quote Post
   
BigEd781
post Oct 7 2008, 08:47 AM
Post #5


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




The best way to do this would be to override/alias some methods of the Scene_Map class so that the location window is displayed when you enter a new map. I know this is a practice script, but it would be better to integrate it fully into the engine.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 7 2008, 06:51 PM
Post #6


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Well, that would work except I also want the name of the possible location to appear before the player actually has to transition to the new map, like the player stands just outside an inn before opening the door and the name of the inn appears before the player actually goes in. Going in is easy enough because I can just call the dispose method before the transition, but if the player decides not to go in, I'm trying to figure out how to dispose of the location name "window". That's why I have events that dispose the location name "window" set up on any possible place to move around the event that calls the window. But that's 4 different events just for one location window... there has to be a more feasible way to do this, but I keep getting infinite loops because I tried setting up a loop to keep track of the player's x, y coords and if its not the same as the event that calls the window, then it disposes, but since it has to keep looping and reestablishing the player's x and y, it just infinite loops. I've tried with a parallel process, and the same thing happens... I'm stumped.

I'll make a SS explaining what I'm trying to do better. I'm not really good at explaining things, so maybe a visual aid would be better.

This post has been edited by drykul: Oct 7 2008, 06:53 PM
Go to the top of the page
 
+Quote Post
   
jens009
post Oct 7 2008, 07:06 PM
Post #7


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




It would be really best if you inherit this map name from Window_Base since the basic functions of creating a sprite within a window are already present.
Now as for your problem in checking the player's coordinates, don't check them by map coordinates but rather check them by screen coordinates.
You can have a loop that constantly checks if the player's coordinates are within the window's coordinates (x+width and y + height). You can add this check under def update in Scene_Map.

I haven't tested this yet but I've done this before for a script request.
CODE
if @player_x >= (@map_window_x) and @player_x <= (@map_window_x + window_width)
if @player_y >= (@map_window_y) and @player_y <= (@map_window_y + window_height)
# HIDE WINDOW HERE
end
end

All the code says is to hide the window if the player is within the window box.

the code snippet above most likely needs debugging since I've just thought it up without really checking if actually works or not. But I hope you get the idea.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 7 2008, 07:46 PM
Post #8


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Ok, let me see if I got this straight.

CODE
if @player_x >= (@map_window_x) and @player_x <= (@map_window_x + window_width)
if @player_y >= (@map_window_y) and @player_y <= (@map_window_y + window_height)


just checks to see if the player is within the specified box, and if it is, then I can have it display the window, and if not, then the window will not be displayed. What is the function for checking screen coords?

Or are you talking about making another window on the spot where I want the player to be when the name appears just for the sole purpose of checking to see if the character is in that window? Hmm, I'm a bit confused. I think I'll try making that window and see how that works out. Please tell me if I misunderstood what you mean.

Well, not sure how the screen coordinate thing will work because the screen can scroll, it's not small enough to fit all in one screen, so if I have a check on a screen coordinate at say 200, 200, then the name will appear when I hit the 200, 200 spot on the screen coordinate regardless if the map is in the right place or not, right?

This post has been edited by drykul: Oct 7 2008, 07:52 PM
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 7 2008, 07:59 PM
Post #9


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




Well, here's what I got that works the way I want it to temporarily, but as I said before, there's got to be a better way to accomplish what I'm trying to do.



***Note*** Also, when this map loads, I had to create a parallel process event that ran
CODE
Script: $class=Loc_Window.new("")

to avoid getting a no method error.

This SS in conjunction with this script:
[Show/Hide] Script Code
CODE
class Loc_Window
  def initialize(location)
    @loc=location
    @location_name = Sprite.new
    @location_name.bitmap = Bitmap.new(200,32)
    @location_name.x = (544/2)-100
    @location_name.y = 250-32
    @location_name.bitmap.clear
    @location_name.bitmap.draw_text(0, 0, 200, 32, @loc.to_s, 1)
    update
  end
    
  def update
    @location_name.bitmap.clear
    @location_name.bitmap.draw_text(0, 0, 200, 32, @loc.to_s, 1)
  end
      
  def dispose
    @location_name.dispose
  end
end




does exactly what I'm trying to do. But very inefficient. And I don't want to have to make 3 extra events for every area that I want to use this script just to dispose of the window.

This post has been edited by drykul: Oct 7 2008, 08:04 PM
Go to the top of the page
 
+Quote Post
   
jens009
post Oct 7 2008, 11:07 PM
Post #10


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (drykul @ Oct 7 2008, 08:08 PM) *
Ok, let me see if I got this straight.

CODE
if @player_x >= (@map_window_x) and @player_x <= (@map_window_x + window_width)
if @player_y >= (@map_window_y) and @player_y <= (@map_window_y + window_height)


just checks to see if the player is within the specified box, and if it is, then I can have it display the window, and if not, then the window will not be displayed. What is the function for checking screen coords?


Yup. That's right. Your definition of screen is different from my definition of screen. The way I see it, is the screen is as is. It doesn't matter how big the map is or how much the "screen" moves. THe screen is still as is.

As for figuring out how to get the player's x and y, you should check the super classes for that information. I don't have VX right now so I can't really check for you. That or you can use VX's RGSS help file.

@ Visual Image: That's a really inneficient way to do things. Instead of having triggers to close the window, you should instead make a visual timer to show the Location name for x amount of seconds and slowly fades away.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
drykul
post Oct 8 2008, 07:40 AM
Post #11


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Beginner




OMG, a timer... what the hell. Why didn't I already think of that... that is the answer to my problems. Thank you SO much. I've been trying to think of a better way to do this for a couple days now, and with one simple statement, you've shown me the light. Much appreciated. And if this sounds sarcastic, I assure you, it's not in the least. I think maybe I was just thinking too hard to figure out how to check if the player wasn't at the specified coords to dispose the window and I couldn't fathom an alternative. Wow, I feel so stupid now, lol. But that's learning, right? Thanks again!
Go to the top of the page
 
+Quote Post
   
krotchmaster
post Jan 5 2009, 07:51 PM
Post #12


Level 2
Group Icon

Group: Member
Posts: 22
Type: Event Designer
RM Skill: Advanced




Hey you should post this in its completed form. I've been looking for something like this. All I can seem to find are ones that use pictures though...
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 03:57 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker