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

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.
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
Because my regular expressions are rusty at best and I don't like using them. 😛
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)
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.
I just specifically don't want them using a "restart" button. A "shut down and begin again" button is fine.
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?
@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*
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.
@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.
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.
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.
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.
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.
Out of the Current topic Question: RGSS2 > Does Pixel movement works in pathfinding script or it uses the default tile movement?
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.
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.
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.?
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.
[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.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/