Title: GML Language
Description: ....need help with ini writing
MaJoRa - August 25, 2004 06:58 PM (GMT)
I need help with ini writing and reading in gml, ive tried all the tutorials and no luck, for all of you who dont know what GML is it stands for Game Maker Language. Im doing it to create a playlist in a media player im making, any help from here would be great, thanks.
ih8censorship - August 25, 2004 07:46 PM (GMT)
well first, what version of gamemaker are you using? because if your using a higher version such as 5.2 there are ini file functions. now this is untested because i dont do anything with 5.2 i just have it to open 5.2 files for someone i helped quite a bit. but here we go
| CODE |
ini_open('somefile.ini') variable=ini_read_section('section1','key','') ini_close()
|
and the ini file would be named somefile.ini and it would contain this:
| CODE |
[section1] key=i like eggs
|
and finaly heres a bit from the gamemaker 5.2 manuel (remember it probly wont work in earlyer versions because the functions arent in the earlyer versions
| QUOTE |
To pass certain parameter settings to programs a standard mechanism is the use of INI files. INI files contain sections and each section contains a number of name-value pairs. For example, here is a typical INI file:
[Form]
Top=100
Left=100
Caption=The best game ever
[Game]
MaxScore=12324
This file contains two sections, one call Form and the other called Game. The first section contains three pairs. The first two have a real value while the third has a string value. Such INI files are easy to create and change and the following functions exist in Game Maker to read and change the data in them
ini_open(name) Opens the INI file with the given name. The ini file must be stored in the same folder as the game!
ini_close() Closes the currently open INI file.
ini_read_string(section,key,default) Reads the string value of the indicated key in the indicated section. When the key or section does not exist the default value is returned.
ini_read_real(section,key,default) Reads the real value of the indicated key in the indicated section. When the key or section does not exist the default value is returned.
ini_write_string(section,key,value) Writes the string value for the indicated key in the indicated section.
ini_write_real(section,key,value) Writes the real value for the indicated key in the indicated section.
ini_key_exists(section,key) Returns whether the indicated key exists in the indicated section.
ini_section_exists(section) Returns whether the indicated section exists.
ini_key_delete(section,key) Deletes the indicated key from the indicated section.
ini_section_delete(section) Deletes the indicated section.
|
dr voodoo - August 25, 2004 08:26 PM (GMT)
If you have GM5.2 then RTFM.
Otherwise with file_read_string you can read a file line by line.
To identify if you have a [a] or a=b use string_pos and look if the first "[" is at pos 0.
To get the value in [a] you use string_copy and don't copy the first and last char.
To splip up the a=b pairs search the = with string_pos. You can get a and b by using string_copy.
If you need further help ask at the GMC.
ih8censorship - August 25, 2004 10:26 PM (GMT)
hes probly asking here because the GMC has been down for a few days due to a server change :lol:
Dragon - August 25, 2004 11:31 PM (GMT)
| QUOTE |
| If you have GM5.2 then RTFM. |
Dr. Voodoo, be nicer. :) Simply RTM. :D
dr voodoo - August 26, 2004 08:00 AM (GMT)
| QUOTE (Dragon @ Aug 25 2004, 11:31 PM) |
| QUOTE | | If you have GM5.2 then RTFM. |
Dr. Voodoo, be nicer. :) Simply RTM. :D
|
No otherwise it wont stick to his memory. And because he might already have forgoten it : RTFM.
| QUOTE |
| hes probly asking here because the GMC has been down for a few days due to a server change |
Not again! They have had more server changes and crashs than I have fingers on one hand!
MaJoRa - August 26, 2004 11:24 AM (GMT)
Yeah i tried the ini_open() and all but it dont work, so i dunno what to do, i have gm 5.3a and how do you get to the new gm community, can some1 link me ive tried all the links on the web page to it and they lead to the old one which you cant logg into, a link would help thanks.
An example of using ini files would be nice also....so that i can work from it, thanks.
dr voodoo - August 26, 2004 11:55 AM (GMT)
www.gamemaker.nl => "Forum" link
MaJoRa - August 26, 2004 01:04 PM (GMT)
The link there just takes me to the old forum, so could some1 give me the link?
ih8censorship - August 26, 2004 04:39 PM (GMT)
the forums back up on the same domain/different server.... just try the link again
Dragon - August 26, 2004 11:19 PM (GMT)
| QUOTE |
| The link there just takes me to the old forum, so could some1 give me the link? |
They changed forums...again? :huh: It might help to tell us what didn't work.
ih8censorship - August 27, 2004 12:01 AM (GMT)
yes they changed servers AGAIN. something about the host threatening to cut them off cause of using 60% of the servers processing power yet staying within the disk space and bandwidth restrictions
Dragon - August 27, 2004 12:51 AM (GMT)
Maybe they should consider having less members, like putting a restriction on how many people can register. But then some people won't be happy.
ih8censorship - August 27, 2004 01:06 AM (GMT)
one of my thoughts was they should allow everyone to only be on X amount of days per week.
Dragon - August 27, 2004 01:59 AM (GMT)
Yeah, some people are obsessed with Game Maker. :lol:
MaJoRa - August 27, 2004 10:03 AM (GMT)
Who isnt? Anyway the link works now so im happy.
ih8censorship - August 28, 2004 02:18 AM (GMT)
i used to be sorta obsessed with gamemaker... now im like obsessed with trying to load/display a jpg and other non bmp images (but mostly jpg) in c++ :lol:
Dragon - August 28, 2004 03:27 AM (GMT)
| QUOTE (MaJoRa @ Aug 27 2004, 03:03 AM) |
| Who isnt? Anyway the link works now so im happy. |
You mean who isn't obsessed with Game Maker? Well, um...hmm...lots of people. :)
kimastergeorge - August 28, 2004 04:15 AM (GMT)
| QUOTE (Dragon @ Aug 25 2004, 11:31 PM) |
| QUOTE | | If you have GM5.2 then RTFM. |
Dr. Voodoo, be nicer. :) Simply RTM. :D
|
Read The Friendly Manual. :D
Dragon - August 28, 2004 04:57 AM (GMT)
dr voodoo - August 28, 2004 09:09 AM (GMT)
| QUOTE |
| Read The Friendly Manual. |
Yes you could say that the GM manual is friendly compared to others.
| QUOTE |
| i used to be sorta obsessed with gamemaker... now im like obsessed with trying to load/display a jpg and other non bmp images (but mostly jpg) in c++ |
Use GDI+ or SDL_Image.
GDI+ has support for BMP, GIF, JPEG, Exif, PNG and TIFF but is Win only.
SDL_Image has support for BMP, PNM, XPM, XCF, PCX, GIF, JPG, TIF, PNG and LBM and is cross platform. With both you don't have to worry about the type of the image.
You just indicate the name and they'll figure out the format and load it.
For GDI+:
| CODE |
Bitmap my_bitmap(L"my_image.png"); Graphics out(some_hdc); out.DrawImage(&out,100,100); |
(Note the name has to be Unicode therefor that L)
For SDL:
| CODE |
SDL_Surface*img=IMG_Load("my_image.png"); SDL_Rect to={100,100,0,0}; SDL_BlitSurface(img,0,SDL_GetVideoSurface(),&to); |
ih8censorship - August 28, 2004 01:26 PM (GMT)
| QUOTE |
| Read The Friendly Manual. |
ROFLOL :lol:
a lot of me not wanting to use gdi+ is its kind of a situation where i dont want the external dll, because i want it to be an interpreter that adds to the end of a single exe... so ya i guess ill look into SDL then havent looked into that much :)
**edit**
dont ya just love how a topic can completely change subjects around here? i bet we could turn an evolution debate into like a C/C++ vs asm debate :lol: