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

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
I see along of script errors lately during my massive debbuging process this weekend and helping others.

Here is a few tips I learned.

1. Don't add scripts and then load a continue or saved game. It holds old variables that didn't have the new script involved. Always start fresh when adding or changin scripts.

2. Sometimes moving added/or custom scripts around in the script editor can solve the issue. That happened to me with XL-core and Symphony. When I moved Xl- Core above everything even symphony it stopped the error. Weird but true.

3. When Debuging and asking for help, a pic or snapshot of the error box is a big big help. 99% of the time it's the last new script you added.

These are a few tips.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
3. When Debuging and asking for help, a pic or snapshot of the error box is a big big help. 99% of the time it's the last new script you added.
AND TELL PEOPLE what scripts you're using AND provide links.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,563
Reaction score
3,838
First Language
English
Moving scripts around usually only works when one overwrites stuff and the other simply adds onto it.


Order of execution is important if one script depends on the other, if you put scripts above its pre-requisites, probably not going to work, especially if the code first checks "if prequisite is imported..."


If both scripts overwrite the same method, you're pretty much out of luck; you'd have to actually go in and combine the conflicting methods manually so that all of the logic is retained.


I have attempted to contain all of the logic for any overwritten methods within a single line so others can just copy that one line into the conflicting scripts.
 
Last edited by a moderator:

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
I'm getting an error when I try to use the following script call:
 
$game_variables[50][this.id] += 5

undefined method '+' for nil:NilClassor
$game_variables[50][self.id] += 5

undefined method 'id' for#<Game_Interpreter:blabla>I believe 'this' was an addon for a script I commissioned from Enelvon that allowed me to use 'this.id' to get the current events ID.
In both cases, it should have ended up translating to $game_variables[50][20] += 5, which works fine if I called it just like that.
 
edit:
the == operator works perfectly fine in both cases
$game_variables[50][this.id] == 5
 
edit 2 solution:
 
Got it, Zal explained it to me. Since I didn't initialize the whole array to zeros it was still at 'nil' which can only take == or =.

Code:
$game_variables[50][this.id] == nil ? $game_variables[50][this.id] = 0 : nil$game_variables[50][this.id] += 5
 
Last edited by a moderator:

saethone

Warper
Member
Joined
Aug 18, 2013
Messages
2
Reaction score
0
First Language
English
Primarily Uses
Hey is it possible to check what terrain tag (set in the tileset in the database) the player is on? 

I'm trying to create a script that will automatically disable dash while walking through water, and I think I have most of it figured out, but the only way I've been able to find to check terrain tags is with events.
 

Galv

Veteran
Veteran
Joined
Oct 1, 2012
Messages
1,271
Reaction score
1,520
First Language
English
Primarily Uses
RMMZ
Try:


$game_map.terrain_tag($game_player.x, $game_player.y)
 
Last edited by a moderator:

saethone

Warper
Member
Joined
Aug 18, 2013
Messages
2
Reaction score
0
First Language
English
Primarily Uses
That worked perfectly, thanks!
 

SoulPour777

Crownless King
Veteran
Joined
Aug 15, 2012
Messages
1,093
Reaction score
104
First Language
English
Primarily Uses
N/A
This might have been asked before or was probably had its solution but I just want to ask for sure.

Is there a way to bypass / change the smooth scrolling of XP aside from adjusting it to smooth scroll mode? It only works for those with good end computers. In as much as I want my game to be played in its full potential graphics even in low computers, how can I activate a better smooth scrolling through a script? I only saw something for VX but for XP....I am lost in thought.
 

DancingDrake

