• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

not set before reading it

Hi

I'm trying to make a demo project to show to YoYo games because of an error that is occuring where if I click
on an icon it warps me to another level. So I'm building this demo project but I'm having trouble.

I have a Player object in the room. I'm getting this error:

GML:
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable PlayerObj.hasbatB(100017, -2147483648) not set before reading it.
 at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 35)
But PlayerObj has a hasbatB variable set in the create event. So I'm not sure what's going on.
 
C

CruelBus

Guest
Has the player object been created before the bats2 object?
 

TsukaYuriko

☄️
Forum Staff
Moderator
As usual, please show the full code of the event where you declare the variable as well as the full code of the event where the error occurs.
 
Error: (Bats2 create event)

GML:
isopen2 = false;

numberOfClicks = 0;

walking = false;
idle = false;
sentry = false;
placing = false;
still = false;
create_new_bat = true;


countdown = -1;
myTimer =0;




//batBmyTimer = room_speed;    //


/**/
Player.batBcountdown = room_speed*600;    //countdown value while batface is frozen
Player.myTimerbatB = false;        //countdown on/off
Player.bhourglass = noone;    //an instance of the hourglass object /**/

//lightning

if (Player.hasbatB)
{
   
    instance_create_depth(280,40,-2100, BatsFaceB)
    //draw_sprite(LightningBatFace, 0, x, y-10);
   
}

else
{
   instance_create_depth(280,40, -2100, BatsFaceHiddenB)
//draw_sprite(GreyScaleLightning, 0, x+10, y);
}
The variable is declared in the room. That is, I drug the PlayerObj as an object into the room. That is how Bats2 is defined as well.
It is an object in the room.

Note: I think it is because the Player object is not always created before Bats2 but I'm not sure. If so, the Player object has to be
the first thing created and I don't know how to do that.
 
I changed it so the Player spawns first. Same error:
GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable PlayerObj.<unknown variable>(100017, -2147483648) not set before reading it.
 at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 35)
 

Nidoking

Member
Are you sure that the capitalization is identical? The Player object Create event also has "hasbatB" and not "hasBatB" or something like that?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
The player doesnt have a hasbat set it only checks and if another object is meant to give player the value for hasbat then that instance needs to be created before the player

You have several different threads with the same issue and each time multiple people need to repeat themselves, please take the time to learn from the code errors here
 
Last edited:
Player does have a hasbatB, capitalization is correct also. hasbatB is marked below by comments


global.castle_hp = 1800

global.completed_level1 = false;
global.completed_level2 = false;
global.completed_level3 = false;
global.completed_level4 = false;
global.completed_level5 = false;
global.completed_level6 = false;
global.completed_level7 = false;
global.completed_level8 = false;
global.completed_level9 = false;
global.completed_level0 = false;
global.completed_level1 = false;
global.completed_level2 = false;

//
//audio_debug(true);
global.number_of_brains_on_screen = 0
global.easy_difficulty = true;
global.doom_difficulty = false;
randomize();
poisoned = false
global.in_battle = true;

//alarm[0] = 100;
global.current_bat = noone;
global.select_bat = noone;
global.dropped_bat = false;


//
global.windbat = false;
global.poisonbat = false;
global.snowbat = false;
global.musclebat = false;
global.bombbat = false;
global.magicbat = false;



instance_create_depth(0,0,-1700, Skip);

hasbat1 =true;
hasbatA = true;

//*********************HASBATB****************/
hasbatB = false;
hasbatC = false;
hasbatD = true;
hasbatE = false;
hasbatF = false;
hasbatG = false;
hasbatH = false;
///
global.lit_bat = false;

selected = false;

myTimerbatA = false;
myTimerbatB = false;
myTimerbatC = false;
myTimerbatD = false;
//global.current_level = 1; ///brain level

myTimerbatE = false;
myTimerbatF = false;
myTimerbatG = false;
myTimerbatH = false;

ahourglass = noone;
bhourglass = noone;
chourglass = noone;
dhourglass = noone;
ehourglass = noone;
fhourglass = noone;
ghourglass = noone;
hhourglass = noone;

//alchemist hourglass
global.alch_hourglass = noone;

batAmyTimer = 0;
batAcountdown = room_speed*50
batBmyTimer =0;
batBcountdown = room_speed*50;
batCmyTimer = 0;
batCcountdown = room_speed*50;
batDmyTimer = 0;
batDcountdown = room_speed*50;
batEmyTimer = 0;
batEcountdown = room_speed*50;
batFmyTimer = 0;
batFcountdown = room_speed*50;
batGmyTimer = 0;
batGcountdown = room_speed*50;
batHmyTimer = 0;
batHcountdown = room_speed*50;


global.active = false;

global.select_bat = noone;

attacking_castle = false;

global.wall_hp = 900;
global.castle_hp = 900;

global.is_bomb_bat = false;

//show_debug_message("Is in anarchy mode: " + string(global.is_anarchyMode));


global.save_file_name = noone;
global.load_file_name = noone;

global.loading_flag = false;
global.saving_flag = false;

////Alchemist myTimer
global.alchemist_myTimer = 0;
global.alchemist_lock = false;
global.alchemist_inst = noone; //instance of hourglass for alchemist table
global.alch_hourglass = noone;
///

global.gems = 99999;
//
global.bat_battle = false;

//dracula spawning a bat


global.dracula_myTimer = 0;


////////////stats//////////

global.brains_killed_per_minute = 0;
global.brains_killed_total = 0;

//brains/minute is brains_killed_per_minute . brains_killed_total

//CLICK HACK///

global.clicking_myTimer = 0;

//////////////////


global.time_passed = 0;
global.brains_killed_overall = 0;
global.level = 0;
global.experience = 0;
global.players_killed = 0;

global.splashscreen = room_speed*5;

global.time_reward_kill = true;

///////ALCHEMIST OBJECTS///////////////

global.group_invincibility = false;
global.freeze_brains = false;
global.invincibility_icon_spawn = false;
global.invuln_splash_flag = true;
global.freeze_splash_flag = true;
global.freeze_brains_myTimer = room_speed*4;
global.acceleration = false;
global.acceleration_splash_flag = false;
global.strength_boost = false;
global.strength_boost_splash = false;
global.defense_boost = false;
global.defense_boost_splash_Flag = false;
global.health_boost = false;
global.health_boost_splash = false;
global.health_boost_myTimer = room_speed*30;
global.fix_wall = false;
invulnerability_icon_instance = noone;
global.meteor = false;
global.meteor_splash_Flag = false;
global.poison_all = false;
global.poison_all_splash = false;
global.firewall = false;
global.firewall_splash = false;
global.firewave = false;
global.firewave_splash = false;
global.frenzy = false
global.frenzy_splash = false;

