Advertisement
TheSixth

Change Picture Properties

Apr 24th, 2018
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.64 KB | None | 0 0
  1. =begin
  2. Change Picture Properties
  3. Made by: Sixth
  4.  
  5. Just a small snippet allowing the user to change the pictures' properties
  6. individually instead of setting them all at once like how those rigid default
  7. picture related event commands do.
  8.  
  9. You can use this script call:
  10.  
  11.   change_pic_prop(pic_id, prop_data1, prop_data2, ..., duration)
  12.  
  13. The pic_id must be an integer number and it will be the ID of the picture.
  14.  
  15. The prop_dataX arguments will be the properties you will change with the script
  16. call. Each of them is an array with 2 elements. The first element is always the
  17. name of the property, and the second element is the value you want to set for
  18. that property.
  19.  
  20. Here is a list of valid property names:
  21.  
  22.   'name'       # Changes the image used for the picture (string)
  23.   'x'          # Changes the X position of the picture (float number)
  24.   'y'          # Changes the Y position of the picture (float number)
  25.   'zoom_x'     # Changes the horizontal zoom level of the picture (0.0 to 100.0)
  26.   'zoom_y'     # Changes the vertical zoom level of the picture (0.0 to 100.0)
  27.   'opacity'    # Changes the opacity of the picture (0.0 to 255.0)
  28.   'blend_type' # Changes the blend type of the picture (0, 1 or 2)
  29.  
  30. They are all strings!
  31.  
  32. I wrote the possible value types these properties can take beside them in
  33. brackets. Note the difference between integer and float numbers, those are
  34. kinda important. If you use an integer number for an animated property, it will
  35. NOT work correctly! So, use float numbers for pretty much everything except for
  36. the 'name' and 'blend_type' properties.
  37.  
  38. You can enter as many as you want in the script call, and all of these changes
  39. will be executed at once.
  40.  
  41. The last part of the script call is an optional argument named as duration.
  42. If you use that, the changes will be animated, so it will change the specified
  43. properties within the specified duration gradually.
  44. This argument must come after all of your prop_data arguments, and it must be
  45. an integer from 1 to infinity!
  46.  
  47. You can NOT change the 'name' and 'blend_type' properties with a script call
  48. using the duration argument! If you do, your game will crash!
  49. The rest of them can be used with the duration argument.
  50.  
  51. The duration for the change is a global duration, sadly. That's how the default
  52. code is written, and I have no intention of rewriting it, too much hassle. :P
  53. So, if you do a second script call with the duration argument while the previous
  54. one is still not finished the change, it will rewrite the duration for those
  55. previous changes specified in the previous script call, so you may want to add
  56. a wait command after these before executing another script call to change
  57. something.
  58.  
  59. Examples:
  60.  
  61.   change_pic_prop(1,['name',"zack1_s1a"])
  62.   change_pic_prop(23,['name',"tutorial2"],['blend_type',0])
  63.   change_pic_prop(12,['zoom_x',25.0],['zoom_y',0.5],120)
  64.   change_pic_prop(35,['x',240.0],['y',320.0],['opacity',0.0],90)
  65.   chnage_pic_prop(24,['opacity',180])
  66.  
  67. =end
  68.  
  69. class Game_Picture
  70.  
  71.   attr_accessor :number, :name, :origin, :x, :y, :zoom_x, :zoom_y, :opacity,
  72.                 :blend_type, :tone, :angle,
  73.                 :target_x, :target_y, :target_zoom_x, :target_zoom_y,
  74.                 :target_opacity
  75.  
  76.   def change_prop(*changes)
  77.     if changes[-1].is_a?(Integer) # Animated
  78.       @duration = changes.pop
  79.       changes.each {|change| send('target_' + change[0] + '=', change[1]) }
  80.     else # Instant
  81.       changes.each {|change| send(change[0]+'=',change[1]) }
  82.     end
  83.   end
  84.  
  85. end
  86.  
  87. class Game_Interpreter
  88.  
  89.   def change_pic_prop(id,*changes)
  90.     screen.pictures[id].change_prop(*changes)
  91.   end
  92.  
  93. end
  94. # End of scipt! O_O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement