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.

Author
Message
Duncro
9
Years of Service
User Offline
Joined: 25th Jul 2015
Location:
Posted: 5th Aug 2015 23:02
Hi

I'm trying to create a level editor, that can set sprite names for manipulation in a game. The sprite position and other properties are stored in a txt file or w/e to be read in by the game.

I am using types to store all the info, though storing the name in the type array per sprite, doesn't allow it to be called directly.

So now i am thinking of keeping a directory of the names and their corresponding numbers in another array, but i havent seen any info on key'd arrays? Does AppGameKit have something like that? or is there a quick way to get the array location of a specific type[].name$?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Aug 2015 23:56
This might help...

Arrays can now be sorted using the .sort() command and searched using the .find(item) command.

.sort() will always sort in ascending order and .find(item) will only work on arrays that are in ascending order. If .find(item) cannot find the item you are looking for it will return "-1". You can sort arrays of Integers, Float, Strings, and Types. When sorting types the first variable of the type will be used to compare elements.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Duncro
9
Years of Service
User Offline
Joined: 25th Jul 2015
Location:
Posted: 8th Aug 2015 21:48
Thanks for the info.

I noticed that the sort function does not work on 2d arrays (test[i,j]), requiring you to sort them by defining the first vector of the array (e.g. test[1].sort()).

Though I will keep these in mind, they may help later on!

Out of itnerest, can you use the sort function to search by things other than the first defined entry for the type? It seems from the examples and my fiddling that it only sorts by the first subgroup of the type.

Login to post a reply

Server time is: 2024-11-21 20:56:14
Your offset time is: 2024-11-21 20:56:14