global.resurrect = false;
global.resurrect_splash = false;
global.num_sentry_killed = 0;

global.conversion = false;
global.conversion_splash = false;
global.petrification = false;
global.petrification_splash = false;

global.zone = false;
global.zone_splash_flag = false;

global.death = false;
global.death_splash = false;

//////////CREATE FRANKENSTEIN//////////////

//global.frankenstein = instance_create_depth(2290, 500, 1900, FrankensteinObject);

///////////BATTLE INFO//////////////////

global.SentryBatObject_x = 0;
global.SentryBatObject_y = 0;
global.battle_myTimer = room_speed;


drac_laugh_myTimer = room_speed*3;
/////////////////CLICK HACK///////////

global.clicking_enabled = true;
global.clicking_myTimer = room_speed*15;

//////////////////ACHIEVEMENTS///////////////////
//Gold achievement

global.achievement_gold = false;
global.achievement_gold_counter = 0;
global.achievement_gold_splash = false

//Tome achievement

global.achievement_tome = false;
global.achievement_tome_experience = 0;
global.achievement_tome_splash = false;

//Indigo achievement

global.achievement_indigo = false;
global.achievement_indigo_gems = 0;
global.achievement_indigo_splash = false;

//Poicket Watch Achievement

global.achievement_watch = false;
global.achievement_watch_time = 0;
global.achievement_watch_splash = false;

//Atrilium Achievement

global.achievement_atrilium = false;
global.achievement_atrilium_gems = 0;
global.achievement_atrilium_splash = false;

//PLatinum Achievement
global.achievement_platinum = false;
global.achievement_platinum_splash = false;
global.achievement_platinum_counter =1;

//Valroite Achievement
global.achievement_valorite = false;
global.achievement_valorite_splash = false;
global.achievement_valorite_counter = 0;

//verite achievement
global.achievement_verite = false;
global.achievement_vertie_splash = false;
global.achievement_verite_counter = 1;

//agapite achievement
global.achievement_agapite = false;
global.achievement_agapite_splash = false;
global.achievement_agapite_counter = 1;

//crystal copper achievement
global.achievement_crystal_copper = false;
global.achievement_crystal_copper_splash = false;
global.achievement_crystal_copper_flag = false;
//adamantium achievement
global.achievement_adamantium = false;
global.achievement_adamantium_splash= false;
global.achievement_adamantium_flag = false;

//no point in dying achievement
global.achievement_no_point_in_dying = false;
global.achievement_no_point_in_dying_splash = false;
global.achievement_no_point_in_dying_counter = 0;
///onyx achievement
global.achievement_onyx = false;
global.achievement_onyx_splash = false;
global.achievement_onyx_flag = false;

//sapphrie achievement
global.achievement_sapphire = false;
global.achievement_sapphire_splash = false;
global.achievement_sapphire_counter = 0;

//steel achievement
global.achievement_steel = false;
global.achievement_steel_splash = false;
global.achievement_steel_counter = 0;

//marble achievement
global.achievement_marble = false;
global.achievement_marble_splash = false;
global.achievement_marble_counter = 0;

//topa zachievmeent
global.achievement_topaz = false;
global.achievement_topaz_splash = false;
global.achievement_topaz_counter = 0;


//sharpshooter achievement
global.achievement_sharp_shooter = false;
global.achievement_sharp_shooter_splash = false;
global.achievement_sharp_shooter_counter = 0;

//virus achievcement
global.achievement_virus = false;
global.achievement_virus_splash = false;
global.achievement_virus_counter = 0;

//tornado achievement
global.achievement_tornado = false;
global.achievement_tornado_splash = false;
global.achievement_tornado_counter = 0;

//anarchy achievement
global.achievement_anarchy = false;
global.achievement_anarchy_splash = false;
global.achievement_anarchy_flag = false;

//clock achievcement
global.achievement_clock = false;
global.achievement_clock_splash = false;
global.achievement_clock_time = 0;


global.you_lose = false;







//you lose
//death_sound_flag

//hex myTimer
global.hex_myTimer = room_speed;

///click fix
global.can_click = true;
global.can_click_myTimer = 0;


///alchemist fire
global.fire_myTimer = 0;
global.fire_flag = false;
global.fire_flash = true;

///chain lightning spell
global.chain_lightning_buff = false;

//restore all buff
global.restore_all = false;
global.restore_all_splash = false;

//terror

global.terror = false;
global.terror_splash_flag = false;

//mindbrekaer

global.mindbreaker = false;
global.mindbreaker_splash = false;
global.mindbreak = false;

//holy
global.holy = false;
global.holy_splash_flag = false;


//////////sound/////////////

global.sfx_volume = 0.5;
global.music_volume = 0.5;

///////////////////////


poison_battle_myTimer = 0;

//////////////RETREAT/////////////
flight = false;
play_myTimer = room_speed;
played = false;
inst = noone;


/////////////need to add to save and load////////////////////

global.bat_attacking = false;

//////////REAPER/////////////

global.death_windbat = 0;
global.death_sentry = 0;
global.death_lightning = 0;
global.death_poison = 0;
global.death_snow = 0;
global.death_magic = 0;




///////////////////

global.game_level = 1;

global.save_me = false;
global.load_me = false;

/////////////level/////////////////

global.level = 1;

global.current_save_counter = 0;

global.current_save_string = noone;


global.save_me_flag_1 = false;
global.save_me_flag_2 = false;
global.save_me_flag_3 = false;
global.save_me_flag_4 = false;
global.save_me_flag_5 = false;

///////////////////////////////////
global.current_bat_attack_target_damage = 0;









//////////////////////////////////////////////////////
////////////////////////GLOBAL INDEX////////////////////////////
/////////////////////////////////////////////////////////////


global.wind_drop = false;
global.wind_drop_myTimer = 0;


////////////////////////MAIN STATS//////////////////////////

global.sentry_int = 0;
global.sentry_dex = 0;
global.sentry_str = 0;
global.sentry_atk = 0;
global.sentry_def = 0;
global.sentry_endurance = 0
global.sentry_accuracy = 0;
global.sentry_agility = 0;
global.sentry_wisdom = 0;


global.lit_int = 0;
global.lit_dex = 0;
global.lit_str = 0;
global.lit_atk = 0;
global.lit_def = 0;
global.lit_endurance = 0
global.lit_accuracy = 0;
global.lit_agility = 0;
global.lit_wisdom = 0;

