About Store Forum Documentation Contact



Post Reply 
Build 21 Game::ObjParams.type
Author Message
fatcoder Offline
Member

Post: #1
Build 21 Game::ObjParams.type
Just upgraded to build 21 to find the way I've been setting Game::ObjParams.type doesn't work any more. I read about the change in the version history. I'm just wondering what is the correct way to be handling this now.

I used to do this.

Code:
obj.type(true, "OBJECT_ID_HERE");

I've now changed it to this.

Code:
obj.type(true, Game::ObjType.elmID(OBJECT_ID_HERE));

Is this correct?

What about if you have a Str name of a dynamically set object to create. Are you supposed to do something like this?

Code:
obj.type(true, Game::ObjType.elmID(Game::ObjType.find(strObjectType)));

Just seems so long winded?
02-22-2013 12:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Build 21 Game::ObjParams.type
Currently yes, that's the right method.
I'm aware that 2 calls may be a bit too much of writing, I'll keep that in mind and try to improve it in the future.
02-22-2013 12:31 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: Build 21 Game::ObjParams.type
Would be nice if it could handle it internally, so you could just pass in the object type.

Anyway, I'm having some trouble with it though. I've changed my code from this.

Code:
obj.type(true, "OBJ_TYPE");

To this.

Code:
obj.type(true, Game::ObjType.elmID(OBJ_TYPE));

However, I'm getting this error now.

   

I definitely have this code in there.

Code:
Game::ObjType = "Enum/obj_type.enum";

I even tried opening the world editor thinking maybe it needs to rebuild the enum binary (haven't done it in months). But that didn't help.

Is there a new step involved now that I'm not doing?
02-22-2013 02:10 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Build 21 Game::ObjParams.type
I think that issue is unrelated, that error should be called if you're trying to do

Game::ObjType(id);
or
Game::ObjType(name);

Code:
struct Enum
{
   Int     operator()(CChar8 *name)C;                       // get index   of enum element, Exit      on fail
   Int     operator()(CChar  *name)C;                       // get index   of enum element, Exit      on fail
   Int     operator()(C UID  &id  )C;                       // get index   of enum element, Exit      on fail

Please post the codes at line at which the error occurs.
02-22-2013 02:14 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #5
RE: Build 21 Game::ObjParams.type
Here is the code. If I comment this out (specifically the third line), it all runs fine.

OBJ_TYPE is just one of the obj types in my obj_type.enum. It definitely exists in the file.

Code:
Game::ObjParams obj;
obj.type(true, Game::ObjType.elmID(OBJ_TYPE));
Game::World.objCreateNear(obj, matrix);

Actually, I might have jumped the gun there. I think the issue might be deeper than that, inside the object itself. Let me keep looking.
(This post was last modified: 02-22-2013 02:26 PM by fatcoder.)
02-22-2013 02:19 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Build 21 Game::ObjParams.type
Can you attach the callstack when the error happens?
02-22-2013 02:36 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #7
RE: Build 21 Game::ObjParams.type
Not to worry, I found the problem.

I was trying to get the Str of the object type and was calling this, not realising it was giving me the Str of the UID.

Code:
obj.type().asText();

Anyway, I changed it to this, and it solved the problem.

Code:
Game::ObjType.elmName(Game::ObjType.find(obj.type()));

Would be nice if there was a more elegant way to do all this stuff though.
02-22-2013 02:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Build 21 Game::ObjParams.type
yeah I've just implemented it, will be uploaded within an hour smile
02-22-2013 02:43 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #9
RE: Build 21 Game::ObjParams.type
Cheers! smile
02-22-2013 03:03 PM
Find all posts by this user Quote this message in a reply
Post Reply