The Daily Click ::. Forums ::. Klik Coding Help ::. How do I save global values?
 

Post Reply  Post Oekaki 
 

Posted By Message

hey hey shoe



Registered
  23/05/2003
Points
  65
23rd April, 2004 at 21:04:22 -

I've been looking through lots of tutorials and haven't been able to figure out how to save information and load it from an .ini file. Can anyone explain to me step by step how to save my global values and load them thoroughly? Thanx in advance!

 
CHES!

cake



Registered
  13/12/2002
Points
  1173
23rd April, 2004 at 22:57:29 -

Sure thing. This will an explaination of MMF, but I don't think TGF varies too much at all:

There are just a few simple steps with INIs, which follow in this exact order:

Set the file
Set the group
Set the item
Get/Set the value

Setting the file:
Depends where you want to put it, but I recommend that you don't annoy the player by sticking in some random folder or whatever. Instead, put it in the game's directory. So your file setting action will be:
Set current file to (Appdrive$ + Appdir$ + "\<name of ini>.ini")

Setting the group:
Groups just let you organise your items into related areas. You can easily just scrape by with 1 group, as you get more comfortable you can organise your INIs more. Your groups setting action will be:
Set current group to "Saved"

Setting the item:
The items are names for the values you are storing. You refer to an item to get its value.
Your item setting action will be:
Set current item to <anything really, eg. "Level">

Setting the value of an item, or "saving"
To save some kind of data to be loaded back into the game at a later time, the action is:
Set value of current item to <desired global value, or any value for that matter>

Getting the value of an item, or "loading"
When you load your game, for each of the global values you need, set to the relevent item, then use the action:
Set value of <desired global value, or any value for that matter> to value of current item

So an example event for loading a game would be:

1.
Button "Load" is clicked:

▪ Set current file to Appdrive$+Appdir$+"\Saved.ini"
▪ Set current group to "Slot1"
▪ Set current item to "Level"
▪ Set Global Value A to value of current item
▪ Set current item to "Ammo"
▪ Set Global Value B to value of current item
▪ Set current item to "Weapon"
▪ Set Global Value C to value of current item
▪ Set current item to "Score"
▪ Set score of player 1 to value of current item

Similarly, an event for saving the equivelent game would be:

1.
Button "Save" is clicked:

▪ Set current file to Appdrive$+Appdir$+"\Saved.ini"
▪ Set current group to "Slot1"
▪ Set current item to "Level"
▪ Set value of current item to Global Value A
▪ Set current item to "Ammo"
▪ Set value of current item to Global Value B
▪ Set current item to "Weapon"
▪ Set value of current item to Global Value C
▪ Set current item to "Score"
▪ Set value of current item to score of player 1

There. Hope I helped.

Image Edited by the Author.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
24th April, 2004 at 03:44:51 -

In the unlikely case that Biax doesn't know what he's talking about here's an example at the clickteam knowledge base.

http://www.nmxt.com/kb/start/index.php?showtopic=64

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
24th April, 2004 at 04:07:49 -

Hey, I had the same problem the other day, but I experimeted i bit and figured it out. Im not sure how to do global values, but global counters works just as good. this is in TGF by the way.

Level editor:
- create an INI file, name it "save" or something.
- Create a counter object, and make it global (rightclick, choose object preferences and check the global to the entire game)

Event editor:
-Upon pressing "Q" add to counter 1
-Upon pressing "W" set the value of the counter equal the ini. or just put this in under the counter "value of( "Ini" )" (remeber, add this under the counter object, not under the ini file.
-Upon pressing "E" set item value of INI to the value of the counter. or just paste this in under the INI (not under the counter this time) " value( "cash counter" )"

there you go. Now try it out. "Q" adds to the counter, "W" loads the counter, "E" saves the counter. Now add some numbers, save it, exit and press "W" to load them up.


 
http://www.robocaptain.com

hey hey shoe



Registered
  23/05/2003
Points
  65
24th April, 2004 at 07:39:46 -

Thanks! I'll try it out!

 
CHES!

hey hey shoe



Registered
  23/05/2003
Points
  65
24th April, 2004 at 08:11:37 -



Image Edited by the Author.

 
CHES!

Mr Icekirby



Registered
  18/12/2003
Points
  846
24th April, 2004 at 09:36:15 -

what a n00bish topic... no offence, i was once a n00bee... all of us were

 
Mr Icekirby says so!
OBEY ME!

X_Sheep

I had a custom rating before it was cool

Registered
  01/03/2004
Points
  1313

VIP MemberPicture Me This -Round 23- Winner!Dos Rules!
24th April, 2004 at 09:51:03 -

Hint of the year: Always look at all other topics before asking a basic question.

 
a/n

hey hey shoe



Registered
  23/05/2003
Points
  65
24th April, 2004 at 09:57:18 -

so what if i'm n00bish? the point is I never understood by looking at other tutorials etc., mind your own

 
CHES!

hey hey shoe



Registered
  23/05/2003
Points
  65
24th April, 2004 at 11:52:16 -

Hey can you give a MMF file with that example you just wrote about? Would help out alot more

 
CHES!

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
25th April, 2004 at 12:35:30 -

Kirb, there wasn't really a need for that. If I remember correctly you were a newb not very long ago yourself.

 
Craps, I'm an old man!

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
26th April, 2004 at 02:44:25 -

Yes Kirb. You're so modest.

[quote kirb]
"I AM A CLICKING LEGEND! ALL SHALL FEAR ME! YOU ASK WHAT I HAVE ACCOMPLISHED? I SHALL FLAME YOUR ASS MORTAL! "
[/quote kirb]

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

hey hey shoe



Registered
  23/05/2003
Points
  65
2nd May, 2004 at 08:04:41 -

I never took the time to learn about the .ini object before so stop whining...

 
CHES!
   

Post Reply



 



Advertisement

Worth A Click