global.wind_int = 0;
global.wind_dex = 0;
global.wind_str = 0;
global.wind_atk = 0;
global.wind_def = 0;
global.wind_endurance = 0
global.wind_accuracy = 0;
global.wind_agility = 0;
global.wind_wisdom = 0;

global.poison_int = 0;
global.poison_dex = 0;
global.poison_str = 0;
global.poison_atk = 0;
global.poison_def = 0;
global.poison_endurance = 0
global.poison_accuracy = 0;
global.poison_agility = 0;
global.poison_wisdom = 0;

global.snow_int = 0;
global.snow_dex = 0;
global.snow_str = 0;
global.snow_atk = 0;
global.snow_def = 0;
global.snow_endurance = 0
global.snow_accuracy = 0;
global.snow_agility = 0;
global.snow_wisdom = 0;

global.bomb_int = 0;
global.bomb_dex = 0;
global.bomb_str = 0;
global.bomb_atk = 0;
global.bomb_def = 0;
global.bomb_endurance = 0
global.bomb_accuracy = 0;
global.bomb_agility = 0;
global.bomb_wisdom = 0;

global.muscle_int = 0;
global.muscle_dex = 0;
global.muscle_str = 0;
global.muscle_atk = 0;
global.muscle_def = 0;
global.muscle_endurance = 0
global.muscle_accuracy = 0;
global.muscle_agility = 0;
global.muscle_wisdom = 0;

global.magic_int = 0;
global.magic_dex = 0;
global.magic_str = 0;
global.magic_atk = 0;
global.magic_def = 0;
global.magic_endurance = 0
global.magic_accuracy = 0;
global.magic_agility = 0;
global.magic_wisdom = 0;

global.sentry_experience = 0
global.sentry_next = 0
global.sentry_level = 0

global.lit_experience = 0
global.lit_next = 0
global.lit_level = 0

global.wind_experience = 0
global.wind_next = 0
global.wind_level = 0

global.poison_experience = 0
global.poison_next = 0
global.poison_level = 0

global.snow_experience = 0
global.snow_next = 0
global.snow_level = 0

global.bomb_experience = 0
global.bomb_next = 0
global.bomb_level = 0

global.muscle_experience = 0
global.muscle_next = 0
global.muscle_level = 0

global.magic_experience = 0
global.magic_next = 0
global.magic_level = 0


//more experience add up: endurance + wisdom + accuracy + agility
//endurance: increases with the more damage you deal and take
//wisdom: increases with the more you use the alchemist cabinet
//accuracy: increases the more you target a brain
//agility: increases wity the more you move around
//your dex, int, and str increase according to your level and experience
//your dex, for say, is calculated by taking your agility*accuracy divided by your level
//your str, for say, is calculated by taking your endurance*agility divided by your level
//your int, for say, is calculated by taking your wisdom*accuracy divided by your level
//your level is calculated by dividing your current experience times the next level, times
//a constant k. Say your experience is 5000 and the next level is 50. Then your next level would be
//5000/50 = 100 divided by k=10 then the experience for your next level is 10.


inst4 = noone;

meteor_timer = room_speed*20

//

inst = noone
inst2 = noone


hasBcountdown = false
hasCcountdown = false
hasDcountdown = false
 

TsukaYuriko

☄️
Forum Staff
Moderator
Put a breakpoint on the line that declares hasbatB. Does the game stop at this line when you run it in debug mode? As in, does that line actually run?

In the error message you posted, the object being referred to is PlayerObj. In your code, you refer to the player as Player. What is Player? Is that a separate object? A macro with the value PlayerObj?
 
@TsukaYuriko Changed the name of PlayerObj to Player.

Updated error message:

GML:
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable Player.<unknown variable>(100017, -2147483648) not set before reading it.
at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 35)
I put a breakpoint in on the line that declares hasbatB. It crashes before it gets to that line.
So things are out of order I'm guessing, not sure why.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Nobody said anything about renaming PlayerObj to Player. If PlayerObj was the actual name of the object, then you probably just broke your entire game by renaming it.

So, that leads me back to my original post: What is Player? Is it a separate object? Is it a macro with the value PlayerObj? A misspelling of PlayerObj?
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
@TsukaYuriko you might be right, looking at the error from the OP it seems to be some kind of macro that is referring to PlayerObj.

I put a breakpoint in on the line that declares hasbatB. It crashes before it gets to that line.
So things are out of order I'm guessing, not sure why.
1) Change back the name of the player to what it was in the beginning
2) The breakpoint must go into your PlayerObj, before the line where you declare hasbatB
3) Make sure there exists an instance of PlayerObj on you room.
4) In you room editor the PlayerObj must appear before (on top of) the Bats2 instance (on the instance list)
 

woods

Member
ERROR in
action number 1
of Create Event
for object Bats2:

Variable PlayerObj.hasbatB(100017, -2147483648) not set before reading it.
at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)




bats2 create event is looking for the hasbatB variable in the object PlayerObj and in your bats2 create event you have the object Player
===
if (Player.hasbatB)
{

===
from what i can tell,
the object PlayerObj needs to have the variable, not the object Player



this looks like you've been staring at your screen for too long and need a break ..take a breather and come back to it with fresh eyes ;o)
 
Ok. Forget about PlayerObj. That was just me renaming Player to PlayerObj so I could use instance_create to create an instance of Player. It was something that I was
trying to do that didn't work. The name of the object is Player. Player has the hasbatB variable in it. Player is what I dragged into the room. Player is the only thing
that is in the error message.

NEW ERROR MESSAGE:

GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable Player.<unknown variable>(100017, -2147483648) not set before reading it.
 at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 35)
 

chamaeleon

Member
Player has the hasbatB variable in it.
And yet, it doesn't have the variable defined. This implies the line that sets it has not executed yet. Just because you write a line of code does not mean something it defines is guaranteed to execute before something that tries to use it. It is your responsibility to ensure it does run before first use. Use all the tools at your disposal to diagnose what events and what lines run when for which instance.
 

gnysek

Member
Change: if (Player.hasbatB) to
GML:
if (instance_exists(Player)) {
    if (Player.hasbatB) {}
        ...
    }
}
to ensure that this instance exists first. You can add "else" to display some message if not, to be sure where error is.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
Ok. Forget about PlayerObj. That was just me renaming Player to PlayerObj so I could use instance_create to create an instance of Player. It was something that I was
trying to do that didn't work. The name of the object is Player. Player has the hasbatB variable in it. Player is what I dragged into the room. Player is the only thing
that is in the error message.

NEW ERROR MESSAGE:

GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable Player.<unknown variable>(100017, -2147483648) not set before reading it.
at gml_Object_Bats2_Create_0 (line 35) - if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 35)
Is not about just dragging Player to the room is about (1) dragging it and (2) assure that it is on top of the list...

Capture.PNG

or at least above the "Bats2" object.

if this doesn't solve the problem you need to:

1) Paste here the code in your Player object create event!
2) Paste here the code in your Bats2 object create event!
 
Change: if (Player.hasbatB) to
GML:
if (instance_exists(Player)) {
    if (Player.hasbatB) {}
        ...
    }
}
to ensure that this instance exists first. You can add "else" to display some message if not, to be sure where error is.

Changed to:

GML:
/lightning
if instance_exists(Player)
{
    if (Player.hasbatB)
    {
    
        instance_create_depth(280,40,-2100, BatsFaceB)
        //draw_sprite(LightningBatFace, 0, x, y-10);
    }
    else
    {
    instance_create_depth(280,40, -2100, BatsFaceHiddenB)
    //draw_sprite(GreyScaleLightning, 0, x+10, y);
    }   
}
@xDGameStudios Player is in the room at the top.

Player object create event::
global.castle_hp = 1800

global.completed_level1 = false;
global.completed_level2 = false;
global.completed_level3 = false;
global.completed_level4 = false;
global.completed_level5 = false;
global.completed_level6 = false;
global.completed_level7 = false;
global.completed_level8 = false;
global.completed_level9 = false;
global.completed_level0 = false;
global.completed_level1 = false;
global.completed_level2 = false;

//
//audio_debug(true);
global.number_of_brains_on_screen = 0
global.easy_difficulty = true;
global.doom_difficulty = false;
randomize();
poisoned = false
global.in_battle = true;

//alarm[0] = 100;
global.current_bat = noone;
global.select_bat = noone;
global.dropped_bat = false;


//
global.windbat = false;
global.poisonbat = false;
global.snowbat = false;
global.musclebat = false;
global.bombbat = false;
global.magicbat = false;



instance_create_depth(0,0,-1700, Skip);

hasbat1 =true;
hasbatA = true;
hasbatB = false;
hasbatC = false;
hasbatD = true;
hasbatE = false;
hasbatF = false;
hasbatG = false;
hasbatH = false;
///
global.lit_bat = false;

selected = false;

myTimerbatA = false;
myTimerbatB = false;
myTimerbatC = false;
myTimerbatD = false;
//global.current_level = 1; ///brain level

myTimerbatE = false;
myTimerbatF = false;
myTimerbatG = false;
myTimerbatH = false;

ahourglass = noone;
bhourglass = noone;
chourglass = noone;
dhourglass = noone;
ehourglass = noone;
fhourglass = noone;
ghourglass = noone;
hhourglass = noone;

//alchemist hourglass
global.alch_hourglass = noone;

batAmyTimer = 0;
batAcountdown = room_speed*50
batBmyTimer =0;
batBcountdown = room_speed*50;
batCmyTimer = 0;
batCcountdown = room_speed*50;
batDmyTimer = 0;
batDcountdown = room_speed*50;
batEmyTimer = 0;
batEcountdown = room_speed*50;
batFmyTimer = 0;
batFcountdown = room_speed*50;
batGmyTimer = 0;
batGcountdown = room_speed*50;
batHmyTimer = 0;
batHcountdown = room_speed*50;


global.active = false;

global.select_bat = noone;

attacking_castle = false;

global.wall_hp = 900;
global.castle_hp = 900;

global.is_bomb_bat = false;

//show_debug_message("Is in anarchy mode: " + string(global.is_anarchyMode));


global.save_file_name = noone;
global.load_file_name = noone;

global.loading_flag = false;
global.saving_flag = false;

////Alchemist myTimer
global.alchemist_myTimer = 0;
global.alchemist_lock = false;
global.alchemist_inst = noone; //instance of hourglass for alchemist table
global.alch_hourglass = noone;
///

global.gems = 99999;
//
global.bat_battle = false;

//dracula spawning a bat


global.dracula_myTimer = 0;


////////////stats//////////

global.brains_killed_per_minute = 0;
global.brains_killed_total = 0;

//brains/minute is brains_killed_per_minute . brains_killed_total

//CLICK HACK///

global.clicking_myTimer = 0;

//////////////////


global.time_passed = 0;
global.brains_killed_overall = 0;
global.level = 0;
global.experience = 0;
global.players_killed = 0;

global.splashscreen = room_speed*5;

global.time_reward_kill = true;

///////ALCHEMIST OBJECTS///////////////

global.group_invincibility = false;
global.freeze_brains = false;
global.invincibility_icon_spawn = false;
global.invuln_splash_flag = true;
global.freeze_splash_flag = true;
global.freeze_brains_myTimer = room_speed*4;
global.acceleration = false;
global.acceleration_splash_flag = false;
global.strength_boost = false;
global.strength_boost_splash = false;
global.defense_boost = false;
global.defense_boost_splash_Flag = false;
global.health_boost = false;
global.health_boost_splash = false;
global.health_boost_myTimer = room_speed*30;
global.fix_wall = false;
invulnerability_icon_instance = noone;
global.meteor = false;
global.meteor_splash_Flag = false;
global.poison_all = false;
global.poison_all_splash = false;
global.firewall = false;
global.firewall_splash = false;
global.firewave = false;
global.firewave_splash = false;
global.frenzy = false
global.frenzy_splash = false;

global.resurrect = false;
global.resurrect_splash = false;
global.num_sentry_killed = 0;

global.conversion = false;
global.conversion_splash = false;
global.petrification = false;
global.petrification_splash = false;

global.zone = false;
global.zone_splash_flag = false;

global.death = false;
global.death_splash = false;

//////////CREATE FRANKENSTEIN//////////////

//global.frankenstein = instance_create_depth(2290, 500, 1900, FrankensteinObject);

///////////BATTLE INFO//////////////////

global.SentryBatObject_x = 0;
global.SentryBatObject_y = 0;
global.battle_myTimer = room_speed;


drac_laugh_myTimer = room_speed*3;
/////////////////CLICK HACK///////////

global.clicking_enabled = true;
global.clicking_myTimer = room_speed*15;

//////////////////ACHIEVEMENTS///////////////////
//Gold achievement

global.achievement_gold = false;
global.achievement_gold_counter = 0;
global.achievement_gold_splash = false

//Tome achievement

global.achievement_tome = false;
global.achievement_tome_experience = 0;
global.achievement_tome_splash = false;

//Indigo achievement

global.achievement_indigo = false;
global.achievement_indigo_gems = 0;
global.achievement_indigo_splash = false;

//Poicket Watch Achievement

global.achievement_watch = false;
global.achievement_watch_time = 0;
global.achievement_watch_splash = false;

//Atrilium Achievement

global.achievement_atrilium = false;
global.achievement_atrilium_gems = 0;
global.achievement_atrilium_splash = false;

//PLatinum Achievement
global.achievement_platinum = false;
global.achievement_platinum_splash = false;
global.achievement_platinum_counter =1;

//Valroite Achievement
global.achievement_valorite = false;
global.achievement_valorite_splash = false;
global.achievement_valorite_counter = 0;

//verite achievement
global.achievement_verite = false;
global.achievement_vertie_splash = false;
global.achievement_verite_counter = 1;

//agapite achievement
global.achievement_agapite = false;
global.achievement_agapite_splash = false;
global.achievement_agapite_counter = 1;

//crystal copper achievement
global.achievement_crystal_copper = false;
global.achievement_crystal_copper_splash = false;
global.achievement_crystal_copper_flag = false;
//adamantium achievement
global.achievement_adamantium = false;
global.achievement_adamantium_splash= false;
global.achievement_adamantium_flag = false;

//no point in dying achievement
global.achievement_no_point_in_dying = false;
global.achievement_no_point_in_dying_splash = false;
global.achievement_no_point_in_dying_counter = 0;
///onyx achievement
global.achievement_onyx = false;
global.achievement_onyx_splash = false;
global.achievement_onyx_flag = false;

//sapphrie achievement
global.achievement_sapphire = false;
global.achievement_sapphire_splash = false;
global.achievement_sapphire_counter = 0;

//steel achievement
global.achievement_steel = false;
global.achievement_steel_splash = false;
global.achievement_steel_counter = 0;

//marble achievement
global.achievement_marble = false;
global.achievement_marble_splash = false;
global.achievement_marble_counter = 0;

//topa zachievmeent
global.achievement_topaz = false;
global.achievement_topaz_splash = false;
global.achievement_topaz_counter = 0;


//sharpshooter achievement
global.achievement_sharp_shooter = false;
global.achievement_sharp_shooter_splash = false;
global.achievement_sharp_shooter_counter = 0;

//virus achievcement
global.achievement_virus = false;
global.achievement_virus_splash = false;
global.achievement_virus_counter = 0;

//tornado achievement
global.achievement_tornado = false;
global.achievement_tornado_splash = false;
global.achievement_tornado_counter = 0;

//anarchy achievement
global.achievement_anarchy = false;
global.achievement_anarchy_splash = false;
global.achievement_anarchy_flag = false;

//clock achievcement
global.achievement_clock = false;
global.achievement_clock_splash = false;
global.achievement_clock_time = 0;


global.you_lose = false;







//you lose
//death_sound_flag

//hex myTimer
global.hex_myTimer = room_speed;

///click fix
global.can_click = true;
global.can_click_myTimer = 0;


///alchemist fire
global.fire_myTimer = 0;
global.fire_flag = false;
global.fire_flash = true;

///chain lightning spell
global.chain_lightning_buff = false;

//restore all buff
global.restore_all = false;
global.restore_all_splash = false;

//terror

global.terror = false;
global.terror_splash_flag = false;

//mindbrekaer

global.mindbreaker = false;
global.mindbreaker_splash = false;
global.mindbreak = false;

//holy
global.holy = false;
global.holy_splash_flag = false;


//////////sound/////////////

global.sfx_volume = 0.5;
global.music_volume = 0.5;

///////////////////////


poison_battle_myTimer = 0;

//////////////RETREAT/////////////
flight = false;
play_myTimer = room_speed;
played = false;
inst = noone;


/////////////need to add to save and load////////////////////

global.bat_attacking = false;

//////////REAPER/////////////

global.death_windbat = 0;
global.death_sentry = 0;
global.death_lightning = 0;
global.death_poison = 0;
global.death_snow = 0;
global.death_magic = 0;




///////////////////

global.game_level = 1;

global.save_me = false;
global.load_me = false;

/////////////level/////////////////

global.level = 1;

global.current_save_counter = 0;

global.current_save_string = noone;


global.save_me_flag_1 = false;
global.save_me_flag_2 = false;
global.save_me_flag_3 = false;
global.save_me_flag_4 = false;
global.save_me_flag_5 = false;

///////////////////////////////////
global.current_bat_attack_target_damage = 0;









//////////////////////////////////////////////////////
////////////////////////GLOBAL INDEX////////////////////////////
/////////////////////////////////////////////////////////////


global.wind_drop = false;
global.wind_drop_myTimer = 0;


////////////////////////MAIN STATS//////////////////////////

global.sentry_int = 0;
global.sentry_dex = 0;
global.sentry_str = 0;
global.sentry_atk = 0;
global.sentry_def = 0;
global.sentry_endurance = 0
global.sentry_accuracy = 0;
global.sentry_agility = 0;
global.sentry_wisdom = 0;


global.lit_int = 0;
global.lit_dex = 0;
global.lit_str = 0;
global.lit_atk = 0;
global.lit_def = 0;
global.lit_endurance = 0
global.lit_accuracy = 0;
global.lit_agility = 0;
global.lit_wisdom = 0;

global.wind_int = 0;
global.wind_dex = 0;
global.wind_str = 0;
global.wind_atk = 0;
global.wind_def = 0;
global.wind_endurance = 0
global.wind_accuracy = 0;
global.wind_agility = 0;
global.wind_wisdom = 0;

global.poison_int = 0;
global.poison_dex = 0;
global.poison_str = 0;
global.poison_atk = 0;
global.poison_def = 0;
global.poison_endurance = 0
global.poison_accuracy = 0;
global.poison_agility = 0;
global.poison_wisdom = 0;

global.snow_int = 0;
global.snow_dex = 0;
global.snow_str = 0;
global.snow_atk = 0;
global.snow_def = 0;
global.snow_endurance = 0
global.snow_accuracy = 0;
global.snow_agility = 0;
global.snow_wisdom = 0;

global.bomb_int = 0;
global.bomb_dex = 0;
global.bomb_str = 0;
global.bomb_atk = 0;
global.bomb_def = 0;
global.bomb_endurance = 0
global.bomb_accuracy = 0;
global.bomb_agility = 0;
global.bomb_wisdom = 0;

global.muscle_int = 0;
global.muscle_dex = 0;
global.muscle_str = 0;
global.muscle_atk = 0;
global.muscle_def = 0;
global.muscle_endurance = 0
global.muscle_accuracy = 0;
global.muscle_agility = 0;
global.muscle_wisdom = 0;

