Default Variables

futrchamp

Musician
Veteran
Joined
Oct 7, 2013
Messages
182
Reaction score
470
First Language
English
Primarily Uses
RMMV
Default Variables v1.0
by futrchamp
 ​
This script simply allows you to set certain variables to have a value that is set when the game starts.

Instructions:

Paste into the script editor below materials and above main.

Change the numbers in the Variables= line to whichever variables you want to set.

Change the numbers in the Values= line to the corresponding values for each variable.

For example:

Variables=[2,3,6,8,9]

Values=[1,2,3,10,56]

Would set variable 2 to 1, variable 3 to 2, variable 6 to 3, and so on.

You can have as many variables in the array as you want, as long as each is assigned a value.

 

Compatibility:

Should be compatible with just about any script that doesn't modify the same things. Report any issues and I will try to make a patch for the script in question.

 

Terms of Use:

Usable in any project, commercial or non-commercial, with credit appreciated, but not required.

 

Code:
# Default Variables v1.0# by futrchamp# This script simply allows you to set certain variables to have a value that is # set when the game starts.# Instructions:# Change the numbers in the Variables= line to each variable you want to set.# Change the numbers in the Values= line to the corresponding values for each # variable.# For example:# Variables=[2,3,6,8,9]# Values=[1,2,3,10,56]# Would set variable 2 to 1, variable 3 to 2, variable 6 to 3, and so on.# You can have as many variables in the array as you want, as long as each is # assigned a value.module FutrDefaultVar  # Set the variables to be changedVariables=[2,3,6,8,9]  # Set corresponding valuesValues=[1,2,3,10,56]endclass Game_Variablesalias initialize_futrdefaultvars initializedef initialize(*a,&    initialize_futrdefaultvars(*a,&    i=0    while i<FutrDefaultVar::Values.length    @data[FutrDefaultVar::Variables[i]] = FutrDefaultVar::Values[i]    i+=1    endendend
 

 

 
 

Spearnear

Villager
Member
Joined
Aug 8, 2014
Messages
15
Reaction score
0
First Language
English
Primarily Uses
You're a life saver thanks! I've been looking for something like this for a while.  Is it possible to set conditional branches with that script too? 

Meaning:

if variable 1 = 2

then make variable 3 = 3

else if variable 1 = 3

then make variable 3 = 2

Variable 1's value could depend on something like the year or time of day (I'm using a real time clock script).

This would be so useful for me if it's possible to do this calculation beforehand instead of need to make an autorun script event for everything involving variables at the start of a map. 

12.jpg
 
Last edited by a moderator:

Gothic Lolita

YouTube Starlet
Veteran
Joined
Oct 21, 2014
Messages
1,132
Reaction score
197
First Language
German
Primarily Uses
RMMV
Is it possible to write something like thIs?

Variables=[1, 2]

Values=[graphics.width, graphics.height]

It would be super useful for me. :) (\s/)
But your script is allready amazing, because I've got tons of variables that need to be set up at the beginning of the game. :) /)

Edit: It works so far, tried that. But it can't actually read out the changed resolution I have only shows me up the 544x416 that is basic resolution. :/
Is there a chance to change that?
 
Last edited by a moderator:

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
Just a small tip on your code, you could use a hash(key-value pair) to make the configuration a little bit easier for the user.

Nevertheless its a simple and nice idea and can save some work for the user, well done :)
 

Spearnear

Villager
Member
Joined
Aug 8, 2014
Messages
15
Reaction score
0
First Language
English
Primarily Uses
Is it possible to write something like thIs?

Variables=[1, 2]

Values=[graphics.width, graphics.height]

It would be super useful for me. :) (\s/)

But your script is allready amazing, because I've got tons of variables that need to be set up at the beginning of the game. :) /)

Edit: It works so far, tried that. But it can't actually read out the changed resolution I have only shows me up the 544x416 that is basic resolution. :/

Is there a chance to change that?
I'm actualy curious why you need to do that.  Want the game to be changing window size on the fly?
 

Gothic Lolita

YouTube Starlet
Veteran
Joined
Oct 21, 2014
Messages
1,132
Reaction score
197
First Language
German
Primarily Uses
RMMV
Yes, I have a different resolution sizes.
But allready got a script, that does this trick without writing to a variable. :D
But may use it anyway, for things like write a character level to a variable. (\s/)
 

tale

Volunteer
Veteran
Joined
Dec 16, 2016
Messages
807
Reaction score
1,358
First Language
English
Primarily Uses
N/A
Fixed script format, credit futrchamp. And thank you Roninator2 for your help/ input.
Edit: included (*argv, &argb) after def initialize (thanks for the update)

Code:
# Default Variables v1.0
# by futrchamp
# This script simply allows you to set certain variables to have a value that is
# set when the game starts.
# Instructions:
# Change the numbers in the Variables= line to each variable you want to set.
# Change the numbers in the Values= line to the corresponding values for each
# variable.
# For example:
# Variables=[2,3,6,8,9]
# Values=[1,2,3,10,56]
# Would set variable 2 to 1, variable 3 to 2, variable 6 to 3, and so on.
# You can have as many variables in the array as you want, as long as each is
# assigned a value.

module FutrDefaultVar
# Set the variables to be changed
    Variables=[2,3,6,8,9]
# Set corresponding values
    Values=[1,2,3,10,56]
end

class Game_Variables
    alias initialize_futrdefaultvars   initialize
   def initialize(*argv, &argb)
        initialize_futrdefaultvars(*argv, &argb)
        i=0
        while i < FutrDefaultVar::Values.length
            @data[FutrDefaultVar::Variables[i]] = FutrDefaultVar::Values[i]
            i+=1
        end
    end
end
 
Last edited:

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

Latest Threads

Latest Profile Posts

Almost to the finish line!... or the starting... since it's just the demo. :kaomad2:

Having problems with enemy/monster designs. :kaosigh:
While we prepare the official trailer, enjoy this kind-of-second teaser! ^^
-Ele
New Episodes of RPG Shenanigans Uploaded to Youtube!

Episode 5 - Surprise Party!
Youtube Link:
Episode 6 - Killer Gin
Youtube Link:
Episode 7 - Gaia's Melody: Echoed Melodies
(Coming soon!)

Episode 8 - Clarent Saga: Tactics
(Coming soon!)

Episode 9 - Star Shift
(Coming soon!)
When the Map Generator throws in the assets in the most dumbest way possible - your path is blocked :D

Forum statistics

Threads
107,566
Messages
1,030,610
Members
139,671
Latest member
WDRS
Top