I was going through my list of features I need for my online project and I was looking for a way to display and modify very high values. Since decimal values can become incorrect and the standard var limit is 999999, I just simply created custom values for this purpose.

Below you will find the code for 3 scripts. It's the same code, just different value types. The code shown below is just a basic method of taking multiple vars and modulating them into a single value. These values can be displayed on screen and lets you check for any value within it's limits. Basic addition and subtraction can also be used and the vars will modulate themselves.

The first value script holds 1 billion (999,999,999), the second value script holds 1 quadrillion (999,999,999,999,999) and the last value script I made just for fun and holds 1 nonillion (999,999,999,999,999,999,999,999,999,999).

I'll be using the billion and quadrillion values for player gold and epic month long raid boss events. Feel free to use this method for whatever you need it for. I'll eventually add more features, such as a multiplication factor.

ONE BILLION
Code:
/*
DEV NOTES :
When setting the values to add or subtract, all 3 must be set.
If you don't want to add to one of the value types, set it to 0.

Example : Adds or subtracts "1,500,250" to the value
set_millions = 1;
set_thousands = 500;
set_hundreds = 250;

Functions : After setting your value types, just call one of the following functions,
modulate_value(); //This will increase the total value based on your settings.
demodulate_value(); //This will decrease the total value based on your settings.

Review the code and comments for more information.
The "main" function at the bottom holds the examples used in this script.
*/

#include <acknex.h>

//Modulated vars that create a single value
typedef struct VALUES {
	int millions;
	int thousands;
	int hundreds;
} VALUES;

//Example of a Modulated value that can hold 999,999,999. (1 Billion).
//Value MIN = 0,0,0            (Zero)
//Value MAX = 999,999,999  (1 Billion)
VALUES *player_gold = {
	millions = 0;
	thousands = 0;
	hundreds = 0;
}

//Used to add/subtract to the modulated value
//Also used to show the value onscreen
var set_millions = 0;
var set_thousands = 0;
var set_hundreds = 0;	

//Displays a Modulated value on screen.
FONT* value_font = "Arial#28b";
PANEL* displayGoldValue = {
	pos_x = 290;
	pos_y = 280;
	digits (78, 0, -3, value_font, 1, set_millions);
	digits (85, 0, ",", value_font, 1, NULL);
	digits (123, 0, -3, value_font, 1, set_thousands);
	digits (130, 0, ",", value_font, 1, NULL);
	digits (168, 0, -3, value_font, 1, set_hundreds);
	flags = UNTOUCHABLE | ARIGHT;
}

//Calculates the values that are "added" and modulates that value between the 3 value types.
//Value MAX = 999,999,999  (1 Billion)
//Each value type will never exceed 999
void modulate_value() {
	
	//Original values to compare with add/subtract
	int oriValue[3];
	oriValue[0] = player_gold.millions;
	oriValue[1] = player_gold.thousands;
	oriValue[2] = player_gold.hundreds;
	
	//Adds the set amount to the value
	player_gold.millions += set_millions;
	player_gold.thousands += set_thousands;
	player_gold.hundreds += set_hundreds;
	
	//Modulate value type "HUNDREDS" : Over 999 and it will be modulated to increase the "THOUSANDS" value type.
	if(player_gold.hundreds  >= 1000){   
		player_gold.hundreds  %=1000; 
		if(oriValue[2]<=set_hundreds && player_gold.thousands>=1000 && player_gold.millions>=1000){   
			player_gold.hundreds  = 999;                 
			} else {
			player_gold.thousands+=1;
		}
	}
	
	//Modulate value type "THOUSANDS" : Over 999 and it will be modulated to increase the "MILLIONS" value type.
	if(player_gold.thousands >= 1000){
		player_gold.thousands %=1000;      
		if(oriValue[1]<=set_thousands && player_gold.millions>=1000){  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
			} else {
			player_gold.millions+=1;
		}
	}
	
	//Defines the MAX VALUE LIMIT : At 999, the "MILLIONS" value type can no longer be increased and stays fixed at 999.
	if(player_gold.millions >= 1000){  
		if(oriValue[0]>=set_millions){  
			player_gold.millions  = 999;  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
		}
	}
	
	//Set value type limits to 999
	if(player_gold.millions>=999){player_gold.millions=999;}
	if(player_gold.thousands>=999){player_gold.thousands=999;}
	if(player_gold.hundreds>=999){player_gold.hundreds=999;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_millions = player_gold.millions;
	set_thousands = player_gold.thousands;
	set_hundreds = player_gold.hundreds;
}


//Calculates the values that are "subtracted" and modulates that value between the 3 value types.
//Value MIN = 0,0,0            (Zero)
void demodulate_value() {
	
	int oriValue[3];
	oriValue[0] = player_gold.millions;
	oriValue[1] = player_gold.thousands;
	oriValue[2] = player_gold.hundreds;
	
	//Subtract the set amount from the value
	player_gold.millions -= set_millions;
	player_gold.thousands -= set_thousands;
	player_gold.hundreds -= set_hundreds;
	
	//DeModulate value type "HUNDREDS" : If 0, it will be modulated to decrease the "THOUSANDS" value type.
	if(player_gold.hundreds <= -1){
		player_gold.hundreds += 1000;
		if(oriValue[2]<=set_hundreds && player_gold.thousands<=0 && player_gold.millions<=0){   
			player_gold.hundreds  = 0;                 
			} else {
			player_gold.thousands-=1;
		}
	}

	//DeModulate value type "THOUSANDS" : If 0, it will be modulated to decrease the "MILLIONS" value type.
	if(player_gold.thousands  <= -1){ 
		player_gold.thousands += 1000;
		if(oriValue[1]<=set_thousands && player_gold.millions<=0){  
			player_gold.thousands  = 0;  
			player_gold.hundreds  = 0;                 
			} else {
			player_gold.millions-=1;
		}
	}
	
	//Correct value type "MILLIONS" : If 0, it will stay fixed at 0
	if(player_gold.millions  <= -1){ 
		if(oriValue[0]<=set_millions){  
			player_gold.millions  = 0;
			player_gold.thousands  = 0;
			player_gold.hundreds  = 0;
		}
	}
	
	//If there are negative values after calculations, set them to 0
	if(player_gold.millions<=0){player_gold.millions=0;}
	if(player_gold.thousands<=0){player_gold.thousands=0;}
	if(player_gold.hundreds<=0){player_gold.hundreds=0;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_millions = player_gold.millions;
	set_thousands = player_gold.thousands;
	set_hundreds = player_gold.hundreds;
}



void main () {
	wait(3);
	video_set(800,600,0,2);
	set(displayGoldValue,SHOW);
	
	//Examples of how to add and subtract to a modulated value and shows how to check for a specific value
	while(1) {
		//DEBUG :		
		//KEY 1 = Increase value until its maxed.
		if(key_1 == 1) {
			set_millions = 1;
			set_thousands = 2;
			set_hundreds = 3;
			modulate_value();
		}
		
		//KEY 2 = decrease value until it reaches zero.
		if(key_2 == 1) {
			set_millions = 1;
			set_thousands = 2;
			set_hundreds = 3;
			demodulate_value();
		}
		
		//KEY 3 = Add Value : Gain 93,274,821 gold
		if(key_3 == 1) {
			while(key_3==1){wait(1);}
			set_millions = 93;
			set_thousands = 274;
			set_hundreds = 821;
			modulate_value();
			printf("TEST : You just gained 93,274,821 Gold!",NULL);
		}
		
		//KEY 4 = Subtract Value : 89,324,177 gold
		if(key_4 == 1) {
			while(key_4==1){wait(1);}
			set_millions = 89;
			set_thousands = 324;
			set_hundreds = 177;
			demodulate_value();
			printf("TEST : You just lost 89,324,177 Gold!",NULL);
		}
		
		//KEY 5 = Increase only the millions value
		if(key_5 == 1) {
			set_millions = 1;
			set_thousands = 0;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 6 = Increase only the thousands value
		if(key_6 == 1) {
			set_millions = 0;
			set_thousands = 1;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 7 = Increase only the hundreds value
		if(key_7 == 1) {
			set_millions = 0;
			set_thousands = 0;
			set_hundreds = 1;
			modulate_value();
		}
		
		//KEY 8 = Checks for a certain amount of gold and subtracts it
		//Examples : 1,200,000  -  1,000  -  1,000,000,000  -  2,500
		if(key_8 == 1) 
		{
			while(key_8==1){wait(1);}
			if(player_gold.millions>=1 && player_gold.thousands>=200 || player_gold.millions>=2){
				printf("Thats a lot of gold! You have over 1,200,000!nYou now have enough to buy that version of A9 you always wanted.",NULL);
				set_millions = 1;
				set_thousands = 200;
				set_hundreds = 0;
				demodulate_value();
				} else {
				printf("You dont have enough gold! You need at least 1,200,000",NULL);
			}
		}
		
		draw_text("1 Billion",362,260,vector(255,255,255));
		draw_text("Key_1 : Increase Value",20,20,vector(255,255,255));
		draw_text("Key_2 : Decrease Value",20,40,vector(255,255,255));
		draw_text("Key_3 : Add Large Value",20,60,vector(255,255,255));
		draw_text("Key_4 : Subtract Large Value",20,80,vector(255,255,255));
		draw_text("Key_5 : Increase Value by One Million",20,100,vector(255,255,255));
		draw_text("Key_6 : Increase Value by One Thousand",20,120,vector(255,255,255));
		draw_text("Key_7 : Increase Value by One Hundred",20,140,vector(255,255,255));
		draw_text("Key_8 : Check for a certain amount and subtract it",20,160,vector(255,255,255));
		wait(1);
	}
}



ONE QUADRILLION
Code:
/*
DEV NOTES :
When setting the values to add or subtract, all 5 must be set.
If you don't want to add to one of the value types, set it to 0.

Example : Adds or subtracts "1,500,250" to the value
set_trillions = 0;
set_billions = 0;
set_millions = 1;
set_thousands = 500;
set_hundreds = 250;

Functions : After setting your value types, just call one of the following functions,
modulate_value(); //This will increase the total value based on your settings.
demodulate_value(); //This will decrease the total value based on your settings.

Review the code and comments for more information.
The "main" function at the bottom holds the examples used in this script.
*/

#include <acknex.h>

//Modulated vars that create a single value
typedef struct VALUES {
	int trillions;
	int billions;
	int millions;
	int thousands;
	int hundreds;
} VALUES;

//Example of a Modulated value that can hold 999,999,999,999,999. (1 Quadrillion).
//Value MIN = 0,0,0,0,0            (Zero)
//Value MAX = 999,999,999,999,999  (1 Quadrillion)
VALUES *player_gold = {
	trillions = 0;
	billions = 0;
	millions = 0;
	thousands = 0;
	hundreds = 0;
}

//Used to add/subtract to the modulated value
//Also used to show the value onscreen
var set_trillions = 0;
var set_billions = 0;
var set_millions = 0;
var set_thousands = 0;
var set_hundreds = 0;	

//Displays a Modulated value on screen.
FONT* value_font = "Arial#28b";
PANEL* displayGoldValue = {
	pos_x = 290;
	pos_y = 280;
	digits (33, 0, -3, value_font, 1, set_trillions);
	digits (40, 0, ",", value_font, 1, NULL);
	digits (78, 0, -3, value_font, 1, set_billions);
	digits (85, 0, ",", value_font, 1, NULL);
	digits (123, 0, -3, value_font, 1, set_millions);
	digits (130, 0, ",", value_font, 1, NULL);
	digits (168, 0, -3, value_font, 1, set_thousands);
	digits (175, 0, ",", value_font, 1, NULL);
	digits (213, 0, -3, value_font, 1, set_hundreds);
	flags = UNTOUCHABLE | ARIGHT;
}

//Calculates the values that are "added" and modulates that value between the 5 value types.
//Value MAX = 999,999,999,999,999  (1 Quadrillion)
//Each value type will never exceed 999
void modulate_value() {
	
	int oriValue[5];
	oriValue[0] = player_gold.trillions;
	oriValue[1] = player_gold.billions;
	oriValue[2] = player_gold.millions;
	oriValue[3] = player_gold.thousands;
	oriValue[4] = player_gold.hundreds;
	
	//Adds the set amount to the value
	player_gold.trillions += set_trillions;
	player_gold.billions += set_billions;
	player_gold.millions += set_millions;
	player_gold.thousands += set_thousands;
	player_gold.hundreds += set_hundreds;
	
	//Modulate value type "HUNDREDS" : Over 999 and it will be modulated to increase the "THOUSANDS" value type.
	if(player_gold.hundreds  >= 1000){   
		player_gold.hundreds  %=1000; 
		if(oriValue[4]<=set_hundreds && player_gold.thousands>=1000 && player_gold.millions>=1000 && player_gold.billions>=1000 && player_gold.trillions>=1000){   
			player_gold.hundreds  = 999;                 
			} else {
			player_gold.thousands+=1;
		}
	}
	
	//Modulate value type "THOUSANDS" : Over 999 and it will be modulated to increase the "MILLIONS" value type.
	if(player_gold.thousands >= 1000){
		player_gold.thousands %=1000;      
		if(oriValue[3]<=set_thousands && player_gold.millions>=1000 && player_gold.billions>=1000 && player_gold.trillions>=1000){  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
			} else {
			player_gold.millions+=1;
		}
	}
	
	//Modulate value type "MILLIONS" : Over 999 and it will be modulated to increase the "BILLIONS" value type.
	if(player_gold.millions  >= 1000){ 
		player_gold.millions  %=1000;  
		if(oriValue[2]<=set_millions && player_gold.billions>=1000 && player_gold.trillions>=1000){  
			player_gold.millions  = 999;  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
			} else {
			player_gold.billions+=1;
		}
	}
	
	//Modulate value type "BILLIONS" : Over 999 and it will be modulated to increase the "TRILLIONS" value type.
	if(player_gold.billions  >= 1000){  
		player_gold.billions  %=1000; 
		if(oriValue[1]<=set_billions && player_gold.trillions>=1000){  
			player_gold.billions  = 999;  
			player_gold.millions  = 999;  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
			} else { 
			player_gold.trillions+=1;
		}
	}
	
	//Defines the MAX VALUE LIMIT : At 999, the "TRILLIONS" value type can no longer be increased and stays fixed at 999.
	if(player_gold.trillions >= 1000){  
		if(oriValue[0]>=set_trillions){  
			player_gold.trillions  = 999;
			player_gold.billions  = 999;  
			player_gold.millions  = 999;  
			player_gold.thousands  = 999;  
			player_gold.hundreds  = 999;                 
		}
	}
	
	//Set value type limits to 999
	if(player_gold.trillions>=999){player_gold.trillions=999;}
	if(player_gold.billions>=999){player_gold.billions=999;}
	if(player_gold.millions>=999){player_gold.millions=999;}
	if(player_gold.thousands>=999){player_gold.thousands=999;}
	if(player_gold.hundreds>=999){player_gold.hundreds=999;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_trillions = player_gold.trillions;
	set_billions = player_gold.billions;
	set_millions = player_gold.millions;
	set_thousands = player_gold.thousands;
	set_hundreds = player_gold.hundreds;
}


//Calculates the values that are "subtracted" and modulates that value between the 5 value types.
//Value MIN = 0,0,0,0,0            (Zero)
void demodulate_value() {
	
	int oriValue[5];
	oriValue[0] = player_gold.trillions;
	oriValue[1] = player_gold.billions;
	oriValue[2] = player_gold.millions;
	oriValue[3] = player_gold.thousands;
	oriValue[4] = player_gold.hundreds;
	
	//Subtract the set amount from the value
	player_gold.trillions -= set_trillions;
	player_gold.billions -= set_billions;
	player_gold.millions -= set_millions;
	player_gold.thousands -= set_thousands;
	player_gold.hundreds -= set_hundreds;
	
	//DeModulate value type "HUNDREDS" : If 0, it will be modulated to decrease the "THOUSANDS" value type.
	if(player_gold.hundreds <= -1){
		player_gold.hundreds += 1000;
		if(oriValue[4]<=set_hundreds && player_gold.thousands<=0 && player_gold.millions<=0 && player_gold.billions<=0 && player_gold.trillions<=0){   
			player_gold.hundreds  = 0;                 
			} else {
			player_gold.thousands-=1;
		}
	}

	//DeModulate value type "THOUSANDS" : If 0, it will be modulated to decrease the "MILLIONS" value type.
	if(player_gold.thousands  <= -1){ 
		player_gold.thousands += 1000;
		if(oriValue[3]<=set_thousands && player_gold.millions<=0 && player_gold.billions<=0 && player_gold.trillions<=0){  
			player_gold.thousands  = 0;  
			player_gold.hundreds  = 0;                 
			} else {
			player_gold.millions-=1;
		}
	}
	
	//DeModulate value type "MILLIONS" : If 0, it will be modulated to decrease the "BILLIONS" value type.
	if(player_gold.millions  <= -1){ 
		player_gold.millions += 1000;
		if(oriValue[2]<=set_millions && player_gold.billions<=0 && player_gold.trillions<=0){  
			player_gold.millions  = 0;  
			player_gold.thousands  = 0;  
			player_gold.hundreds  = 0;                 
			} else {
			player_gold.billions-=1;
		}
	}
	
	//DeModulate value type "BILLIONS" : If 0, it will be modulated to decrease the "TRILLIONS" value type.
	if(player_gold.billions  <= -1){ 
		player_gold.billions += 1000;
		if(oriValue[1]<=set_billions && player_gold.trillions<=0){  
			player_gold.billions  = 0;  
			player_gold.millions  = 0;  
			player_gold.thousands  = 0;  
			player_gold.hundreds  = 0;                 
			} else { 
			player_gold.trillions-=1;
		}
	}
	
	//Correct value type "TRILLIONS" : If 0, it will stay fixed at 0
	if(player_gold.trillions  <= -1){ 
		if(oriValue[0]<=set_trillions){  
			player_gold.trillions  = 0;
			player_gold.billions  = 0;
			player_gold.millions  = 0;
			player_gold.thousands  = 0;
			player_gold.hundreds  = 0;
		}
	}
	
	//If there are negative values after calculations, set them to 0
	if(player_gold.trillions<=0){player_gold.trillions=0;}
	if(player_gold.billions<=0){player_gold.billions=0;}
	if(player_gold.millions<=0){player_gold.millions=0;}
	if(player_gold.thousands<=0){player_gold.thousands=0;}
	if(player_gold.hundreds<=0){player_gold.hundreds=0;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_trillions = player_gold.trillions;
	set_billions = player_gold.billions;
	set_millions = player_gold.millions;
	set_thousands = player_gold.thousands;
	set_hundreds = player_gold.hundreds;
}



void main () {
	wait(3);
	video_set(800,600,0,2);
	modulate_value();
	set(displayGoldValue,SHOW);
	
	//Examples of how to add and subtract to a modulated value and shows how to check for a specific value
	while(1) {
		//DEBUG :		
		//KEY 1 = Increase value until its maxed.
		if(key_1 == 1) {
			set_trillions = 5;
			set_billions = 4;
			set_millions = 3;
			set_thousands = 2;
			set_hundreds = 1;
			modulate_value();
		}
		
		//KEY 2 = decrease value until it reaches zero.
		if(key_2 == 1) {
			set_trillions = 5;
			set_billions = 4;
			set_millions = 3;
			set_thousands = 2;
			set_hundreds = 1;
			demodulate_value();
		}
		
		//KEY 3 = Add Value : Gain 57,256,937,274,821 gold
		if(key_3 == 1) {
			while(key_3==1){wait(1);}
			set_trillions = 57;
			set_billions = 256;
			set_millions = 937;
			set_thousands = 274;
			set_hundreds = 821;
			modulate_value();
			printf("TEST : You just gained 57,256,937,274,821 Gold!",NULL);
		}
		
		//KEY 4 = Subtract Value : 23,467,890,324,177 gold
		if(key_4 == 1) {
			while(key_4==1){wait(1);}
			set_trillions = 23;
			set_billions = 467;
			set_millions = 890;
			set_thousands = 324;
			set_hundreds = 177;
			demodulate_value();
			printf("TEST : You just lost 23,467,890,324,177 Gold!",NULL);
		}
		
		//KEY 5 = Increase only the trillions value
		if(key_5 == 1) {
			set_trillions = 1;
			set_billions = 0;
			set_millions = 0;
			set_thousands = 0;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 6 = Increase only the billions value
		if(key_6 == 1) {
			set_trillions = 0;
			set_billions = 1;
			set_millions = 0;
			set_thousands = 0;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 7 = Increase only the millions value
		if(key_7 == 1) {
			set_trillions = 0;
			set_billions = 0;
			set_millions = 1;
			set_thousands = 0;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 8 = Increase only the thousands value
		if(key_8 == 1) {
			set_trillions = 0;
			set_billions = 0;
			set_millions = 0;
			set_thousands = 1;
			set_hundreds = 0;
			modulate_value();
		}
		
		//KEY 9 = Increase only the hundreds value
		if(key_9 == 1) {
			set_trillions = 0;
			set_billions = 0;
			set_millions = 0;
			set_thousands = 0;
			set_hundreds = 1;
			modulate_value();
		}
		
		//KEY 0 = Checks for a certain amount of gold and subtracts it
		//For sanity reasons, keep the value detection within normal calculations and not uncommon values.
		//Examples : 1,200,000  -  1,000  -  1,000,000,000  -  2,500
		if(key_0 == 1) 
		{
			while(key_0==1){wait(1);}
			if(player_gold.millions>=1 && player_gold.thousands>=200 || player_gold.millions>=2 || player_gold.billions>=1 || player_gold.trillions>=1){
				printf("Thats a lot of gold! You have over 1,200,000!nYou now have enough to buy that version of A9 you always wanted.",NULL);
				set_trillions = 0;
				set_billions = 0;
				set_millions = 1;
				set_thousands = 200;
				set_hundreds = 0;
				demodulate_value();
				} else {
				printf("You dont have enough gold! You need at least 1,200,000",NULL);
			}
		}
		
		draw_text("1 Quadrillion",344,260,vector(255,255,255));
		draw_text("Key_1 : Increase Value",20,20,vector(255,255,255));
		draw_text("Key_2 : Decrease Value",20,40,vector(255,255,255));
		draw_text("Key_3 : Add Large Value",20,60,vector(255,255,255));
		draw_text("Key_4 : Subtract Large Value",20,80,vector(255,255,255));
		draw_text("Key_5 : Increase Value by One Trillion",20,100,vector(255,255,255));
		draw_text("Key_6 : Increase Value by One Billion",20,120,vector(255,255,255));
		draw_text("Key_7 : Increase Value by One Million",20,140,vector(255,255,255));
		draw_text("Key_8 : Increase Value by One Thousand",20,160,vector(255,255,255));
		draw_text("Key_9 : Increase Value by One",20,180,vector(255,255,255));
		draw_text("Key_0 : Check for a certain amount and subtract it",20,200,vector(255,255,255));
		
		wait(1);
	}
}



ONE NONILLION
Code:
/*
DEV NOTES :
When setting the values to add or subtract, all 5 must be set.
If you don't want to add to one of the value types, set it to 0.

Example : Adds or subtracts "1,000,500,000,250" to the value
set_oct_sep = 0;
set_sex_quin = 0;
set_quad_tri = 1;
set_bil_mil = 500;
set_thou_hun = 250;

Functions : After setting your value types, just call one of the following functions,
modulate_value(); //This will increase the total value based on your settings.
demodulate_value(); //This will decrease the total value based on your settings.

Review the code and comments for more information.
The "main" function at the bottom holds the examples used in this script.
*/

#include <acknex.h>

//Modulated vars that create a single value
typedef struct VALUES {
	int oct_sep;
	int sex_quin;
	int quad_tri;
	int bil_mil;
	int thou_hun;
} VALUES;

//Example of a Modulated value that can hold 999,999,999,999,999,999,999,999,999,999. (1 nonillion).
//Value MIN = 0,0,0,0,0            (Zero)
//Value MAX = 999,999,999,999,999,999,999,999,999,999  (1 nonillion)
VALUES *player_gold = {
	oct_sep = 0;
	sex_quin = 0;
	quad_tri = 0;
	bil_mil = 0;
	thou_hun = 0;
}

//Used to add/subtract to the modulated value
//Also used to show the value onscreen
var set_oct_sep = 0;
var set_sex_quin = 0;
var set_quad_tri = 0;
var set_bil_mil = 0;
var set_thou_hun = 0;	

//Displays a Modulated value on screen.
FONT* value_font = "Arial#28b";
PANEL* displayGoldValue = {
	pos_x = 220;
	pos_y = 280;
	digits (42, 0, -6, value_font, 1, set_oct_sep);
	digits (6, 0, ",", value_font, 1, NULL);
	digits (48, 0, ",", value_font, 1, NULL);
	digits (122, 0, -6, value_font, 1, set_sex_quin);
	digits (87, 0, ",", value_font, 1, NULL);
	digits (128, 0, ",", value_font, 1, NULL);
	digits (203, 0, -6, value_font, 1, set_quad_tri);
	digits (167, 0, ",", value_font, 1, NULL);
	digits (207, 0, ",", value_font, 1, NULL);
	digits (283, 0, -6, value_font, 1, set_bil_mil);
	digits (248, 0, ",", value_font, 1, NULL);
	digits (288, 0, ",", value_font, 1, NULL);
	digits (363, 0, -6, value_font, 1, set_thou_hun);
	digits (328, 0, ",", value_font, 1, NULL);
	flags = UNTOUCHABLE | ARIGHT;
}

//Calculates the values that are "added" and modulates that value between the 5 value types.
//Value MAX = 999,999,999,999,999,999,999,999,999,999  (1 nonillion)
//Each value type will never exceed 999999
void modulate_value() {
	
	int oriValue[5];
	oriValue[0] = player_gold.oct_sep;
	oriValue[1] = player_gold.sex_quin;
	oriValue[2] = player_gold.quad_tri;
	oriValue[3] = player_gold.bil_mil;
	oriValue[4] = player_gold.thou_hun;
	
	//Adds the set amount to the value
	player_gold.oct_sep += set_oct_sep;
	player_gold.sex_quin += set_sex_quin;
	player_gold.quad_tri += set_quad_tri;
	player_gold.bil_mil += set_bil_mil;
	player_gold.thou_hun += set_thou_hun;
	
	//Modulate value type "thou_hun" : Over 999999 and it will be modulated to increase the "bil_mil" value type.
	if(player_gold.thou_hun  >= 999999+1){   
		player_gold.thou_hun  %=999999+1; 
		if(oriValue[4]<=set_thou_hun && player_gold.bil_mil>=999999 && player_gold.quad_tri>=999999 && player_gold.sex_quin>=999999 && player_gold.oct_sep>=999999){   
			player_gold.thou_hun  = 999999;                 
			} else {
			player_gold.bil_mil+=1;
		}
	}
	
	//Modulate value type "bil_mil" : Over 999999 and it will be modulated to increase the "quad_tri" value type.
	if(player_gold.bil_mil >= 999999+1){
		player_gold.bil_mil %=999999+1;      
		if(oriValue[3]<=set_bil_mil && player_gold.quad_tri>=999999 && player_gold.sex_quin>=999999 && player_gold.oct_sep>=999999){  
			player_gold.bil_mil  = 999999;  
			player_gold.thou_hun  = 999999;                 
			} else {
			player_gold.quad_tri+=1;
		}
	}
	
	//Modulate value type "quad_tri" : Over 999999 and it will be modulated to increase the "sex_quin" value type.
	if(player_gold.quad_tri  >= 999999+1){ 
		player_gold.quad_tri  %=999999+1;  
		if(oriValue[2]<=set_quad_tri && player_gold.sex_quin>=999999 && player_gold.oct_sep>=999999){  
			player_gold.quad_tri  = 999999;  
			player_gold.bil_mil  = 999999;  
			player_gold.thou_hun  = 999999;                 
			} else {
			player_gold.sex_quin+=1;
		}
	}
	
	//Modulate value type "sex_quin" : Over 999999 and it will be modulated to increase the "oct_sep" value type.
	if(player_gold.sex_quin  >= 999999+1){  
		player_gold.sex_quin  %=999999+1; 
		if(oriValue[1]<=set_sex_quin && player_gold.oct_sep>=999999){  
			player_gold.sex_quin  = 999999;  
			player_gold.quad_tri  = 999999;  
			player_gold.bil_mil  = 999999;  
			player_gold.thou_hun  = 999999;                 
			} else { 
			player_gold.oct_sep+=1;
		}
	}
	
	//Defines the MAX VALUE LIMIT : At 999999, the "oct_sep" value type can no longer be increased and stays fixed at 999999.
	if(player_gold.oct_sep >= 999999+1){  
		if(oriValue[0]>=set_oct_sep){  
			player_gold.oct_sep  = 999999;
			player_gold.sex_quin  = 999999;  
			player_gold.quad_tri  = 999999;  
			player_gold.bil_mil  = 999999;  
			player_gold.thou_hun  = 999999;                 
		}
	}
	
	//Set value type limits to 999999
	if(player_gold.oct_sep>=999999){player_gold.oct_sep=999999;}
	if(player_gold.sex_quin>=999999){player_gold.sex_quin=999999;}
	if(player_gold.quad_tri>=999999){player_gold.quad_tri=999999;}
	if(player_gold.bil_mil>=999999){player_gold.bil_mil=999999;}
	if(player_gold.thou_hun>=999999){player_gold.thou_hun=999999;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_oct_sep = player_gold.oct_sep;
	set_sex_quin = player_gold.sex_quin;
	set_quad_tri = player_gold.quad_tri;
	set_bil_mil = player_gold.bil_mil;
	set_thou_hun = player_gold.thou_hun;
}


//Calculates the values that are "subtracted" and modulates that value between the 5 value types.
//Value MIN = 0,0,0,0,0            (Zero)
void demodulate_value() {
	
	int oriValue[5];
	oriValue[0] = player_gold.oct_sep;
	oriValue[1] = player_gold.sex_quin;
	oriValue[2] = player_gold.quad_tri;
	oriValue[3] = player_gold.bil_mil;
	oriValue[4] = player_gold.thou_hun;
	
	//Subtract the set amount from the value
	player_gold.oct_sep -= set_oct_sep;
	player_gold.sex_quin -= set_sex_quin;
	player_gold.quad_tri -= set_quad_tri;
	player_gold.bil_mil -= set_bil_mil;
	player_gold.thou_hun -= set_thou_hun;
	
	//DeModulate value type "thou_hun" : If 0, it will be modulated to decrease the "bil_mil" value type.
	if(player_gold.thou_hun <= -1){
		player_gold.thou_hun += 999999 + 1;
		if(oriValue[4]<=set_thou_hun && player_gold.bil_mil<=0 && player_gold.quad_tri<=0 && player_gold.sex_quin<=0 && player_gold.oct_sep<=0){   
			player_gold.thou_hun  = 0;                 
			} else {
			player_gold.bil_mil-=1;
		}
	}

	//DeModulate value type "bil_mil" : If 0, it will be modulated to decrease the "quad_tri" value type.
	if(player_gold.bil_mil  <= -1){ 
		player_gold.bil_mil += 999999 + 1;
		if(oriValue[3]<=set_bil_mil && player_gold.quad_tri<=0 && player_gold.sex_quin<=0 && player_gold.oct_sep<=0){  
			player_gold.bil_mil  = 0;  
			player_gold.thou_hun  = 0;                 
			} else {
			player_gold.quad_tri-=1;
		}
	}
	
	//DeModulate value type "quad_tri" : If 0, it will be modulated to decrease the "sex_quin" value type.
	if(player_gold.quad_tri  <= -1){ 
		player_gold.quad_tri += 999999 + 1;
		if(oriValue[2]<=set_quad_tri && player_gold.sex_quin<=0 && player_gold.oct_sep<=0){  
			player_gold.quad_tri  = 0;  
			player_gold.bil_mil  = 0;  
			player_gold.thou_hun  = 0;                 
			} else {
			player_gold.sex_quin-=1;
		}
	}
	
	//DeModulate value type "sex_quin" : If 0, it will be modulated to decrease the "oct_sep" value type.
	if(player_gold.sex_quin  <= -1){ 
		player_gold.sex_quin += 999999 + 1;
		if(oriValue[1]<=set_sex_quin && player_gold.oct_sep<=0){  
			player_gold.sex_quin  = 0;  
			player_gold.quad_tri  = 0;  
			player_gold.bil_mil  = 0;  
			player_gold.thou_hun  = 0;                 
			} else { 
			player_gold.oct_sep-=1;
		}
	}
	
	//Correct value type "oct_sep" : If 0, it will stay fixed at 0
	if(player_gold.oct_sep  <= -1){ 
		if(oriValue[0]<=set_oct_sep){  
			player_gold.oct_sep  = 0;
			player_gold.sex_quin  = 0;
			player_gold.quad_tri  = 0;
			player_gold.bil_mil  = 0;
			player_gold.thou_hun  = 0;
		}
	}
	
	//If there are negative values after calculations, set them to 0
	if(player_gold.oct_sep<=0){player_gold.oct_sep=0;}
	if(player_gold.sex_quin<=0){player_gold.sex_quin=0;}
	if(player_gold.quad_tri<=0){player_gold.quad_tri=0;}
	if(player_gold.bil_mil<=0){player_gold.bil_mil=0;}
	if(player_gold.thou_hun<=0){player_gold.thou_hun=0;}
	
	//Sets panel vars to the value types to update them on the screen.
	set_oct_sep = player_gold.oct_sep;
	set_sex_quin = player_gold.sex_quin;
	set_quad_tri = player_gold.quad_tri;
	set_bil_mil = player_gold.bil_mil;
	set_thou_hun = player_gold.thou_hun;
}



void main () {
	wait(3);
	video_set(800,600,0,2);
	modulate_value();
	set(displayGoldValue,SHOW);
	
	//Examples of how to add and subtract to a modulated value and shows how to check for a specific value
	while(1) {
		//DEBUG :		
		//KEY 1 = Increase value until its maxed.
		if(key_1 == 1) {
			set_oct_sep = 10021;
			set_sex_quin = 10021;
			set_quad_tri = 10021;
			set_bil_mil = 10021;
			set_thou_hun = 10021;
			modulate_value();
		}
		
		//KEY 2 = decrease value until it reaches zero.
		if(key_2 == 1) {
			set_oct_sep = 10021;
			set_sex_quin = 10021;
			set_quad_tri = 10021;
			set_bil_mil = 10021;
			set_thou_hun = 10021;
			demodulate_value();
		}
		
		//KEY 3 = Add Value : Gain 570,256,000,937,000,274,000,821,000 gold
		if(key_3 == 1) {
			while(key_3==1){wait(1);}
			set_oct_sep = 570;
			set_sex_quin = 256000;
			set_quad_tri = 937000;
			set_bil_mil = 274000;
			set_thou_hun = 821000;
			modulate_value();
			printf("TEST : You just gained 570,256,000,937,000,274,000,821,000 Gold!",NULL);
		}
		
		//KEY 4 = Subtract Value : 570,256,000,937,000,274,000,821,000 gold
		if(key_4 == 1) {
			while(key_4==1){wait(1);}
			set_oct_sep = 570;
			set_sex_quin = 256000;
			set_quad_tri = 937000;
			set_bil_mil = 274000;
			set_thou_hun = 821000;
			demodulate_value();
			printf("TEST : You just lost 570,256,000,937,000,274,000,821,000 Gold!",NULL);
		}
		
		//KEY 5 = Increase only the oct_sep value
		if(key_5 == 1) {
			set_oct_sep = 1003;
			set_sex_quin = 0;
			set_quad_tri = 0;
			set_bil_mil = 0;
			set_thou_hun = 0;
			modulate_value();
		}
		
		//KEY 6 = Increase only the sex_quin value
		if(key_6 == 1) {
			set_oct_sep = 0;
			set_sex_quin = 1003;
			set_quad_tri = 0;
			set_bil_mil = 0;
			set_thou_hun = 0;
			modulate_value();
		}
		
		//KEY 7 = Increase only the quad_tri value
		if(key_7 == 1) {
			set_oct_sep = 0;
			set_sex_quin = 0;
			set_quad_tri = 1003;
			set_bil_mil = 0;
			set_thou_hun = 0;
			modulate_value();
		}
		
		//KEY 8 = Increase only the bil_mil value
		if(key_8 == 1) {
			set_oct_sep = 0;
			set_sex_quin = 0;
			set_quad_tri = 0;
			set_bil_mil = 1003;
			set_thou_hun = 0;
			modulate_value();
		}
		
		//KEY 9 = Increase only the thou_hun value
		if(key_9 == 1) {
			set_oct_sep = 0;
			set_sex_quin = 0;
			set_quad_tri = 0;
			set_bil_mil = 0;
			set_thou_hun = 1003;
			modulate_value();
		}
		
		//KEY 0 = Checks for a certain amount of gold and subtracts it
		//Examples : 1,200,000  -  1,000  -  1,000,000,000  -  2,500
		if(key_0 == 1) 
		{
			while(key_0==1){wait(1);}
			if(player_gold.sex_quin>=1000 && player_gold.quad_tri>=100000 && player_gold.bil_mil>=250000 && player_gold.thou_hun>=500000 || 
				player_gold.oct_sep>=1){
				printf("Thats a lot of gold! You have over 1,000,100,000,250,000,500,000!nYou now have enough to buy that version of A9 you always wanted.",NULL);
				set_oct_sep = 0;
				set_sex_quin = 1000;
				set_quad_tri = 100000;
				set_bil_mil = 250000;
				set_thou_hun = 500000;
				demodulate_value();
				} else {
				printf("You dont have enough gold! You need at least 1,000,100,000,250,000,500,000",NULL);
			}
		}
		
		draw_text("1 nonillion",347,260,vector(255,255,255));
		draw_text("Key_1 : Increase Value",20,20,vector(255,255,255));
		draw_text("Key_2 : Decrease Value",20,40,vector(255,255,255));
		draw_text("Key_3 : Add Large Value",20,60,vector(255,255,255));
		draw_text("Key_4 : Subtract Large Value",20,80,vector(255,255,255));
		draw_text("Key_5 : Increase Value of Octillion/Septillion",20,100,vector(255,255,255));
		draw_text("Key_6 : Increase Value of Sextillion/Quintillion",20,120,vector(255,255,255));
		draw_text("Key_7 : Increase Value of Quadrillion/Trillion",20,140,vector(255,255,255));
		draw_text("Key_8 : Increase Value of Billion/Million",20,160,vector(255,255,255));
		draw_text("Key_9 : Increase Value of Thousand/Hundred",20,180,vector(255,255,255));
		draw_text("Key_0 : Check for a certain amount and subtract it",20,200,vector(255,255,255));
		
		wait(1);
	}
}