Creating object by name from INI and setting VARs

For questions about using Classic.

Post » Mon Aug 06, 2012 3:14 pm

Hi!


I'm currently building a map editor and playing along with the INI object.

I would like to specify all the tile data in an INI file rather then cluttering the eventsheet with statments.

So far I have been able to "create object by name" from the INI file like so:

For each group
   Create object INI.ItemString(INI.CurrentGroup, "Name")

I have more item names(set of data in the INI) that I would like to set for every created object, put how would I pick them since they are created from name?

As it stands now, the map editor creates the tiles (grass, dirt they are in a family called tiles) but let's say that I would like to set, on creation, their ID, Speedmodifier, Walksound, etc...

How would one do that in one function?

The INI looks like this:

[Grass]
ID=1000
Name=terrain_grass01 <-- THIS IS THE NAME I USE IN THE EVENTSHEET
Description=Medium long green grass. It's like fur but smellier.
Speed multiplier=0.95
Walksound=walk_grass.wav

[Dirt]
ID=1001
Name=terrain_dirt01
Description=Brownish compound with small pebbles in it. Makes mothers cry.
Speed multiplier=0.90
Walksound=walk_dirt.wav


Any help would be greatful!

MJOne2012-08-06 15:24:34
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Mon Aug 06, 2012 6:39 pm

While you can create by name, you can't pick by name. A workaround is to have a private variable "init" which is by default 0. It indicates if the object was loaded completely.

http://dl.dropbox.com/u/5426011/examples13/ini_load.zip
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Wed Aug 08, 2012 2:32 pm

Thanks alot R0J0hound, I will try it out!
B
5
S
1
G
2
Posts: 28
Reputation: 806


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests