Ruby/RGSSx questions that don't deserve their own thread

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Yes, that is the correct scripted check. Much easier than the evented one, right? :p
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
Can someone please explain to me what the functional difference is between these two script calls in simple terms?

In a Set Move route command, 'Repeat' box checked

turn_toward_character($game_map.events[29])

where 29 is the id of the event that the the NPC will turn towards

In the custom move route of the NPC (and the +2 or -2 is because that was the distance away that I wanted the player to influence the behaviour of the NPC)

self.x.between?($game_player.x - 2, $game_player.x + 2) &&  self.y.between?($game_player.y - 2, $game_player.y + 2) ? turn_toward_player : set_direction(2)

Is the more complicated second one needed because it is the player, rather than another event, that the NPC is turning towards?  Or is it solely because of the specification of the distance away? Can the first one be used to turn towards the player?

I am about to need an event to turn towards the player, and don't know on what basis I should choose between these. 

Thanks.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
565
Reaction score
276
First Language
German
Primarily Uses
Or is it solely because of the specification of the distance away?
Exactly that.

self.x.between?($game_player.x - 2, $game_player.x + 2) && self.y.between?($game_player.y - 2, $game_player.y + 2) ? turn_toward_player : set_direction(2)

The teal colored part is used as a fork condition (self is within a 2x2 square from the player). If it is fulfilled, the purple colored command is executed (turn towards the player), otherwise the brown one (turn down).

The condition might not work correctly for looped maps. There is a function that takes the map loop border into account, but I'm not sure what it was called. Something like  self.distance_x_from($game_player.x)
 
Last edited by a moderator:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
Thank you.

So if I just want the NPC to turn towards the player, irrespective of distance, then I could use the first formulation, in a set move route, 'Repeat' checked, and it would just be

turn_toward_player.  I wouldn't need to specify anything further.  Is that correct?

EDIT That wasn't as clear as perhaps it should have been - but anyway, having checked it myself, I can't see anything wrong, as it turns when the player is still some distance away, which is what I wanted.

Once more, thanks for the clarification.
 
Last edited by a moderator:

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
565
Reaction score
276
First Language
German
Primarily Uses
Sorry about that.

Yes,  turn_towards_player  should be correct, even though you probably don't need a script command for that as it is already a built in move command option.

The problem is that the fork condition does not take the map wrapping into account. When the player happens to be near the left side of the map and the event stays near the right side so they seem to be close to each other, the fork condition will still calculate a huge difference in their coordinates and does not trigger.

(For example, if you have a 100x100 map, the player is located at (0, 40) and the event at (98, 40) it seems the player stands two tiles to the right of the event. The fork condition will conclude that the player stands 98 tiles to the left of the event instead.)

An alternative for the teal colored part could be for example:

distance_x_from($game_player.x).between?(-2, 2) && distance_y_from($game_player.y).between?(-2, 2)

Of course, if you don't use looping maps, that issue should not be a problem. :)
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
I'm not using looping maps in this project, but I have copied that alternative into my "useful script calls for all eventualities" document.

So thank you.
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
If I wanted to change the x and y location of battle animations in scripts where and how would I do this?

Based on the information in the help the x and y is for each cell located in a frame of the animation stored in a 2 dimensional array. Meaning to do this properly I believe I am going to have to use a for loop based on the number of frames then another one for the number of cells in a frame. Is my understanding of what I need to do correct (would this be the most efficient way to do this)?

Thanks in advance.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Script call to end game?

The following didn't work:

Code:
SceneManager.goto(Scene_End)
Code:
SceneManager.call(Scene_End)
 
Last edited by a moderator:

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
Do you want the game over screen or just shutdown?

SceneManager.call(Scene_Gameover) is for game over screen.

SceneManager.exit to shutdown.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Is there any way to change an already initialized viewport's X/Y position?


I can't seem to do this...


And since I can't see the default Viewport class, I can't even make a working method for this. >.>


When I try to specify an X or Y value for a viewport, it says that those methods are not defined (x= and y=). So, I tried to define them, but nothing I do works. -.-


Anyone knows how to do this?
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Is there any way to change an already initialized viewport's X/Y position?

I can't seem to do this...

And since I can't see the default Viewport class, I can't even make a working method for this. >.>

When I try to specify an X or Y value for a viewport, it says that those methods are not defined (x= and y=). So, I tried to define them, but nothing I do works. -.-

Anyone knows how to do this?
Yes. When you initialize a viewport, you set its rect's parameters. The X and Y positions of the viewport are the X and Y positions of its rect. Simply change its rect's X and Y.

