Is there a way to change the position of scrolling text using the 'show scrolling text' command? I want the text to appear above the player / enemies head when certain skill are used.
reposition "show scrolling text"
RGSS3 Script RequestsThe engine gives you no built-in method to resize Window_ScrollText and the initialize method for that class receives no parameters. It starts at (0, 0) and ends at (Graphics.width, Graphics.height) - so it is a full screen window. To change that you have to change how the window itself works and that means using a script.
ok. thanks for the answer. Do you know of a script that does this?
No, unfortunately I do not know any script with that feature. But if you use the Script Request board maybe you can find somebody who used something like this before.
While thinking of possible ways to do it I ended up doing it myself. I really am an addict...this is something that should be cured somehow.
You can find it here. Description, TOU and instructions are inside the script. I hope you like it. Of course feel free to use a different one if you find one that you like more (or if you don't like mine).
You can find it here. Description, TOU and instructions are inside the script. I hope you like it. Of course feel free to use a different one if you find one that you like more (or if you don't like mine).
thanks. I'll try it out! 😀
You can do it yourself.
Code:
def resize(width, height)
self.width = width
self.height = height
create_contents # or try refresh
end
Thanks for pointing this out. Both of them actually work. I edited the script I posted above so that it uses refresh.
Thanks guys. This now works so that when my character uses a skill or spell, it show the skill name above his head and scrolls up, which is the effect i was after.
To take it to another level... I'm using an ABS so i fight enemies on the map, rather than in the default battle window. Setting the X,Y coordinates for the scrolling text for the character is easy, as he's always in the center of the map. However, is it possible to create this effect for when my enemies use skills/magic? Obviously they are in various positions on the map when their skills are used. I assume I would have to set the X,Y coordinates to the position of the event, but don't know what to use in the script call for that (e.g. pos.current_event instead of a number).
Is this doable? 😀
To take it to another level... I'm using an ABS so i fight enemies on the map, rather than in the default battle window. Setting the X,Y coordinates for the scrolling text for the character is easy, as he's always in the center of the map. However, is it possible to create this effect for when my enemies use skills/magic? Obviously they are in various positions on the map when their skills are used. I assume I would have to set the X,Y coordinates to the position of the event, but don't know what to use in the script call for that (e.g. pos.current_event instead of a number).
Is this doable? 😀
If you are using the one I gave you then you can. When you use your script call to change where your window is displayed you can set new x and y based on your event position.
Keep in mind that player x and y are grid-based while those you have to pass to your message window are pixel based. If you want to display your message where the square (1, 1) starts then you have to set x and y as (32, 32).
That said you have two options to display your skill name:
Keep in mind that player x and y are grid-based while those you have to pass to your message window are pixel based. If you want to display your message where the square (1, 1) starts then you have to set x and y as (32, 32).
That said you have two options to display your skill name:
- Set a fixed size for your text length and create a formula to calculate your x and y
- Calculate how long your skill name is and and calculate x and y accordingly.
If you want a fixed maximum text length (let's say 100 pixels) you can do it this way:
If you want to calculate your name size every time you can change the number 50 above with a.text_size(your_skill_name)/2. In this case a must be an instance of Bitmap class.
To have more informations about Bitmap and text_size just press F1 in your engine, go to index and look for Bitmap.
Code:
new_x = $game_player.screen_x + 16 - 50
# 16 is to add half your tile size, and -50 is to subtract half your total length.
# I am using numbers here just as an example.
# It is better if you store them somewhere so you don't have to correct everything
# every time just because you changed your window size.
new_y = $game_player.screen_y - how_high_it_should_go - your_window_height
# instead of $game_player you can use any other event.
# after this you call your method to resize scroll text window
If you want to calculate your name size every time you can change the number 50 above with a.text_size(your_skill_name)/2. In this case a must be an instance of Bitmap class.
To have more informations about Bitmap and text_size just press F1 in your engine, go to index and look for Bitmap.
but if the monster is moving around the map, how can i set the script call to automatically "know" where the event is when the skill is used?
EDIT: I tried setting two variables to determine the X and Y coordinates of "this event" and then used them in the script call:
set_scroll_text_size(\V[429], \V[430], Graphics.width, Graphics.height)
I know these numbers are the coordinate values and not the pixel values, but i can edit that later. Problem is now i get a "Expecting )" error when the skill is used. And as you can see there's no missing ) in the script call.
EDIT2: So I looked up about variables in script calls and, obviously, I was doing it wrong. Now I have this, but it only displays from the bottom-left corner.
EDIT: I tried setting two variables to determine the X and Y coordinates of "this event" and then used them in the script call:
set_scroll_text_size(\V[429], \V[430], Graphics.width, Graphics.height)
I know these numbers are the coordinate values and not the pixel values, but i can edit that later. Problem is now i get a "Expecting )" error when the skill is used. And as you can see there's no missing ) in the script call.
EDIT2: So I looked up about variables in script calls and, obviously, I was doing it wrong. Now I have this, but it only displays from the bottom-left corner.
Yes, when you use variables inside a script call you have to use $game_variables[id] instead of V[id] (or \V[id]). Anyway if you use your event coordinates since they change the window position will automatically change as well.
EDIT: just so that you know you should be able to access your event position using this:
However you might want to access their screen_x and screen_y instead of just x and y. It should work (theoretically) but since I cannot access the engine right now and I am only relying on my memory I cannot guarantee that.
EDIT: just so that you know you should be able to access your event position using this:
Code:
$game_map.events[id].x # x position
$game_map.events[id].y # y position
However you might want to access their screen_x and screen_y instead of just x and y. It should work (theoretically) but since I cannot access the engine right now and I am only relying on my memory I cannot guarantee that.
so how do i add this to the script call?
EDIT: If I use the above script call, I'd have to use the number of the event that it applies to. The problem with this is that I want it to apply to many different events, hence why I used the 'This event' when getting the variable for X,Y coordiantes.
EDIT2: currently, the variables return a value of 0 for the X,Y position.... 🙁
EDIT: If I use the above script call, I'd have to use the number of the event that it applies to. The problem with this is that I want it to apply to many different events, hence why I used the 'This event' when getting the variable for X,Y coordiantes.
EDIT2: currently, the variables return a value of 0 for the X,Y position.... 🙁
You can just have your event call it whenever casting a skill. However you can access each event id by using @event_id in a script call. It automatically gives you the id for the event it is in.
The result should be this:
NOTE: I was able to access the engine now. That code definitely works. If you got 0 then you must have done something wrong.
The result should be this:
Code:
ev = $game_map.events[@event_id]
new_x = ev.screen_x
new_y = ev.screen_y
new_x = your_formula_to_calculate_window_new_x_goes_here
new_y = your_formula_to_calculate_window_new_y_goes_here
set_scroll_text_size(new_x, new_y, width, height)
NOTE: I was able to access the engine now. That code definitely works. If you got 0 then you must have done something wrong.
do i need this section?
new_x = your_formula_to_calculate_window_new_x_goes_here
new_y = your_formula_to_calculate_window_new_y_goes_here
If new_x = ev.screen_x and new_y = ev.screen_y give the positions?
I tried it without these 2 lines and got an error (you are using VX ace, right, not MX?), so I assume this is needed, but I have the same problem - how to I add a formula here if the pos of x and y keep changing and I can't use event variables? My new_x would be the current x pos of the event, same for y. but I don't know what the formula would be for that.
This is the error I got:
new_x = your_formula_to_calculate_window_new_x_goes_here
new_y = your_formula_to_calculate_window_new_y_goes_here
If new_x = ev.screen_x and new_y = ev.screen_y give the positions?
I tried it without these 2 lines and got an error (you are using VX ace, right, not MX?), so I assume this is needed, but I have the same problem - how to I add a formula here if the pos of x and y keep changing and I can't use event variables? My new_x would be the current x pos of the event, same for y. but I don't know what the formula would be for that.
This is the error I got:
As I said the formula you use there is not something I can come out with. It depends on where you want to place your scroll text window. It is not something I can know without reading your mind. All I can do is tell you how to set it up, then you are the one who has to write it.
However assignments are read from right to left. If I write a = b then first b is evaluated, then a is set to be equal to the result. That means I can write a = a + 2 and increase a by 2. The new assignment for new_x and new_y is just a way to avoid using a new variable to save memory. If you want to remove a line from that script it could be the very 1st one and use $game_map.events[@event_id] instead of ev in the next two lines.
Anyway even though those two lines are needed it does not explain why you got that error message.
P.S. in the example I used $game_player. For events you have to use $game_map.events[@event_id]. However if you assign your event screen_x and screen_y to new_x and new_y you can just use new_x and new_y instead of that whole $game_player.screen_x and $game_player.screen_y I used in the example.
In the end you should have something like this:
Code:
new_x = $game_map.events[@event_id].screen_x
new_y = $game_map.events[@event_id].screen_y
new_x = new_x + 16 - whatever_value_you_want
new_y = new_y - how_high_your_message_should_be_compared_to_character
set_scroll_text_size(new_x, new_y, width, height)
I know you can't read my mind! 🙂
Exactly where the text appears isn't too important because I can mess around with the numbers until it works. But at the moment, I still get that error message when the enemy uses the skill.
When the skill is used, a common event is called and this is the event. I just put some numbers into the new_x and y parts, just to see what happens - i can mess around with these later, but at the moment I don't get the text, just the error... 🙁
it's like it doesn't know what 'screen_x' means. that's why i asked if you were using VX and not MV.
Exactly where the text appears isn't too important because I can mess around with the numbers until it works. But at the moment, I still get that error message when the enemy uses the skill.
When the skill is used, a common event is called and this is the event. I just put some numbers into the new_x and y parts, just to see what happens - i can mess around with these later, but at the moment I don't get the text, just the error... 🙁
it's like it doesn't know what 'screen_x' means. that's why i asked if you were using VX and not MV.
Let me guess, are you using common event?
yes. 🙂
Original thread: https://forums.rpgmakerweb.com/threads/reposition-show-scrolling-text.97108/