Random Lurker
Veteran
Joined
Jul 24, 2012
Messages
80
Reaction score
22
First Language
English
Primarily Uses
RMVXA
I was just wondering (and I hope this is the right place to ask this) is there a script call that I can use to check how many actors are in the current party? I have been looking all over for this because I want to limit the overall party (not just battle party) to just 4 actors and will be needing to check how many actors are already in the party during my game. I know I could do this with variables but If there is a script call that can do this (or even any other way that I haven't been able to find) it would make this part of my game so much easier.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
$game_party.members.size will give you the number of battlers if you're in battle, but the total number of members (battlers and reserve) at all other times.


However, you can also get this via Control Variables > Game Data > Other > Party Members, so you really don't need to use a script call if you're already in an event.
 
Last edited by a moderator:

DancingDrake

Random Lurker
Veteran
Joined
Jul 24, 2012
Messages
80
Reaction score
22
First Language
English
Primarily Uses
RMVXA
Thanks Shaz :D . I think I might of seen that script call somewhere else while looking for this solution but I didn't understand the whole thing about it being everyone when used outside of battle. Also thanks for telling me about the event method I feel so silly for not seeing that before.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
Does anyone happen to know how the Input module will only get a key once every second, based on the game's frame rate, so that it doesn't always grab a key press? I assume it's something done in the update method, but I'm not entirely sure what it is. I've tried making a counter to only work every 60 updates, but it didn't work out as well as I had hoped.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
It would be difficult - you might need to experiment between Input.press? trigger? and repeat? because if you're only checking once every 60 frames, the method you're using might require the button to be pressed exactly on that 60th frame.

Basing it on frame rate might be incorrect too, because you'd have to guarantee that your game would always run at that frame rate, and if you have anything that causes lag, or the player has an older computer that can't handle that frame rate, both of those will cause issues.

A new method like this might be a good starting point, but would be prone to the issues just mentioned:

Code:
module Input  def press_60?(sym)    press?(sym) && Graphics.frame_count % Graphics.frame_rate == 0  endend
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
Oh, no, I wasn't extending the Input module, I'm trying to replicate the behavior that it won't get get input at every frame (because, ideally, the game will run too fast and that would be difficult to control). How I did it was just make a timer, which was defined as:

def self.update # It was in a module, so I can't use instance methods !@counter.is_a?(Numeric) || @counter < 0 @counter = Graphics.frame_rate end if @count <= 0 @updated = true end @counter -= 1endWhen I did a specific function, @updated was set to false and no other input bits would be accepted until @updated was true again, but it seemed to run much too slowly, especially compared to the speed of the regular Input module, so I'm trying to figure out how it waits for a second (or however long it is) until it will get another key, or in my case, allow another action to occur.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
Does your method really say if @count <= 0? You've used @counter everywhere else.


Game_Interpreter calculates play time (in seconds) as Graphics.frame_count / Graphics.frame_rate if that helps. You could get play time into one variable, then in your loop check if the current play time is different to the previous play time, which means a second has elapsed (and then save the current play time into the variable for the previous play time).
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,563
Reaction score
3,838
First Language
English
Oh, no, I wasn't extending the Input module, I'm trying to replicate the behavior that it won't get get input at every frame (because, ideally, the game will run too fast and that would be difficult to control). How I did it was just make a timer, which was defined as:

def self.update # It was in a module, so I can't use instance methods
Don't change Input.update. Write your own listener somewhere else.

You are asking for trouble if you're going to change how Input functions everywhere.

Have something in the scene check every few frames for example.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
Does your method really say if @count <= 0? You've used @counter everywhere else.

Game_Interpreter calculates play time (in seconds) as Graphics.frame_count / Graphics.frame_rate if that helps. You could get play time into one variable, then in your loop check if the current play time is different to the previous play time, which means a second has elapsed (and then save the current play time into the variable for the previous play time).
No that was a typo on my retyping it.

Don't change Input.update. Write your own listener somewhere else.

You are asking for trouble if you're going to change how Input functions everywhere.

Have something in the scene check every few frames for example.
I am not rewriting anything about the Input module. It's for something apart from Input,  I'm trying to replicate it's update.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,000
First Language
Tagalog
Primarily Uses
RMVXA
It was in a module, so I can't use instance method

--> Then why use a module? use classes instead
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
What would making it a class change? I don't need it as an object, that would actually make it more difficult to do this specific function. I just noted that it was a module for additional information, in case it was relevant.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,000
First Language
Tagalog
Primarily Uses
RMVXA
Just so that you can use instance methods... if you really need it... but it seems you don't...
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Ami
--- Spoiled Food ---

M.Knight: Oh,no! the Bread has been Mold!
Chef: It's not Mold,it's in Fermentation.
M.Knight: Are you sure?
Chef: Y'know Cheese? It's safe to eat
(Chef eat the Moldy Bread,after that he take into the Hospital with Green Face)
Suddenly I remember the days when I create something just by pure wild imagination. I wasn't thinking about concept, structure, or anything else. Just create (even if it's unfinished in the end). Somehow I kinda want to have that wild imagination again. :D
Google "The Great Stink"
Enjoy.
Woke up on an awful nightmare of being banned here because some mod didn't liked me in a super-heroes freeform round robin RP where I used throwing normal hammer as power and it was qualified being too OP. XD Nice to read you all guys. Will not wait next nightmares.

Forum statistics

Threads
104,333
Messages
1,005,604
Members
135,844
Latest member
andrewshetty123
Top