global.magic_int = 0;
global.magic_dex = 0;
global.magic_str = 0;
global.magic_atk = 0;
global.magic_def = 0;
global.magic_endurance = 0
global.magic_accuracy = 0;
global.magic_agility = 0;
global.magic_wisdom = 0;

global.sentry_experience = 0
global.sentry_next = 0
global.sentry_level = 0

global.lit_experience = 0
global.lit_next = 0
global.lit_level = 0

global.wind_experience = 0
global.wind_next = 0
global.wind_level = 0

global.poison_experience = 0
global.poison_next = 0
global.poison_level = 0

global.snow_experience = 0
global.snow_next = 0
global.snow_level = 0

global.bomb_experience = 0
global.bomb_next = 0
global.bomb_level = 0

global.muscle_experience = 0
global.muscle_next = 0
global.muscle_level = 0

global.magic_experience = 0
global.magic_next = 0
global.magic_level = 0


//more experience add up: endurance + wisdom + accuracy + agility
//endurance: increases with the more damage you deal and take
//wisdom: increases with the more you use the alchemist cabinet
//accuracy: increases the more you target a brain
//agility: increases wity the more you move around
//your dex, int, and str increase according to your level and experience
//your dex, for say, is calculated by taking your agility*accuracy divided by your level
//your str, for say, is calculated by taking your endurance*agility divided by your level
//your int, for say, is calculated by taking your wisdom*accuracy divided by your level
//your level is calculated by dividing your current experience times the next level, times
//a constant k. Say your experience is 5000 and the next level is 50. Then your next level would be
//5000/50 = 100 divided by k=10 then the experience for your next level is 10.


inst4 = noone;

meteor_timer = room_speed*20

//

inst = noone
inst2 = noone


hasBcountdown = false
hasCcountdown = false
hasDcountdown = false

Bats2 object create event:

isopen2 = false;

numberOfClicks = 0;

walking = false;
idle = false;
sentry = false;
placing = false;
still = false;
create_new_bat = true;


countdown = -1;
myTimer =0;




//batBmyTimer = room_speed; //


/**/
Player.batBcountdown = room_speed*600; //countdown value while batface is frozen
Player.myTimerbatB = false; //countdown on/off
Player.bhourglass = noone; //an instance of the hourglass object /**/

//lightning
if instance_exists(Player)
{
if (Player.hasbatB)
{

instance_create_depth(280,40,-2100, BatsFaceB)
//draw_sprite(LightningBatFace, 0, x, y-10);
}
else
{
instance_create_depth(280,40, -2100, BatsFaceHiddenB)
//draw_sprite(GreyScaleLightning, 0, x+10, y);
}
}

Throws the same error:

Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable Player.<unknown variable>(100018, -2147483648) not set before reading it.
 at gml_Object_Bats2_Create_0 (line 36) -        if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 36)
@chamaeleon The order is what I'm trying to figure out. Logically it appears that Player should be instantiated and create hasbatB before it creates Bats2. Player is drug into the room and is at the top of the list. But, instance_exists isn't working right either.
 

TailBit

Member
The only idea I got is that there could be two resources named Player, and it gets the index of the wrong one.. making it point to a object with a completely different index that your Player object

try..
show_debug_message("index is targeting: " + object_get_name(Player));
..early in the bat create event and see what the console gives

I expect it to either print the name of a different object, or fail if the index is out of range .. but since instance_exists passed, then it should point to something.

EDIT:
Or alternatively do a:
GML:
with(Player){
    // and have the player print some of information in the console
    show_debug_message("I am " + object_get_name(object_index) )
    show_debug_message("instance: " + string(id))
}
 
Last edited:

dudaxan

Member
Hey, I'm pretty sure your instance creation order is incorrect. Try following these steps to solve it:

2021-03-31_16-42.png

Changed to:

GML:
/lightning
if instance_exists(Player)
{
    if (Player.hasbatB)
    {
   
        instance_create_depth(280,40,-2100, BatsFaceB)
        //draw_sprite(LightningBatFace, 0, x, y-10);
    }
    else
    {
    instance_create_depth(280,40, -2100, BatsFaceHiddenB)
    //draw_sprite(GreyScaleLightning, 0, x+10, y);
    }  
}
@xDGameStudios Player is in the room at the top.

Player object create event::
global.castle_hp = 1800

global.completed_level1 = false;
global.completed_level2 = false;
global.completed_level3 = false;
global.completed_level4 = false;
global.completed_level5 = false;
global.completed_level6 = false;
global.completed_level7 = false;
global.completed_level8 = false;
global.completed_level9 = false;
global.completed_level0 = false;
global.completed_level1 = false;
global.completed_level2 = false;

//
//audio_debug(true);
global.number_of_brains_on_screen = 0
global.easy_difficulty = true;
global.doom_difficulty = false;
randomize();
poisoned = false
global.in_battle = true;

//alarm[0] = 100;
global.current_bat = noone;
global.select_bat = noone;
global.dropped_bat = false;


//
global.windbat = false;
global.poisonbat = false;
global.snowbat = false;
global.musclebat = false;
global.bombbat = false;
global.magicbat = false;



instance_create_depth(0,0,-1700, Skip);

hasbat1 =true;
hasbatA = true;
hasbatB = false;
hasbatC = false;
hasbatD = true;
hasbatE = false;
hasbatF = false;
hasbatG = false;
hasbatH = false;
///
global.lit_bat = false;

selected = false;

myTimerbatA = false;
myTimerbatB = false;
myTimerbatC = false;
myTimerbatD = false;
//global.current_level = 1; ///brain level

myTimerbatE = false;
myTimerbatF = false;
myTimerbatG = false;
myTimerbatH = false;

ahourglass = noone;
bhourglass = noone;
chourglass = noone;
dhourglass = noone;
ehourglass = noone;
fhourglass = noone;
ghourglass = noone;
hhourglass = noone;

//alchemist hourglass
global.alch_hourglass = noone;

batAmyTimer = 0;
batAcountdown = room_speed*50
batBmyTimer =0;
batBcountdown = room_speed*50;
batCmyTimer = 0;
batCcountdown = room_speed*50;
batDmyTimer = 0;
batDcountdown = room_speed*50;
batEmyTimer = 0;
batEcountdown = room_speed*50;
batFmyTimer = 0;
batFcountdown = room_speed*50;
batGmyTimer = 0;
batGcountdown = room_speed*50;
batHmyTimer = 0;
batHcountdown = room_speed*50;


global.active = false;

global.select_bat = noone;

attacking_castle = false;

global.wall_hp = 900;
global.castle_hp = 900;

