The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Tenraah on August 15, 2010, 02:37:37 AM

Title: Change Picture Angle?
Post by: Tenraah on August 15, 2010, 02:37:37 AM
Anyone know what the script is to set a picture's angle in RMXP?
I made a time-of-day deal in my game with a working digital clock in the menu, but I was thinking of how cool it would be to have a working analog clock, or a clock tower somewhere.  I noticed looking around in Game_Picture that it looks like you might be able to set a picture's angle without it being set to rotate.  I have some basic scripting knowledge so I don't know how I'd make that happen.  I searched at rmrk.net and hbgames.org with out any help.
Title: Re: Change Picture Angle?
Post by: cozziekuns on August 15, 2010, 03:03:02 AM
I haven't toyed around with RPG Maker XP for a while, but something like $game_screen.pictures[picture number].angle = angle in degrees, in a script call should work.
Title: Re: Change Picture Angle?
Post by: Tenraah on August 15, 2010, 03:42:17 AM
Error  :(
"NoMethodError occurred while running script.
undefined method 'angle=' for #<Game_Picture:0x2725168>"
I've tried messing with a bunch of variations on that with no success, too.
Title: Re: Change Picture Angle?
Post by: cozziekuns on August 15, 2010, 03:43:43 AM
Ah, my bad. Go to Game_Picture and change the line "attr_reader :angle" to "attr_accessor :angle"
Title: Re: Change Picture Angle?
Post by: Tenraah on August 15, 2010, 03:53:18 AM
It works!     :D
Now I just have to whip up some art and make the event...
Thanks again!
Title: Re: Change Picture Angle?
Post by: Tenraah on August 15, 2010, 05:25:48 AM
Allright... I'm trying to make the event to make a clock now, but I'm stuck.
Can you tell me why this doesn't work?
hour = $game_variables[155] / 60 % 60
min = $game_variables[155] % 60
if hour >= 12
  hour = hour - 12
end
hour = sprintf("%2d", hour)
min = sprintf("%2d", min)
$game_screen.pictures[3].angle = hour
* 20
$game_screen.pictures[4].angle = min
* 6

Just brings up the error "SyntaxError occurred while running script."
$game_variables[155] is the variable I used to track the time.  Counts up 1 every 20 frames, resets to 0 at 1440.
I'm trying to learn  :)

Edit: After messing around with this for a few hours, it seems like the other scripts involved in showing pictures can't read that sprintf stuff... guess I'd have to make a million conditional branches in an event to make it work this way then :(
Title: Re: Change Picture Angle?
Post by: Nhoj_yeR on August 21, 2010, 01:31:59 PM
hour = sprintf("%2d", hour)
min = sprintf("%2d", min)

remove these lines and it will be fine. ;)
these lines make the hour and min variables strings but you need integers for angle.