J
jacobj30
Guest
So i am creating a cooking game, and i thought the the game would be better if the food rotted if it is not stored in a freezer. So i thought about how the code would work. and i came up with the below. There is no problem with the code below but i want it more streamlined. i do not want to have to create almost a thought didn't variable for each food. Because if you buy 1 meat then global.meat_1_bought=true would be active, but if you buy another meat nothing would happen because global.meat_1_bought=true is already active. which would mean having to create meat 1,2,3,4,.... & etc. i do not want to do that because it would take too much time so if anyone could show me a way to streamline it then i would be really happy. but if there isn't then i would instead continue what i have been doing.
Note that code below could have some mistakes but i do not want you to focus on the mistakes but instead an alternative to this. that is much faster. So please do not point out the mistakes. i could figure out the mistakes by opening the game up.
VARIABLES:
global.subtract=1; /// this will be used later
global.meat_expiration=irandom_range(4,6); /// # of days meat 1 can be out without spoiling.
global.meat_1_expiration=0; /// # of days ( meat 1) can be out without spoiling
global.meat_1_in_freezer=false; ///the food is in the freezer
global.meat_1_bought=false; ///you have bought your meat
buying the meat left click
randomize();
global.sub=1; /// i use the variable sub as a way to stop the code.
if ( meat_1_in_freezer=false && global.meat_1_bought=false && global.sub=1 ) {
global.meat_expiration=irandom_range(4,6); /// # of days meat 1 can be out without spoiling.
global.meat_1_expiration+=global.meat_expiration;
global.meat_1_bought=true;
global.meat_1_in_freezer=true;
global.sub-=1 }
step event
if ( global.meat_1_expiration==0 ) {
global.meat_1_bought=false;
global.meat_1_in_freezer=false; }
so now lets say i click next day and this is what is suppose to happen.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( meat_1_in_freezer=true && global.meat_1_bought=true) {
global.meat_1_expiration-=0; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( meat_1_in_freezer=false && global.meat_1_bought=true) {
global.meat_1_expiration-=1; }
what i want is to buy as many meats as possible without having to create a thousand variables. so is there a code or codes that can allow me to such a thing. i hope you understand what i mean
Note that code below could have some mistakes but i do not want you to focus on the mistakes but instead an alternative to this. that is much faster. So please do not point out the mistakes. i could figure out the mistakes by opening the game up.
VARIABLES:
global.subtract=1; /// this will be used later
global.meat_expiration=irandom_range(4,6); /// # of days meat 1 can be out without spoiling.
global.meat_1_expiration=0; /// # of days ( meat 1) can be out without spoiling
global.meat_1_in_freezer=false; ///the food is in the freezer
global.meat_1_bought=false; ///you have bought your meat
buying the meat left click
randomize();
global.sub=1; /// i use the variable sub as a way to stop the code.
if ( meat_1_in_freezer=false && global.meat_1_bought=false && global.sub=1 ) {
global.meat_expiration=irandom_range(4,6); /// # of days meat 1 can be out without spoiling.
global.meat_1_expiration+=global.meat_expiration;
global.meat_1_bought=true;
global.meat_1_in_freezer=true;
global.sub-=1 }
step event
if ( global.meat_1_expiration==0 ) {
global.meat_1_bought=false;
global.meat_1_in_freezer=false; }
so now lets say i click next day and this is what is suppose to happen.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( meat_1_in_freezer=true && global.meat_1_bought=true) {
global.meat_1_expiration-=0; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if ( meat_1_in_freezer=false && global.meat_1_bought=true) {
global.meat_1_expiration-=1; }
what i want is to buy as many meats as possible without having to create a thousand variables. so is there a code or codes that can allow me to such a thing. i hope you understand what i mean
Last edited by a moderator: