• 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!

Instance Create Layer not working properly or my idiocy?

D

Darren

Guest
In my Initialize room I have

if !audio_group_is_loaded(audiogroup_music){audio_group_load(audiogroup_music);}

ini_open("Settings.ini");
global.music = ini_read_real("Audio","Music", 1);
ini_write_real("Audio","Music", global.music);
ini_close();

room_goto(MainMenu);​
Then I have an audio object
Create:
if (!audio_is_playing(snd_music))
{
audio_play_sound(snd_music,100,true);
audio_sound_gain(snd_music, global.music, 0);​
}
Step:
audio_sound_gain(snd_music, global.music, 0);​

I get this error
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_sound_controller:

global variable name 'music' index (100010) not set before reading it.
at gml_Object_obj_sound_controller_Create_0 (line 4) - audio_sound_gain(snd_music, global.music, 0);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_sound_controller_Create_0 (line 4)
I don't know why as I've already written the variable when I initialize. Also I have an audio bar which is supposed to create the slider, and it doesn't until I click on it

Create event:

can_click = true;

rightLimit = x+(sprite_get_width(spr_bar) /2) - 1;
leftLimit = x-(sprite_get_width(spr_bar) /2) + 1;

//Create the slider + assign values

a = instance_create_layer(x,y,"Instances",obj_slider);
a.image_xscale = 1;
a.image_yscale = 1;
a.barLength = sprite_get_width(spr_slider);
a.rightLimit = rightLimit;
a.leftLimit = leftLimit;
a.percentage = global.music * 100;

//Current value using percentage value

a.x = a.leftLimit + ((a.percentage/100) * (a.rightLimit-a.leftLimit));
a.clicked = false;​

Is there a create event issue known or is it me being silly? Thanks!
 

Bentley

Member
Edit: nevermind. Did not see you were using a splash room. I thought the problem was that you were initializing in the room's creation code then getting the error in the create event because the room creation code runs after.
 
D

Darren

Guest
Edit: nevermind. Did not see you were using a splash room. I thought the problem was that you were initializing in the room's creation code then getting the error in the create event because the room creation code runs after.
Don't know if it helps but the audiogroup says it exists, but then I go into my settings room and back into my main menu, and its create code runs then. I don't know why it isn't running initially.
 
Top