Jump to content
kal

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

Recommended Posts

I've got a question about bitmaps...

When a bitmap moves to the left, and its X coordinate becomes negative, it's still displayed in-game. However, when it's moved upwards and its y coordinate becomes negative, it just disappears (does not apply for all bitmaps). Can anyone explain me how this works? Or has it something to do with the viewports? (just hate those things)

 

 

Z order and Y coordinates are mixed in RGSS3, so you need to take care about this, an solution is to use an Viewport with hight Z order, to be upper that map, you need 300+.

Share this post


Link to post
Share on other sites

Curious question. What is the point of the import statement in most scripts?

 

Just fancyness and innecessary use of memory as global variable.

 

There a lot of scripters that add the 'imported' thinking that is important or must be there, but in the 99% they even don't use that.

 

The real reason, and the original, if I remember begin with the KGC scripts that add a global variable to identify his scripts and also to add requirement for other scripts and disabled when a required script isn't installed, like:

 

Script 1
$KGC << 'Script One'
end

Script 2
if $KGC.include?('Script One')
enable script
end
end

 

After that many scripters begin to use it with the same reason but in some point this become useless and just a bad habit, users of SDK used the script logging that offered a real reason to use a variation of the 'imported' thing.

----

 

As i said, the modern use of the imported is unknow for me, for example some yanfly script:

 

$imported = {} if $imported.nil?
$imported["YEA-BattleEngine"] = true

 

and in the plugins should be included some kind of verifier, but none, maybe it is used for internal revisions, but no need of leaving as public code because is useless.

----

 

Of course not saying is totally useless, but there should be a GLOBAL way for all the scripters to use a log system, I saw someone tried to recreate the SDK for VXAce, a really good idea.

Edited by Mephistox

Share this post


Link to post
Share on other sites

I'd just like to add my reasoning for using the '$imported' variable.

In VX I made a lot of scripts that all worked together, but edited the same various parts of script. So I made (for example) my Passive Skills script check that the conditions set out in my Conditional Skills script were met before you could use that passive skill.

But what if someone wanted to use my Passive Skills without my Conditional Skills?

So I included the '$imported' variable so I could check that they had the necessary script before running a section of code (that would crash the game if they didn't have the script).

 

In short, I use it to add additional features/compatibility to scripts only if the necessary counterpart scripts are also installed

 

:EDIT:

For a VXAce example, my Linked Skills & Enchanted Equipment script checks for my Passive Skills script so you can add enchanted passive skills.

Edited by syvkal

Share this post


Link to post
Share on other sites

After that many scripters begin to use it with the same reason but in some point this become useless and just a bad habit, users of SDK used the script logging that offered a real reason to use a variation of the 'imported' thing.

 

Some people might have written some nice scripts so I can quickly check whether the user decided to use that script in their project.

 

If the convenient script isn't there I fall back to other behaviors.

I don't have to rely on other scripts but if it's there, no reason not to use it.

Share this post


Link to post
Share on other sites

I'm a bit new to RMVXAce, so I apologize if this question has already been asked to death. How would I go about adding new parameters to characters?

 

The database doesn't seem to allow any kind of "custom features" under the character class definitions, nor does there seem to be a way to add more parameters to the default 8. I see there's some additional "Ex" and "Sp" attributes, but there doesn't seem to be any way to add to those either. How would I go about modifying one of those attribute lists (to create new attributes, and ideally have the database recognize them)? Are they defined somewhere in the script editor?

 

Edit: Actually, disregard that, I think I've found the answer. I'll leave this here in case someone else had a similar question.

Edited by Kaelan

Share this post


Link to post
Share on other sites

This is probably a newbie question, but how can I go about adding different kinds of "database items" than the default in the GUI, for example, instead of skills/classes/items/weapons/actors/enemies, add an "upgrades" item which can be referenced directly with a description, name, and all the other inherited methods & parameters from "Game_BaseItem"?

 

I know I can extend the old class and all, but do I need to hardcode in the information into Game_BaseItem, or is the database flexible enough such that I'm barking up the wrong tree?

Share this post


Link to post
Share on other sites

I also have a newbie question. Presumably, there's a place somewhere in the script database that sets the amount by which TP increases if a character is attacked in combat. Where is that place? (I'd like to modify the rate of increase--currently, a character whose skillset revolves around drawing attacks gains TP at a much faster rate than other characters.)

Share this post


Link to post
Share on other sites

Game Battler.

I think it's only this one though

 

 #--------------------------------------------------------------------------
 # * Charge TP by Damage Suffered
 #--------------------------------------------------------------------------
 def charge_tp_by_damage(damage_rate)
   self.tp += 50 * damage_rate * tcr
 end

Share this post


Link to post
Share on other sites

That's peculiar. When I change the 50 in the above script to 0, the change takes effect when playing the game in debug mode, but does not take effect when using "Battle Test" in the database. Still, if it's working in debug, it'll probably work in the finished game, and that's good enough for me. Thanks!

Share this post


Link to post
Share on other sites

