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

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
You could put a try/rescue around the getting of the image. I THINK that would cause it to not show an error if it couldn't find the file.
 

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
Actually, I already took your advice of it being the user's problem :) I just made it to where if you want an image to be displayed you now write <$filename: bool, bool> and <filename: bool, bool> to draw the scene without the image. I think this approach works fine. I'm sorry for the grief. I've had so much trouble with this thing. The game_interpreter looked like another language to me this morning lol. Oh, and thank you for all your help. I'm sure I made it much more complicated than it should have been.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
nah, that's what it's all about :)


Game_Interpreter - ignore the stuff at the top. command_101 is the first bit where it gets interesting. If you want to see how to do something, find an event that does it (or nearly does it) and then look up the name of that event command (so the button says Show Text, so search Game_Interpreter for Show Text). Just take it one method at a time.
 

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
I think I'll try that actually since I have to format the message text now, and I don't even know how to begin doing that lol

I"m not sure how this happened. It posted twice somehow. Sorry, I really don't mean to keep doing that
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Just report it, and we'll delete the extra.
 

TheRiotInside

Extra Ordinaire
Veteran
Joined
Sep 3, 2012
Messages
270
Reaction score
123
First Language
English
Primarily Uses
Another RMXP question for you guys. Thanks for all of your time and effort, really appreciated.

I've re-purposed the dex_f and agi_f values (since I won't be needing Dexterity or Agility-based attacks) to allow for more control over applying states with skills. The bit of code I added looks like this:

Code:
if skill.dex_f > 0  if rand(100) < skill.dex_f    # Removes state to restart turn count    if self.state?(skill.agi_f)      self.remove_state(skill.agi_f)    end    self.add_state(skill.agi_f)    endend
 

I'm not a scripter by any means, so apologies if that code is cringe-worthy, but it gets the job done. Setting a skill in the database with Dex-F of 75 and an Agi-F of 2 makes the skill apply poison 75% of the time on top of whatever else the skill does. The thing is, this obviously overwrites the A-F state resistances that the target has. I've looked through the code to see what kind of syntax I would have to use to add that functionality to what I have, but I'm at a loss.

 

I know where to find and modify what values A-F have, but I have no idea how to properly add them into my code. Say I wanted a D rating to cut the success chance in half, I could change D's value elsewhere to 2, and do this:

 


Code:
rate = skill.dex_f / [state resistance modifier]if rand(100) < rate[etc...]
 

I could add an if case for if the rating is F, maybe at the very top, like: [if rating is not F, (do state calculations)] so that if won't even run the code if the target's immune to that state.

 

Basically I'm looking for the syntax to call the value of the state resistance letter (A-F). Or really, any and all syntax available dealing with element and state resistance ratings. Answers will probably lead to more questions, but again, I appreciate your time. Thanks in advance!
 

Neok

Veteran
Veteran
Joined
Jul 31, 2014
Messages
45
Reaction score
15
First Language
English
Primarily Uses
Just a quick question. If say in the original script, a class is defined as follows:

 

class Window_ChoiceList < Window_Command

 

 

and later under Materials, I define it as follows:

 

class Window_ChoiceList

 

 

What changes inside it, now that I've removed the 'Window_Command' inheritance?
 

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
It doesn't inherit from window_command anymore, and won't have those methods within that class. At least that's how I assume that would work.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
@Neok 

If the normal code (ie, class Window_ChoiceList < Window_Command) is still there, it will not 'affect' anything.  If you have removed the original code, there would be no inheritance when the code is initialized.

For example :

class Game_Actor   def example_method    p "Just showing text"  end end^ this will simply add a new method into the game actor class, providing the Game_Actor class has been previously defined. It does not remove Game_Actors inheritance from Game_Battler.
 
Last edited by a moderator:

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
@Neok 

If the normal code (ie, class Window_ChoiceList < Window_Command) is still there, it will not 'affect' anything.  If you have removed the original code, there would be no inheritance when the code is initialized.

For example :

class Game_Actor   def example_method    p "Just showing text"  end end^ this will simply add a new method into the game actor class, providing the Game_Actor class has been previously defined. It does not remove Game_Actors inheritance from Game_Battler.
That's interesting! I thought it would be over written since it wasn't making the original inheritance call.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
Nah, as long as the inheritance is being applied at 'some point' along the line of code it will work (anyone is free to correct me here if this is wrong)

But for example...

I have this in script A

class Person  def intialize    @name = "Newborn"    @age  = 1  end  def name    @name  end  def age    @age  endendclass Dekita < Person  def intialize    @name = "Dekita"    @age  = 24  endendThis creates and defines the 'Dekita' class. Which inherits from 'Person' class.

Now, I want to add a new method into 'Dekita' class called 'gender'.

class Dekita  alias :init_alias :initialize  def initialize    init_alias    @gender = "??"  end  def gender    @gender  endendAs you can see, I have removed the inheritance from my new methods, but because its already defined prior to my new modification, it does not affect any inheritance already included.

This can be tested by calling the code below (when the code from above is also there);

dekita = Dekita.newp dekita.namep dekita.agep dekita.gender

Also - lets say we wanted to include a new 'inheritance'. We can do this by creating a new module and including it in any class we choose, for this example, I am placing it within the 'Person' class.. This will mean even descendants of 'Person' will be entitled to access the methods.

module Person_New  def new_stuff    return "New Stuff"  endendclass Person  include Person_Newend
Can be tested by calling.

p dekita.new_stuff
For convenience, I have placed the tried and tested code from above into the spoiler below - so you can easily load it up and play around with it :)

Code:
class Person  def initialize    @name = "Newborn"    @age  = 1  end  def name    @name  end  def age    @age  endendclass Dekita < Person  def initialize    @name = "Dekita"    @age  = 24  endendclass Dekita  alias :init_alias :initialize  def initialize    init_alias    @gender = "??"  end  def gender    @gender  endenddekita = Dekita.newp dekita.namep dekita.agep dekita.gendermodule Person_New  def new_stuff    return "New Stuff"  endendclass Person  include Person_Newendp dekita.new_stuff
 

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
Thanks for the explanation, Dekita. ^ That was actually helpful with something I'm working on. I also have a question though. I'm using a horizontal window command in a script I'm writing. So far I haven't done anything except change the max columns 3 and changed the width of the window, but for some reason the menu is moving backwards. i.e. I press :LEFT and the selection moves right.... Do you know what could cause this?  
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
Sorry, that I do not.  I never use horz commands cause I dislike how they change certain things.  :/
My personal preference is just to not use them at all :D
 

DRS

Veteran
Veteran
Joined
Aug 10, 2014
Messages
67
Reaction score
6
First Language
English
Primarily Uses
I just figured it out. I was updating twice, and it somehow caused it to switch direction Lol. Thanks for the help anyways. I'm starting to realize what you mean about HorzCommands too.
 

Bloodmorphed

Dungeon Fanatic
Veteran
Joined
Sep 17, 2012
Messages
1,466
Reaction score
144
First Language
English
Primarily Uses
This is more of a simple situation but I'm extremely confused and I need a break down as to why this line is true, rather then false.

boolean_1 = (3 < 4 || false) && (false || true)

Why would this come out as true? I know 3 < 4 would equal true, so I'm assuming you would take that as the true, but the && (false || true) I thought you would take out the first so it would be true && false, which would come out false. I'm doing code academy but it doesn't explain WHY this line comes out true.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
boolean_1 = (3 < 4 || false) && (false || true)it would return true because you are checking is (3 < 4 or false) - which will return true and the also asking for either (false or true) to be true, which it obviously is. Therefore, both testes return true and thus, the overall statement is true :)
 

Bloodmorphed

Dungeon Fanatic
Veteran
Joined
Sep 17, 2012
Messages
1,466
Reaction score
144
First Language
English
Primarily Uses
So in other words if there is a true statement inside of (something || something) it will always be true?
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
|| (or) will return true if any statement is true. The second it gets a true statement, no other checks are made on that line.

&& (and) is the same, however if it receives one false it will stop checking, and will only continue if all conditions are true.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
@bloodmorphed - in short, yes. :)
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,479
Members
137,824
Latest member
dobratemporal
Top