global.is_bomb_bat = false;

//show_debug_message("Is in anarchy mode: " + string(global.is_anarchyMode));


global.save_file_name = noone;
global.load_file_name = noone;

global.loading_flag = false;
global.saving_flag = false;

////Alchemist myTimer
global.alchemist_myTimer = 0;
global.alchemist_lock = false;
global.alchemist_inst = noone; //instance of hourglass for alchemist table
global.alch_hourglass = noone;
///

global.gems = 99999;
//
global.bat_battle = false;

//dracula spawning a bat


global.dracula_myTimer = 0;


////////////stats//////////

global.brains_killed_per_minute = 0;
global.brains_killed_total = 0;

//brains/minute is brains_killed_per_minute . brains_killed_total

//CLICK HACK///

global.clicking_myTimer = 0;

//////////////////


global.time_passed = 0;
global.brains_killed_overall = 0;
global.level = 0;
global.experience = 0;
global.players_killed = 0;

global.splashscreen = room_speed*5;

global.time_reward_kill = true;

///////ALCHEMIST OBJECTS///////////////

global.group_invincibility = false;
global.freeze_brains = false;
global.invincibility_icon_spawn = false;
global.invuln_splash_flag = true;
global.freeze_splash_flag = true;
global.freeze_brains_myTimer = room_speed*4;
global.acceleration = false;
global.acceleration_splash_flag = false;
global.strength_boost = false;
global.strength_boost_splash = false;
global.defense_boost = false;
global.defense_boost_splash_Flag = false;
global.health_boost = false;
global.health_boost_splash = false;
global.health_boost_myTimer = room_speed*30;
global.fix_wall = false;
invulnerability_icon_instance = noone;
global.meteor = false;
global.meteor_splash_Flag = false;
global.poison_all = false;
global.poison_all_splash = false;
global.firewall = false;
global.firewall_splash = false;
global.firewave = false;
global.firewave_splash = false;
global.frenzy = false
global.frenzy_splash = false;

global.resurrect = false;
global.resurrect_splash = false;
global.num_sentry_killed = 0;

global.conversion = false;
global.conversion_splash = false;
global.petrification = false;
global.petrification_splash = false;

global.zone = false;
global.zone_splash_flag = false;

global.death = false;
global.death_splash = false;

//////////CREATE FRANKENSTEIN//////////////

//global.frankenstein = instance_create_depth(2290, 500, 1900, FrankensteinObject);

///////////BATTLE INFO//////////////////

global.SentryBatObject_x = 0;
global.SentryBatObject_y = 0;
global.battle_myTimer = room_speed;


drac_laugh_myTimer = room_speed*3;
/////////////////CLICK HACK///////////

global.clicking_enabled = true;
global.clicking_myTimer = room_speed*15;

//////////////////ACHIEVEMENTS///////////////////
//Gold achievement

global.achievement_gold = false;
global.achievement_gold_counter = 0;
global.achievement_gold_splash = false

//Tome achievement

global.achievement_tome = false;
global.achievement_tome_experience = 0;
global.achievement_tome_splash = false;

//Indigo achievement

global.achievement_indigo = false;
global.achievement_indigo_gems = 0;
global.achievement_indigo_splash = false;

//Poicket Watch Achievement

global.achievement_watch = false;
global.achievement_watch_time = 0;
global.achievement_watch_splash = false;

//Atrilium Achievement

global.achievement_atrilium = false;
global.achievement_atrilium_gems = 0;
global.achievement_atrilium_splash = false;

//PLatinum Achievement
global.achievement_platinum = false;
global.achievement_platinum_splash = false;
global.achievement_platinum_counter =1;

//Valroite Achievement
global.achievement_valorite = false;
global.achievement_valorite_splash = false;
global.achievement_valorite_counter = 0;

//verite achievement
global.achievement_verite = false;
global.achievement_vertie_splash = false;
global.achievement_verite_counter = 1;

//agapite achievement
global.achievement_agapite = false;
global.achievement_agapite_splash = false;
global.achievement_agapite_counter = 1;

//crystal copper achievement
global.achievement_crystal_copper = false;
global.achievement_crystal_copper_splash = false;
global.achievement_crystal_copper_flag = false;
//adamantium achievement
global.achievement_adamantium = false;
global.achievement_adamantium_splash= false;
global.achievement_adamantium_flag = false;

//no point in dying achievement
global.achievement_no_point_in_dying = false;
global.achievement_no_point_in_dying_splash = false;
global.achievement_no_point_in_dying_counter = 0;
///onyx achievement
global.achievement_onyx = false;
global.achievement_onyx_splash = false;
global.achievement_onyx_flag = false;

//sapphrie achievement
global.achievement_sapphire = false;
global.achievement_sapphire_splash = false;
global.achievement_sapphire_counter = 0;

//steel achievement
global.achievement_steel = false;
global.achievement_steel_splash = false;
global.achievement_steel_counter = 0;

//marble achievement
global.achievement_marble = false;
global.achievement_marble_splash = false;
global.achievement_marble_counter = 0;

//topa zachievmeent
global.achievement_topaz = false;
global.achievement_topaz_splash = false;
global.achievement_topaz_counter = 0;


//sharpshooter achievement
global.achievement_sharp_shooter = false;
global.achievement_sharp_shooter_splash = false;
global.achievement_sharp_shooter_counter = 0;

//virus achievcement
global.achievement_virus = false;
global.achievement_virus_splash = false;
global.achievement_virus_counter = 0;

//tornado achievement
global.achievement_tornado = false;
global.achievement_tornado_splash = false;
global.achievement_tornado_counter = 0;

//anarchy achievement
global.achievement_anarchy = false;
global.achievement_anarchy_splash = false;
global.achievement_anarchy_flag = false;

//clock achievcement
global.achievement_clock = false;
global.achievement_clock_splash = false;
global.achievement_clock_time = 0;


global.you_lose = false;







//you lose
//death_sound_flag

//hex myTimer
global.hex_myTimer = room_speed;

///click fix
global.can_click = true;
global.can_click_myTimer = 0;


///alchemist fire
global.fire_myTimer = 0;
global.fire_flag = false;
global.fire_flash = true;

///chain lightning spell
global.chain_lightning_buff = false;

//restore all buff
global.restore_all = false;
global.restore_all_splash = false;

//terror

global.terror = false;
global.terror_splash_flag = false;

//mindbrekaer

global.mindbreaker = false;
global.mindbreaker_splash = false;
global.mindbreak = false;

//holy
global.holy = false;
global.holy_splash_flag = false;


//////////sound/////////////

