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

Solistra

Veteran
Veteran
Joined
Aug 15, 2012
Messages
593
Reaction score
244
Primarily Uses
You'd have to look at Game.ini and read which DLL will be used for the game, which is entirely possible. This is also probably a wildly inefficient hack, but this will check in Game.ini for the RGSS version and return the more usable "RGSS1", "RGSS2", or "RGSS3" that you might be expecting.



Code:
file = File.open("Game.ini")
file.each { |line|
  @version = line.match(/RGSS[1,2,3]/)[0] if line.match(/^Library=/)
}
Edit: Replaced my original post, which was interesting, but not thought out well enough for my tastes. This works far better than what I originally posted anyway.
 
Last edited by a moderator:

FenixFyreX

Fire Deity
Veteran
Joined
Mar 1, 2012
Messages
434
Reaction score
308
First Language
English
Primarily Uses
Why not just use the general regex:



Code:
if line =~ /Library=RGSS(\d+)\.dll/
@version = $1.to_s.split("").join(".") # OR $1.to_s.split("")[0] just for the first number(1,2,3).
end
This supports possible future versions if their naming standards hold up.

That way you have the version and subversion as well lol.

Alternatively you can just check the RUBY_VERSION to see if it is above 1.8, if so you are in RGSS3.



Code:
if RUBY_VERSION.split(".")[0..1].join.to_i > 1.8
@version = 3
elsif RUBY_VERSION.split(".")[-1].to_i > 1
@version = 2
else
@version = 1
end
 
Last edited by a moderator:

Solistra

Veteran
Veteran
Joined
Aug 15, 2012
Messages
593
Reaction score
244
Primarily Uses
Because my regular expressions are rusty at best and I don't like using them. :p
 

TheNewTeddy

Veteran
Veteran
Joined
Oct 14, 2012
Messages
92
Reaction score
0
First Language
English
Primarily Uses
Is it possible to create a script that prevents the user from restarting the game using any shortcuts (I heard some of the F keys will do this, I'd like to prevent that)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,072
First Language
English
What if they alt+F4? Do you want something to prevent that as well? There is not much of a difference and if someone wants to restart they will figure that out eventually.
 
Last edited by a moderator:

TheNewTeddy

Veteran
Veteran
Joined
Oct 14, 2012
Messages
92
Reaction score
0
First Language
English
Primarily Uses
I just specifically don't want them using a "restart" button. A "shut down and begin again" button is fine.
 

Gigglemoo

Member Title
Veteran
Joined
Sep 20, 2012
Messages
243
Reaction score
35
Primarily Uses
I just specifically don't want them using a "restart" button. A "shut down and begin again" button is fine.
That is what it does, jumps right back to the title screen. :)

F12 is the built in hotkey for that.

I think it could be possible with scripting, but that's built into the engine. Why would you want it removed?
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,200
Reaction score
1,256
First Language
English
Primarily Uses
RMXP
@Game.ini reading:

I highly suggest using the Win32API provided for that. Here's a wrapper you can use: http://pastebin.com/mdW8D8fi

One advantage of using this is that you can read and write to the .ini file even if you install the game in the program files folder (something like C:\Program Files (x86)\GameName\Game.ini)

IO access is restricted there. That is the main reason for the scripts putting save files in %APPDATA% instead. (It is of course also better practice to try that place first)

@Gigglemoo:

The problem is that F12 does not reset the game properly and the mechanism for restarting can potentially lead to a bunch of problems.

Enterbrain have generally tried to fix the issue from version to version, but imo it has just gotten worse.

As long as a proper reset is not done the issues continues to persist. Really, the extra loading time for loading all the classes and etc is definitely worth the price compared the entire class of race condition bugs. (Premature optimization, yup)

In XP at least we can convert it to pausing. In VX and Ace we don't have this option, though some symptom treatment has been done in Ace.

I just specifically don't want them using a "restart" button. A "shut down and begin again" button is fine.
For XP and VX you can use this which technically starts a new game instance and shuts down the current: http://pastebin.com/KdBFd0Cn

It does not work for VX Ace. An adaption have been made though I don't remember who did it or where to find it ._.

*hugs*
 
Last edited by a moderator:

TheNewTeddy

Veteran
Veteran
Joined
Oct 14, 2012
Messages
92
Reaction score
0
First Language
English
Primarily Uses
That is what it does, jumps right back to the title screen. :)

F12 is the built in hotkey for that.

I think it could be possible with scripting, but that's built into the engine. Why would you want it removed?
I want to make the user think for a few moments that he may need to reset the game, but want to make it difficult so he will wait those few moments, and thus find out he does not need to.
 

Solistra

Veteran
Veteran
Joined
Aug 15, 2012
Messages
593
Reaction score
244
Primarily Uses
@Game.ini reading:

I highly suggest using the Win32API provided for that. Here's a wrapper you can use: http://pastebin.com/mdW8D8fi

One advantage of using this is that you can read and write to the .ini file even if you install the game in the program files folder (something like C:\Program Files (x86)\GameName\Game.ini)

IO access is restricted there. That is the main reason for the scripts putting save files in %APPDATA% instead. (It is of course also better practice to try that place first)
Coincidentally, I'm using %APPDATA% for a lot of the information generated by the project I'm working on right now (since it creates more than just a save file). It's extremely useful.

