PDA

View Full Version : saving itemID with scene



richhelvey
09-10-2013, 02:42 PM
I have an IItemMotion python script that references another object in the scene. I'd like to save that information in the scene file, so I've been messing around with the inst_save function.

I'd like to use state.lwsave_id(), but it's asking for a LWBlockIdent which is described in the C sdk as:


typedef struct st_LWBlockIdent {
LWID id;
const char *token;
} LWBlockIdent;

I can create a block like this:

block = lwsdk.LWBlockIdent()

but passing that into lwsave_id() crashes LW, and shouldn't work anyways since I'm not referencing the object anywhere.

I've tried setting

block.token = lwsdk.LWItemInfo().name(myObj)

but that's not working either. And i can't find any examples in the included scripts.

Has anyone gotten anything like this to work, and if so, how?

Thanks,
-Rich

Sensei
09-10-2013, 03:41 PM
Check out whether LWBlockIdent() has default constructor which takes id and name.

richhelvey
09-10-2013, 03:45 PM
Check out whether LWBlockIdent() has default constructor which takes id and name.

Nope. I get:
TypeError: __init__() takes exactly 1 argument (3 given)

Sensei
09-10-2013, 10:45 PM
Anyway, token is not the name of object-item, but name under which section of data will appear in .lws
When block is saved to .lwo, id is used (it's IFF chunk id, 4 chars)
When block is saved to .lws, token is used.

f.e.

{ Envelope
1
Key 0 0 0 0 0 0 0 0 0
Behaviors 1 1
}


"Envelope", "Key", "Behaviors" are examples of 3 different tokens.