global.sfx_volume = 0.5;
global.music_volume = 0.5;

///////////////////////


poison_battle_myTimer = 0;

//////////////RETREAT/////////////
flight = false;
play_myTimer = room_speed;
played = false;
inst = noone;


/////////////need to add to save and load////////////////////

global.bat_attacking = false;

//////////REAPER/////////////

global.death_windbat = 0;
global.death_sentry = 0;
global.death_lightning = 0;
global.death_poison = 0;
global.death_snow = 0;
global.death_magic = 0;




///////////////////

global.game_level = 1;

global.save_me = false;
global.load_me = false;

/////////////level/////////////////

global.level = 1;

global.current_save_counter = 0;

global.current_save_string = noone;


global.save_me_flag_1 = false;
global.save_me_flag_2 = false;
global.save_me_flag_3 = false;
global.save_me_flag_4 = false;
global.save_me_flag_5 = false;

///////////////////////////////////
global.current_bat_attack_target_damage = 0;









//////////////////////////////////////////////////////
////////////////////////GLOBAL INDEX////////////////////////////
/////////////////////////////////////////////////////////////


global.wind_drop = false;
global.wind_drop_myTimer = 0;


////////////////////////MAIN STATS//////////////////////////

global.sentry_int = 0;
global.sentry_dex = 0;
global.sentry_str = 0;
global.sentry_atk = 0;
global.sentry_def = 0;
global.sentry_endurance = 0
global.sentry_accuracy = 0;
global.sentry_agility = 0;
global.sentry_wisdom = 0;


global.lit_int = 0;
global.lit_dex = 0;
global.lit_str = 0;
global.lit_atk = 0;
global.lit_def = 0;
global.lit_endurance = 0
global.lit_accuracy = 0;
global.lit_agility = 0;
global.lit_wisdom = 0;

global.wind_int = 0;
global.wind_dex = 0;
global.wind_str = 0;
global.wind_atk = 0;
global.wind_def = 0;
global.wind_endurance = 0
global.wind_accuracy = 0;
global.wind_agility = 0;
global.wind_wisdom = 0;

global.poison_int = 0;
global.poison_dex = 0;
global.poison_str = 0;
global.poison_atk = 0;
global.poison_def = 0;
global.poison_endurance = 0
global.poison_accuracy = 0;
global.poison_agility = 0;
global.poison_wisdom = 0;

global.snow_int = 0;
global.snow_dex = 0;
global.snow_str = 0;
global.snow_atk = 0;
global.snow_def = 0;
global.snow_endurance = 0
global.snow_accuracy = 0;
global.snow_agility = 0;
global.snow_wisdom = 0;

global.bomb_int = 0;
global.bomb_dex = 0;
global.bomb_str = 0;
global.bomb_atk = 0;
global.bomb_def = 0;
global.bomb_endurance = 0
global.bomb_accuracy = 0;
global.bomb_agility = 0;
global.bomb_wisdom = 0;

global.muscle_int = 0;
global.muscle_dex = 0;
global.muscle_str = 0;
global.muscle_atk = 0;
global.muscle_def = 0;
global.muscle_endurance = 0
global.muscle_accuracy = 0;
global.muscle_agility = 0;
global.muscle_wisdom = 0;

global.magic_int = 0;
global.magic_dex = 0;
global.magic_str = 0;
global.magic_atk = 0;
global.magic_def = 0;
global.magic_endurance = 0
global.magic_accuracy = 0;
global.magic_agility = 0;
global.magic_wisdom = 0;

global.sentry_experience = 0
global.sentry_next = 0
global.sentry_level = 0

global.lit_experience = 0
global.lit_next = 0
global.lit_level = 0

global.wind_experience = 0
global.wind_next = 0
global.wind_level = 0

global.poison_experience = 0
global.poison_next = 0
global.poison_level = 0

global.snow_experience = 0
global.snow_next = 0
global.snow_level = 0

global.bomb_experience = 0
global.bomb_next = 0
global.bomb_level = 0

global.muscle_experience = 0
global.muscle_next = 0
global.muscle_level = 0

global.magic_experience = 0
global.magic_next = 0
global.magic_level = 0


//more experience add up: endurance + wisdom + accuracy + agility
//endurance: increases with the more damage you deal and take
//wisdom: increases with the more you use the alchemist cabinet
//accuracy: increases the more you target a brain
//agility: increases wity the more you move around
//your dex, int, and str increase according to your level and experience
//your dex, for say, is calculated by taking your agility*accuracy divided by your level
//your str, for say, is calculated by taking your endurance*agility divided by your level
//your int, for say, is calculated by taking your wisdom*accuracy divided by your level
//your level is calculated by dividing your current experience times the next level, times
//a constant k. Say your experience is 5000 and the next level is 50. Then your next level would be
//5000/50 = 100 divided by k=10 then the experience for your next level is 10.


inst4 = noone;

meteor_timer = room_speed*20

//

inst = noone
inst2 = noone


hasBcountdown = false
hasCcountdown = false
hasDcountdown = false

Bats2 object create event:

isopen2 = false;

numberOfClicks = 0;

walking = false;
idle = false;
sentry = false;
placing = false;
still = false;
create_new_bat = true;


countdown = -1;
myTimer =0;




//batBmyTimer = room_speed; //


/**/
Player.batBcountdown = room_speed*600; //countdown value while batface is frozen
Player.myTimerbatB = false; //countdown on/off
Player.bhourglass = noone; //an instance of the hourglass object /**/

//lightning
if instance_exists(Player)
{
if (Player.hasbatB)
{

instance_create_depth(280,40,-2100, BatsFaceB)
//draw_sprite(LightningBatFace, 0, x, y-10);
}
else
{
instance_create_depth(280,40, -2100, BatsFaceHiddenB)
//draw_sprite(GreyScaleLightning, 0, x+10, y);
}
}

Throws the same error:

Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object Bats2:

Variable Player.<unknown variable>(100018, -2147483648) not set before reading it.
at gml_Object_Bats2_Create_0 (line 36) -        if (Player.hasbatB)
############################################################################################
gml_Object_Bats2_Create_0 (line 36)
@chamaeleon The order is what I'm trying to figure out. Logically it appears that Player should be instantiated and create hasbatB before it creates Bats2. Player is drug into the room and is at the top of the list. But, instance_exists isn't working right either.
 

Nidoking

Member
Are you sure you haven't defined hasbatB as a macro or something somewhere? If hasbatB is not defined, I would expect the error message to say "variable hasbatB is not defined", but it says "unknown variable". To me, that says that it's not even recognizing hasbatB as a variable.
 
Top