viewport.rect.x = new_xviewport.rect.y = new_yCheck the Viewport page from the help file for more information. :)  
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Lmao, I was so distracted by searching for the X and Y properties in the help files, that I didn't notice the rect property. :D


Frustrated by it, I changed from sprite to an invisible window, so I managed to fix my issue in a different way (which actually made my job easier, because I could move it together with the other things on the same viewport effortlessly), but it is certainly good to know that it can be done!


Thanks for the info!
 

FeaR616

Veteran
Veteran
Joined
Nov 22, 2014
Messages
277
Reaction score
52
First Language
german
Primarily Uses
hey, I don't really know where to look at... is there any way to change the animations so that they are displayed above star passability?? best would be if I can turn it on or off with a script or something or changing the value directly... ^^"

thanks in advance
 

Lowell

The Walking Atelier
Veteran
Joined
Apr 21, 2012
Messages
292
Reaction score
69
First Language
English
Primarily Uses
So like, help me out here. I use a few Japanese scripts in my project and prefer not to "translate it"  to avoid breaking it. but I want to try and alias some of the modules due to some of the contents requiring translating.

For Example

module KURE
  module ExEquip
  #初期設定(変更しないこと)-----------------------------------------------------  
    EQUIP_SLOT_NAME = [] ; Vocab_Ex1 = []
        
 
    #装備スロット表示名を設定(EQUIP_SLOT_NAME[iD] = "表示名"
    #スロットID 0~4はシステムより予約されています
    EQUIP_SLOT_NAME[5] = "Fate"
    EQUIP_SLOT_NAME[6] = "スロット6"
 
  #ステータス欄の表示設定-------------------------------------------------------
    #ステータスの表示名
    Vocab_Ex1[0] = "命中率"      #命中率
    Vocab_Ex1[1] = "回避率"      #回避率
    Vocab_Ex1[2] = "会心率"      #会心率
 
  end
end
 
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Lmao, I was so distracted by searching for the X and Y properties in the help files, that I didn't notice the rect property. :D

Frustrated by it, I changed from sprite to an invisible window, so I managed to fix my issue in a different way (which actually made my job easier, because I could move it together with the other things on the same viewport effortlessly), but it is certainly good to know that it can be done!

Thanks for the info!
You're welcome!

hey, I don't really know where to look at... is there any way to change the animations so that they are displayed above star passability?? best would be if I can turn it on or off with a script or something or changing the value directly... ^^"

thanks in advance
Hello! Try changing the z value in Sprite_Base. Search for "sprite.z".

So like, help me out here. I use a few Japanese scripts in my project and prefer not to "translate it"  to avoid breaking it. but I want to try and alias some of the modules due to some of the contents requiring translating.

For Example
What do you mean by "alias some of the modules"? You can't use alias with a module. What are you trying to do? You could always keep a .txt or .rb with the original code in case you want to go back to the original settings.
 

Lowell

The Walking Atelier
Veteran
Joined
Apr 21, 2012
Messages
292
Reaction score
69
First Language
English
Primarily Uses
Basically any function that draws text in game, I want to be aliased/overwritten with a custom snippet due to any updates the main script may have. Through I think a direct overwrite might work as well.
 

Blinn

Veteran
Veteran
Joined
Jan 18, 2015
Messages
610
Reaction score
243
First Language
English
Primarily Uses
1: Is there a script that enables multiple enemies to attack at the same time?

2: Is there a script that enables "hit" animations the moment damage is displayed?

3: Is there a script where enemies periodically make "fidget" sounds when idle?

4: And is there a script that displays multiple damage counters at once, in different locations relative to the target?

Here's a couple videos for reference:

#1-3 - 6:01 - Watch how the magical attacks are displayed when a character is hit by it, and how several creatures can attack at once during turns. Also note the sounds made by the other monsters throughout the dungeon when idle.




#4 - 2:47 - Watch how a character named Gadot deals damage during combat:
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You're asking for a script so that deserves it's own thread... anyway, you can do all that using scripts
 

Blinn

Veteran
Veteran
Joined
Jan 18, 2015
Messages
610
Reaction score
243
First Language
English
Primarily Uses
You're asking for a script so that deserves it's own thread... anyway, you can do all that using scripts
I wasn't sure, so posted it here just in case. I might commission a scripter at some point to make a combination of the 4 functions in a script, I am the last person in the world who should be touching Ruby.
 

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

Latest Threads

Latest Profile Posts

This is relevant so much I can't even!
Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect

Forum statistics

Threads
105,999
Messages
1,018,221
Members
137,778
Latest member
br11an
Top