Is there a simple way to directly access the nth element of a Hash in Ruby? (in a situation where the elements were inserted in a sorted order and the keys aren't numbers).

Share this post


Link to post
Share on other sites

Cannot guarantee order but you can do something like

 

hash.values[n]

 

Or something along those lines.

Unless you want the n'th key/value pair?

Edited by Tsukihime

Share this post


Link to post
Share on other sites

I did, but keys[n] and values[n] seems to work well enough. Can't believe I missed those functions, been looking over the Hash definition for something like that for half an hour now.

 

This is more efficient than just iterating to the nth element manually, yes?

Share this post


Link to post
Share on other sites

X, you need to save the game between changing a script and doing a test battle. Maybe that's why you didn't see a change when testing?

Share this post


Link to post
Share on other sites

I did, but keys[n] and values[n] seems to work well enough. Can't believe I missed those functions, been looking over the Hash definition for something like that for half an hour now.

 

This is more efficient than just iterating to the nth element manually, yes?

 

Don't know, benchmark it lol

Share this post


Link to post
Share on other sites

Meh, it's not that important. I just want to make sure it's not creating a whole copy of the hash values in the background or something every time I index into it like that. If there's nothing absolutely horrible like that going on, this works for me

Share this post


Link to post
Share on other sites

I imagine it's still creating a copy of all the values, which in itself is another concern.

Then again, why use a hash if you need to index it? An associative array would seem more appropriate.

Share this post


Link to post
Share on other sites

I'm indexing it with the key (which is a symbol w/ the name of the struct in the hash) in all the code that I control, but I need the numerical index to grab values to use inside a draw_item call in a menu, and those are based on the position of the cursor, which is an integer.

 

I could just change it to an array to fix it for the item drawing, but all that would do is make me have to search for the right struct whenever I need them by name in my own code. If it's copying stuff, maybe I should just iterate through it every time (it's ugly, but better than creating/deleting memory). Don't think I can get away from having to search through it one way or the other.

 

Edit: Actually, since the size of the hash never changes in the game, I'll just create a parallel array that maps an index to a hash key. Only happens during init, and prevents any kind of searching or copying during runtime. Hurray for not having terrible code, lol

Edited by Kaelan

Share this post


Link to post
Share on other sites

Heya, I'm new to RGSS3 but I have 4 years worth of actual programming experience, so I thought I'd dive into it a bit. Coming to Ruby (or the RGSS3 library specifically, I know it's different) is quite a difference from a C based language.

 

Anyhow, I'm experimenting with my first script, and it fails to work. I've uploaded it here on pastebin: http://pastebin.com/6muiv3xp

 

What the script is supposed to do is that all events that have a <fm> tag in the comments should only show up if the players fm_view_on variable is true. However, whenever you provide the game with an event that has an <fm> tag in it, it throws the error "undefined method `fm_event=' for #<Game_Event:0x88ed9a8>", when Game_CharacterBase in the script blatantly defines "attr_reader :fm_event".

 

And as I've gathered, Game_Event inherits from Game_CharacterBase (through Game_Character), so I'm very confused as to what's going wrong here. It's probably a simple error.

 

(I apologize if I should have made this its own thread, please tell me if this is the case.)

Share this post


Link to post
Share on other sites

As you guessed, it is a very simple error.

 

There are three kinds of attr_

  • attr_reader defines a get method, it returns the variable.
    attr_reader :fm_event

    equals to

    def fm_event; @fm_event; end


  • attr_writer defines a set method, it sets the variable to a value.
    attr_writer :fm_event

    equals to

    def fm_event=(value); @fm_event = value; end


  • Finally, there is attr_accessor, which is a combination of attr_reader and attr_writer, creating both methods.

In your case, you used attr_reader, when you should have used attr_accessor (as I assume you want to have the reading ability as well).

Share this post


Link to post
Share on other sites

Thank you, that did get rid of the problem. However, I don't seem to actually be able to effect anything in Game_Event.

Fixed script here: http://pastebin.com/1x8fgXiF As you can see, update calls refresh_fm_state, which runs

@through = !$game_variables[FM_World::FM_VIEW_SWITCH]

 

This piece of code should, if it were not for the issue, set the events Through parameter to the opposite of the switches state. So if the switch is off, (FM View is off), the events Through should be on. However, that doesn't happen. The event in question has its Through off at all times, and its transparency as well.

Edited by Sigma

Share this post


Link to post
Share on other sites

If you're checking switch state, switches are stored in $game_switches

Share this post


Link to post
Share on other sites

That probably don't deserve it's own topico, since it's only a matter of finding the thing (wich is exactly my problem), so, here it is: at older makers I liked to change the EXP formulas in the scripts so I wouldn't need to understand the heavy math behind the maker own formulas, and still be able to twist it in a interesting way (mostly to make it simpler for me when I was trying to give a certain monster it's exp value). The problem is that I can't find the formula on Ace, for some reason, or it has changed the names of the variables so much I don't know what they are anymore. Any clue?

Share this post


Link to post
Share on other sites

The formulas aren't in the scripts anymore. They're in the database. Check the Skills and Items tabs, and look at the Damage box. You can put the formula in there. Also check the help file for instructions and examples.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted