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

Is there a script call to update only the opacity of a picture?

edit: While I'm at it, is there a script call for everything else in there? I'd love it if I could use variables for the size of the picture.
Is there a script call to update only the opacity of a picture?
Code:
class Game_Picture    def opacity=(val)    @opacity = val  endend
Script call,
Code:
$game_map.screen.pictures[1].opacity = 128
Assuming you are on the map, and you want to adjust picture 1.
awesome people are awesome. Thanks guys
Hi Tsuki, I managed to figure out how to change zoom_x using that syntax. I'm wondering if there's a way to call the update with a duration time? So instead of immediately becoming that value, it would change over time according to the duration.
I believe you can just set the duration as well and it will handle it automatically.


If not, I think it is the easiest way to write it.
hehe I wish I could say I figured it out or I know how to do that. I tried adding [@duration = d] and changed the parameters to (val, d) but I can't get it to work, of course I'm sure I'm just doing it wrong.
Is there any way to use attr_accessor to access class variables(@@variable_name)? I've tried it and it always returns them as nil, even though they have a variable within the class. I am accessing the class through a global variable, but whenever I try to get the class variables, nothing. Do they only work with instance variables, or do I have to write a custom method for each class variable to get it's value?
http://stackoverflow.com/questions/895747/how-can-rubys-attr-accessor-produce-class-variables-or-class-instance-variables

Code:
class TYourClass  class << self    attr_accessor :class_instance_variable  endend
You have probably done similar things when you were adding stuff to DataManager or BattleManager.
I've had a quick look and can't find it ... if you have several items that trigger the same common event, is the item id saved somewhere, so in the common event you can check what item was used?

I've found this in Game_Battler, but it doesn't save the item id anywhere, and some items I want to have None as the target:

#-------------------------------------------------------------------------- # * [Common Event] Effect #-------------------------------------------------------------------------- def item_effect_common_event(user, item, effect) end... oh, I think this is it - in Game_Battler:

Code:
  #--------------------------------------------------------------------------  # * Apply Effect of Use to Other Than User  #--------------------------------------------------------------------------  def item_global_effect_apply(effect)    if effect.code == EFFECT_COMMON_EVENT      $game_temp.reserve_common_event(effect.data_id)    end  end
So it looks like it saves the common event id, but not the id of the item (or the item itself) that's triggering it. So I'd need to add it. Right?
Hi Tsuki, I managed to figure out how to change zoom_x using that syntax. I'm wondering if there's a way to call the update with a duration time? So instead of immediately becoming that value, it would change over time according to the duration.
I hoppe you are still looking for it.

class Game_Picture  def opacity=(val)    @opa =-1 if val[0] < @opacity    @opa = 1 if val[0] > @opacity        @opa *= (val[0].to_f)/val[1]    @fr = val[1]  end   def update    update_opa if @fr    update_move    update_tone_change    update_rotate  end   def update_opa    @fr-=1    if @fr==0      @fr=nil    end    @opacity += @opa  endendCall would be:

$game_map.screen.pictures[1].opacity =[30,100]The opacity of picture 1 will be set to 30 over 100 frames.

regards Bot
thanks MeridianBot. I'm wondering if this is correct if I were to change it to just zoom_x?

Code:
class Game_Picture  def zoom_x=(val)    @z_x =-1 if val[0] < @zoom_x    @z_x = 1 if val[0] > @zoom_x        @z_x *= (val[0].to_f)/val[1]    @fr = val[1]  end    def update    update_z_x if @fr    update_move    update_tone_change    update_rotate  end   def update_z_x    @fr-=1    if @fr==0      @fr=nil    end    @zoom_x += @z_x  endend
yes but be careful don't use the zoom from the maker.

This would Frick up the script.

regards Bot
What do you mean by don't use the zoom from the maker? If I use that, I can't use the "move picture" command anymore?

Also, I tested out the script I posted, and it's not behaving the way I expect it to.

What I'm doing is inputting a variable for the parameter:

$game_map.screen.pictures[31].zoom_x =[$game_variables[138],20]

The variable maxes at 100 and decreases by about 30 every time I call it (for testing purposes).

However, when I call it, it fluctuates the picture to what seems like random numbers.

wtfhealth.png


The red health bar at the top should be the percentage of variable 138.

Edit2:

on the other hand, this works perfectly:

class Game_Picture
 
  def zoom_x=(val)
    @zoom_x = val
  end
end
    


$game_map.screen.pictures[31].zoom_x = $game_variables[138]
Except it doesn't have the duration effect of course.

Edit3: I believe a script call equivalent of "Move Picture" would also work perfectly for this situation. Yeah, it works for this purpose, thanks so much for your help Meridian!
For a window, is there a way to get an image under the cursor, or do I need to draw the image separate from the window to achieve that?
blt to the window contents is what gives you images under the cursor. See how the faces and icons are drawn in Window_Base.
I thought blts were under the cursor as well, but in fact, that does not appear to be the case. If you change the cursor highlight dark enough, you'll notice that the cursor does not appear above the face picture in the default menu in both VX and Ace (Using Ace in this case since I did not mention it). This is fine most of the time, but I have an image that is larger than the cursor area.
Does anyone know where RGSS3 is defined? I understand that it is within the RGSS301.dll, but I can't find which call in there actually writes it. I'm trying to write a separate ruby program that is going to read the scripts file. It's not going to do anything bad, but I was wondering if anyone knew how to get it? Honestly I probably can just write dummy definitions for everything and use that, since it isn't actually going to run the code, but I'd still like to know where I can get it all loaded up.

I would have assumed RGSSInitialize3 would do it, but nope, even doing that and reading the scripts file gave an error saying the Sprite class is undefined.
Trying to extract scripts from the rgssad file using an external program would be breaking the terms of the EULA.
that is a topic i was quite interested in also, in a slightly different way..

how would i tell the game to read my scripts from a different folder.. OTHER THAN GAME.INI..

im thinking maybe having 1 single script in the script editor, game.ini tells the game to load the scripts from the normal place (Data Folder) which then reads a script to tell it which scripts to import and from where..

maybe something along the lines of...

files = ["randomfile.txt", "randomfile_II.txt, "lastradnomfile"] files.each do |file|  $RGSS3_SCRIPTS << Marshal.load(file)endobviously it would need quite a bit more code than that, buit i am just wondering if its possible / easy to set something like this up ?
Use TDS's script disabler to see how to load scripts.


http://forums.rpgmakerweb.com/index.php?/topic/3687-script-disabler/

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