Simple use of String parser 2, useing 1 ini to save many values/strings
Author:|| craig miriad
Submitted:|| 24th April, 2006
Useing just 1 INI file in your games:
This is my first ever artical, im very sorry if it's rubbish...
But I hope to find out how to put an example at the end for help
I don't know why i never thought of this idea before... Most likly coz im dumb...but meh!
Ok firstly your going to need the extention: String Parser 2 i will explain
how to use this as we go along.
Now we need to make an simple app, and a normal frame.
Ok, now put 4 counters on the screen, (Im using 4 to extra proove this works,
but you can use 2 if you like, in your games there will be more than one counter
to save so, it's up to you )
Now, put the string parser 2 object on your level, and use the settings as default,
then put a ini on the screen, and call it save or whatever.
Now we need to make some edit boxes to change the each counter, along with a button
wich says set to INI, and another button wich say's continue.
Now to the event editor:
start of frame: 'string parser 2: add delimiter ,'
-note for ones who are not aware of the use of a 'delimiter'-
--A delimiter seperates values or strings with a , so you can bundle a bunch of
strings/values together, aslong as you put ' + , + ' in the middle of each one.
We will later see how to retreive thease values.
Start of frame: 'String parser 2: set source string to string of$( Ini )'
When user clicks on set to INI button: 'Counter 1,2,3 and 4: set to;
Edit Value 1st,2nd,3rd and 4th value
When user clicks on set to INI button: 'INI: set item string to;
Str$( value( 1st counter ) ) + , +
Str$( value( 2nd counter ) ) + , +
Str$( value( 3rd counter ) ) + , +
Str$( value( 4th counter ) )
Continue clicked: Next frame.
Ok now make a new level, make it have the 4 counters again, and a button saying Set INI to counters.
Back to the editor again.
Start of frame: 'Add delimiter ,'
Start of frame: 'Set source string to string of$( Ini )'
User clicks on set INI to counter: 'set;
set counter 1 to: Val( listGetAt$( String Parser, 1 ) )
set counter 2 to: Val( listGetAt$( String Parser, 2 ) )
set counter 3 to: Val( listGetAt$( String Parser, 3 ) )
set counter 4 to: Val( listGetAt$( String Parser, 4 ) )
The values at the end of the expression 1,2,3 and 4 express the 1st value of string, before the
+ , + , the second just after that, then once more we have + , + then the third string folowed
by + , + once again folowed by the 4th string. 0 Does not count! it always starts at 1, 0 counts
as...well...0...or , so make sure you dont accidently do that.
My example should work, i hope... coz this has most probly been explained badly. but sorry...
Its my first artical though so
EDIT: you can obviusly take this to new levels, as in with usernames and passwords, and more than one save file in a game. But my example is just simple