Jump to content


Photo

variable question.


  • Please log in to reply
8 replies to this topic

#1 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 09:54 AM

do global variables change when u have the game restart?
i want to make a global variable in the starting room about the backround music
and in the setting it ll see this variable and change the buttons accordingly.
so if i do that when the game restarts it ll keep the last variable or not?
and how is this possible any idea?
im a newbie.....:)

Edited by Morpheas, 04 March 2012 - 09:54 AM.

  • 0

#2 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5402 posts
  • Version:GM:Studio

Posted 04 March 2012 - 10:04 AM

ini_open('config.ini')
global.bg_music = ini_read_string('data','music',default_music) // change default music to the name of the default start music you want
ini_close()
the savefile will look like this then:
[data]
music=0

if the file don't exists, then it will just the one you sat as default ^^ ini files are nice like that

use "other > game end" for saving:
ini_open('config.ini')
ini_write_real('data','music',global.bg_music)
ini_close()

have a nice day
  • 1

#3 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 10:29 AM

could u explain it a little more?
where u i put the code?in the creation of room or some object?
because i understood only half of what u wrote me.:)
i told u im a newbie:)
thx

edit:in the creation event of my controler i putted the first set of codes.
and in end game of the same object the last set of codes.
now what i see.
with this code it creates an .ini file with what u said
[data]
music=0
but it doesnt start paying any music when the game starts.
when it restarts it keeps the last music selected.
so what do i do? i just say the controller to play a starting music?

Edited by Morpheas, 04 March 2012 - 10:47 AM.

  • 0

#4 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5402 posts
  • Version:GM:Studio

Posted 04 March 2012 - 11:54 AM

oh, sorry .. well this just load and saves a variable that just hold the song that should be used

after the first code you can play it using:
sound_loop(global.bg_music)
and there should be sound..

you can easily make some buttons to change the song with left pressed event:
sound_stop(global.bg_music) // stop current bg music
global.bg_music = some_other_song
sound_loop(global.bg_music) // start the new one

  • 0

#5 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 12:39 PM

oh, sorry .. well this just load and saves a variable that just hold the song that should be used

after the first code you can play it using:

sound_loop(global.bg_music)
and there should be sound..

you can easily make some buttons to change the song with left pressed event:
sound_stop(global.bg_music) // stop current bg music
global.bg_music = some_other_song
sound_loop(global.bg_music) // start the new one


i tried it and it loops the song not at end but its like a compressed song.i mean its like noise.
i used mp3 for backround music.do u think this is the problem?
thx very much.:)

Edited by Morpheas, 04 March 2012 - 12:43 PM.

  • 0

#6 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5402 posts
  • Version:GM:Studio

Posted 04 March 2012 - 12:56 PM

oh, I can accually not answer that since I don't have mutch experience with sound in GM, many uses ogg instead of mp3, but then they have to load with a dll .. sorry, I have to leave that question for someone else <>;;
  • 0

#7 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 01:01 PM

oh, I can actually not answer that since I don't have mutch experience with sound in GM, many uses ogg instead of mp3, but then they have to load with a dll .. sorry, I have to leave that question for someone else <>;;

so have u heard anything like that again.my guess is that it must be the mp3 extension but im not sure it might also be something with the code.
i mean its like it doesn't see the start and the end of the loop.but it could be also the mp3....i ll see what i can do thx again for ur help

Edited by Morpheas, 04 March 2012 - 01:03 PM.

  • 0

#8 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 01:24 PM

im pretty sure its something with the code of looping i ll give u a feedback in a while....
mmm.. even if i put sound_play(global.bg_music) the music is like......(.hit):)
i think the problem is here ini_read_string('data','music',oldwestern)
and then the sound_loop(global.bg_music) or whatever.
is it possible that it cant read the global.bg_music?i mean like a variable.
the problem is in the first room the first time it starts


edit of edit oh edit:)
please read this.
i have 4 rooms
room0(doesn't have any music)
room0.1(settings room)
room1
room1.1(settings room)
all of them r persistent rooms.
so when u choose 1 button from the settings it follows the rest of the rooms with no problem even if it restarts.
so i thought i would make a variable it would be better because the way i have it now i cant put at room0 a sound.
because if i do,it restarts the object with the sound and u cant have the last music setting in the first room.
what do u propose?
or what is the problem with what u gave me?.is it the persistent room settings?

Edited by Morpheas, 04 March 2012 - 02:39 PM.

  • 0

#9 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 05 March 2012 - 10:27 AM

any help pls?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users