Regarding the Win32API and file permissions, I didn't think that there would be a problem if the file is only being opened for read access (writing is another animal altogether, admittedly) -- and using the Win32API just to read a value that has to be in Game.ini seems like overkill to me. I could always be wrong, of course, and for the purpose of full disclosure, I just really dislike the Win32API in general. It's just... ugly and painful for me to use.

Your wrapper is very convenient, though... so thank you for sharing that.
 

Hyomoto

Staring Contest
Veteran
Joined
Oct 4, 2012
Messages
47
Reaction score
0
First Language
English
I'm trying to figure out which class is used to get information about skills. For instance, under make_damage_value in the Game_Battler, it uses the line item.physical? but all I can find are the pointers back to Game_Action where it has def item. Obviously this has a class and method, but RPG::Skill and RPG::UsableItem don't have this information either.

Basically I want to know how to find out which element an attack/skill is using, but I want to know what element_id as per item.damage.element_id is a part of. Item is pointing to a skill but I can't figure out what is handling that. By the way, new to Ruby so excuse and correct my terminology please.
 

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
826
Reaction score
346
Primarily Uses
The F1 help menu for the program has a lot of information on the hidden classes. For example, I can see that physical? is a method of RPG::UsableItem (though I'm not completely sure if that is what you are asking?) If you're talking about the item variable itself, in the case of Game_Battler, it is just an instance variable/parameter for that method.

So I guess the question becomes where and when you are trying to access the element. $data_skills[skill_id].damage.element_id will work from anywhere (with the skill_id) changed to whichever one you are looking for, though I assume you're wanting the skill being used. In conclusion to this rambly answer, item is just a variable holding a RPG::Skill(or RPG::Item) object.
 

Hyomoto

Staring Contest
Veteran
Joined
Oct 4, 2012
Messages
47
Reaction score
0
First Language
English
Yes, that is exactly what I was looking for. I could have sworn I'd checked there, but I must have been suffering from some sort of blindness at the time. Thank you very much, I was able to find all that information.
 

Nightlit

Warper
Member
Joined
Oct 28, 2012
Messages
2
Reaction score
1
First Language
English
Primarily Uses
I am trying to script a Dual Wield common_event that checks to see whether the character has a second weapon and if they do, to force them to do a skill called "Second Attack"

I am having trouble, of all things, with referencing which battler is currently going so I can force them to do the command. Since there is nothing in the event system which references who is currently acting when in the middle of combat (or barring that, who last acted) I need to script this...

But I can't figure out what variable stores the character to last act during combat.
 

DonCreek

The OH!Yeah!
Veteran
Joined
Sep 5, 2012
Messages
119
Reaction score
7
First Language
ENGLISH
Primarily Uses
Out of the Current topic Question: RGSS2 > Does Pixel movement works in pathfinding script or it uses the default tile movement?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,072
First Language
English
Err depends on the script. Obviously if you pathfind at the pixel level it will be much slower but as long as the pixel movement is setup properly then it should work.
 

DonCreek

The OH!Yeah!
Veteran
Joined
Sep 5, 2012
Messages
119
Reaction score
7
First Language
ENGLISH
Primarily Uses
Err depends on the script. Obviously if you pathfind at the pixel level it will be much slower but as long as the pixel movement is setup properly then it should work.
Thanks Tsukihime for the reply, now i might forget this idea. Thanks again.
 

Tofuffalo

Veteran
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
0
First Language
English
Primarily Uses
Hey guys,

Is there any way of restricting which actors/enemies a skill can target?

For example, the default 'heal' skill allows you to target dead party members, it just doesn't heal that dead actor when you hit ok.

Or, you can target party members who are alive with 'revive', but nothing happens when you do.

So can you set conditions such that an actor with the 'dead' state cannot be targetted at all with 'heal', etc.?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
Ok so basically ive "finished" an enemy natures / iv's and levels script (all in one script) and its an add-on for my actor natures iv and ev's.

It basically allows you to notetag map noteboxes with <lv: min, max> and you replace min and max with the min and max level on monster to encounter on that map. whats peoples opinions on the way that this works ? would people prefer that it was based against party level ? its obviously a pokemon script , which is why ive written it the way it is.
 

Acetonide

Event Coordinator
Veteran
Joined
Apr 16, 2012
Messages
660
Reaction score
30
First Language
English
Primarily Uses
N/A
[snip] would people prefer that it was based against party level ? its obviously a pokemon script , which is why ive written it the way it is.
I think it would if you could have a place for people to configure it for at least two options.

1. Based on party level.

2. Exceptions for each individual enemy (either via notetags or directly in the script)..

That's just my opinion though. Honestly I think no matter how you did it people would love it.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

40 card deck size, the plugin seems more sluggish.
Village theme I composed for a commission!
Stream will be live shortly with some Haunting Ground! Feel free to drop by!
welp, the stock market went down by 7% because of corona today. Time to buy stocks?
Man, being able to edit my game WHILE testplaying it is like the most convenient thing EVER. Thank you, MV...it even makes up for the OGG thing. Well, almost.

Forum statistics

Threads
94,560
Messages
921,889
Members
124,423
Latest member
Detulovnoc
Top