Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Key-Value Pairs (Reading&Writing)

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Apr 2015 07:39
I'm working a 'save game' mechanism and had the need for reading and writing key value pairs so knocked up a little script, thought maybe someone else would maybe find it useful, also for tips on my AppGameKit coding!



and a usage example
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Apr 2015 11:24
Thanks for sharing.

There is also a similar tutorial here. The example usage also applies to anyone using your code, good for fine-tuning game mechanics.

It is also extended in this month's newsletter to create multi-language functionality. You should be able to do the same language trick with your key-value code by adding the folder method in the tutorial.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Apr 2015 17:46
Ha there I go reinventing the wheel again, I like your system as it allows multiple files to be used simultaneously, I must take time to read through some of the news letters and play catchup

BTW, line 180 of parameters.agc the operator is missed "arrParmlength" to "arrParm.length"

which brings me to, do I need to expand my arrays when using .insert, the help page seems to suggest that I don't as the example code does not, is this handled internally?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Apr 2015 18:57
Quote: "BTW, line 180 of parameters.agc the operator is missed "arrParmlength" to "arrParm.length""


Thanks for the correction

Quote: "which brings me to, do I need to expand my arrays when using .insert"


No, this adds a new element.
But I prefer to add many elements in one go by changing .length.
This is because as I understand it, the whole array moves location in memory each time you expand it. So I prefer to move it once for 10 new elements, rather than 10 times for each .insert.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Apr 2015 19:58
yea that makes sense, I was thinking I didn't want empty unused array elements but weighed in against the load on the cpu with a large array I think a few extra elements cant hurt, I'm to used to dynamic linklists, haven't 'dimmed' an array since my VB6 days lol

Thanks for the tip

Login to post a reply

Server time is: 2024-11-25 20:37:17
Your offset time is: 2024-11-25 20:37:17