Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: jayje on December 26, 2018, 08:57:28 pm

Title: [RMXP] Script call to show pictures?
Post by: jayje on December 26, 2018, 08:57:28 pm
any way I could script call show a picture based on a variable? IE Show Picture 1 \V[1]?
Title: Re: [RMXP] Script call to show pictures?
Post by: KK20 on December 27, 2018, 01:00:28 am
Note, this does not allow dynamic updating of the picture (every time you update the game variable's value, you will need to do the picture script call)

$game_screen.pictures[NUMBER].show($game_variables[1], ORIGIN, X, Y, ZOOM_X, ZOOM_Y, OPACITY, BLEND_TYPE)

replacing the constants above with actual values...

NUMBER = which picture ID to show (generally 1~100)
ORIGIN = upper-left (0) or center (1)
X/Y = screen coordinates
ZOOM_X/_Y = percentage to zoom in/out picture, default is 100
OPACITY = transparency, default 255
BLEND_TYPE = normal (0), add (1), sub (2)

...and the game variable ID accordingly.


Alternatively, you can change Game_Picture's name attribute to accessor:
attr_reader   :name                     # file name

into
attr_accessor :name                     # file name

And use the script call:
$game_screen.pictures[NUMBER].name = $game_variables[1]

Assuming all you want to do is change the graphic it uses and nothing else.
Title: Re: [RMXP] Script call to show pictures?
Post by: jayje on December 27, 2018, 07:41:37 am
I tried to use this:
$game_screen.pictures[12].show(Wraith, [0], 120, 120, 0, 0, 255, [0])

and got an error. So I messed up. I have a bunch of pictures, numbered 1-100, that correspond to the actor  IDs in my database. Each picture is called 'Face" followed by a number face1, face2, etc. How would I get it to show these pictures with a variable?

I'm Looking to do something similar to this. A combination of SHOW Choice and Pictures:
(https://almakesgames.files.wordpress.com/2018/12/example.jpg)
Title: Re: [RMXP] Script call to show pictures?
Post by: KK20 on December 27, 2018, 11:27:31 am
A lot of things wrong with that script call of yours.


Assuming $game_variables[1] holds some integer value,
name = 'face' + $game_variables[1].to_s
$game_screen.pictures[12].show(name, 0, 120, 120, 100, 100, 255, 0)
Title: Re: [RMXP] Script call to show pictures?
Post by: jayje on December 27, 2018, 09:21:31 pm
I got an error using that scriptlet:
name = 'face' + $game_variables
[920].to_s
$game_screen.pictures[12].show(name,
0, 120, 120, 100, 100, 255, 0)


Quote"TypeError occurred while running script. cannot convert Game_Variables into string"
Title: Re: [RMXP] Script call to show pictures?
Post by: KK20 on December 27, 2018, 09:55:50 pm
It's because the lines are broken up incorrectly. The [920].to_s needs to be on the same line as $game_variables. So put the line break after the plus sign.
name = 'face' +
$game_variables[920].to_s
Title: Re: [RMXP][RESOLVED] Script call to show pictures?
Post by: jayje on December 28, 2018, 01:12:15 am
Thanks for the headsup. I'll post the results later on.