About Store Forum Documentation Contact



Post Reply 
Reading params on a Game::Chr?
Author Message
cdoty Offline
Member

Post: #1
Reading params on a Game::Chr?
Is there any reason that I would not be able to read a param from a Game::Chr obj?

Here's what I'm trying to use:

Code:
Game::Chr&    gameChar    = Chrs[iLoop];
            
Param*    pParam    = gameChar.obj->findParam(L"value");

In the editor i have a Param on the object:
Type: Int
Name: value
Value: 1

The params.elms is 1 on the obj.

This seems to be the same thing that's being done in the Sample world and in example 09. The only difference is that it's using a Game::Item instead of a Game::Chr.
(This post was last modified: 01-05-2016 09:12 AM by cdoty.)
01-05-2016 09:08 AM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #2
RE: Reading params on a Game::Chr?
1. Does every Chr have that parameter in its OBJECT_CLASS or did you apply it to just 1 Chr object in the world editor?
2. Did you also do: pParam.asInt(); (EDIT: My bad, misread the name)
(This post was last modified: 01-05-2016 09:34 AM by Tottel.)
01-05-2016 09:28 AM
Find all posts by this user Quote this message in a reply
cdoty Offline
Member

Post: #3
RE: Reading params on a Game::Chr?
I put the parameter on just the one instance. The OBJ_ITEM, from the examples, doesn't have it on the OBJECT_CLASS.

Yes I do use asInt, if it is not NULL. But it's always NULL.

pParam is sort-of hungarian notation. p means pointer. It was the coding standard at one the gaming companies I worked for, and I've had a hard time changing it. Prior to the job I used to despise that style notation.
(This post was last modified: 01-05-2016 09:42 AM by cdoty.)
01-05-2016 09:35 AM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #4
RE: Reading params on a Game::Chr?
About the name: Yeah.. I misread it and blame my lenses pfft I read it as pRaram (with an R).

I should test how reading the params work if it's not in the OBJECT_CLASS base. For now, can you try putting it on all instances? (not manually, but in the base OBJECT_CLASS)
01-05-2016 09:37 AM
Find all posts by this user Quote this message in a reply
cdoty Offline
Member

Post: #5
RE: Reading params on a Game::Chr?
It's actually reading from the Resource object, rather than the in game Object.

A Game::Item uses it's own parameters whereas as Game::Chr uses the ones from the Object drop on the scene.

I had a chance to look at the Character source file. A character sets it's Obj to the first obj of the Resource Object:

Code:
void Chr::create(Object &obj)
{
   ...
   T.obj =obj.firstStored(); // copy pointer to object stored in project data
   ...
}

The item does not.
(This post was last modified: 01-05-2016 03:49 PM by cdoty.)
01-05-2016 09:50 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Reading params on a Game::Chr?
The parameters which are specified in the World Editor (Object tab) can be accessed only by overriding the virtual create (Game::Obj class) method.
Other parameters may be accessed at any time as long as you've stored the pointer to the "obj.firstStored"
01-06-2016 09:56 AM
Find all posts by this user Quote this message in a reply
Post Reply