Setting a variable when the game starts

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
I am using a code in the materials section to make sure that the first 5 variables in my project are set when the game starts. This is my code:

class << DataManager alias :some_random_alias_init :init def self.init some_random_alias_init $game_variables[1] = 0 $game_variables[2] = -150 $game_variables[3] = -125 $game_variables[4] = 300 $game_variables[5] = 275 endend(code provided by KockaAdmiralac_FINALLY)

it works, the variables are set when the game starts ... but I discovered another problem.

I'm not sure if this counts as a question about scripting, but the reason I need those variables set when the game starts is because I'm using them for my portrets(they represent the drawing positions for the show_picture command). With this script the variables are changed(I press F9 and I can see they are changed) but the pictures are not drawn on the right positions.

In the Show Picture window I have the Display Position set to Variable, and there I set the variables that I need (In most cases x = game_variables[3] and y = game_variables[1])

I press F9 and game_variables[3] is set to be -125 but the X position in which the image is shown is 0...

I really don't know what to do about this ...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I've moved this thread to VX Ace Support. Please be sure to post your threads in the correct forum next time. Thank you.


You know, you don't need to do this in script. Just create a parallel process event on your starting map that sets the variables, then turns on a self switch with a new page conditioned by that self switch to ensure it doesn't run again.


In your Show Picture command, do you set the origin to the top left, or to the centre?


And do you change the variables throughout the game? If you don't, why are you using variables at all? Why not just use coordinates in the Show Picture command?
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
In the Show Picture command I have it set to the top left

And yes they change throughout the game, depending on the number of portrets on the screen (if it's one guy then he's centered, if there are 2 they are side to side and so on)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Can you show a screenshot of the Show Picture command in your event, with all the settings as you've used them, and a screenshot of what you see in the game?


Are you using any screen resizing scripts or any "system" or "core" or "engine" type scripts?
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
Are you using any screen resizing scripts or any "system" or "core" or "engine" type scripts?
I do. I use the Yanfly Engine Ace (the core engine)

And these are the screenshots

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,420
Reaction score
7,709
First Language
German
Primarily Uses
RMMV
why did you set the X-coordinate to a negative number?

Do you have that much of a transparent area around the bust on the picture?

The regular method would be to make sure that there is no transparent area other than needed around the bust, and setting the X-Coordinate to zero for a left-corner display (or even slightly above zero for a buffer between the left border and the left part of the picture.

Can you attach the bust? I think we have to see how large the transparent frame on it is to solve this problem.
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
why did you set the X-coordinate to a negative number?

Do you have that much of a transparent area around the bust on the picture?

The regular method would be to make sure that there is no transparent area other than needed around the bust, and setting the X-Coordinate to zero for a left-corner display (or even slightly above zero for a buffer between the left border and the left part of the picture.

Can you attach the bust? I think we have to see how large the transparent frame on it is to solve this problem.
Does the image size really matter that much?

Well this is the image for that character



Yeah it's big, but that's cause I want the size to fit all the characters. And some of the characters are really big.



Like that guy for example
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Yes, the image size matters. Because you set the coordinates based on a top left origin. So if you set it to 0,0 and have a whole bit transparent area to the left of the visible sprite, it's going to push the sprite to the middle of the screen.


You'd be better off setting the coordinates where you want the MIDDLE of the image to be, and use Center for the origin.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

This is relevant so much I can't even!
Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect

Forum statistics

Threads
105,998
Messages
1,018,218
Members
137,777
Latest member
Bripah
Top