Frictional Games Forum (read-only)

Full Version: Set Entity Active Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello once again,

uuhm, ok so my problem is this

I have a nice closet.
I have a set of chairs + a round table which are tumbled over and all which I set to active in the level editor, then I have another set of chairs + a round table which are all nice and haven't tumbled over which are inactive.

Then I have this in my code file:

Code:
void OnStart()
{
    if(ScriptDebugOn())
    {
       GiveItemFromFile("lantern", "lantern.ent");

       for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
    }
    
    SetEntityPlayerInteractCallback("cabinet_nice_1", "cabinet_nice_1_callback", true);
}

void OnEnter()
{

}

void OnLeave()
{

}

void cabinet_nice_1_callback(){
    SetEntityActive("chair_nice02_9", true);
    SetEntityActive("chair_nice02_8", true);
    SetEntityActive("chair_nice02_10", true);
    SetEntityActive("table_nice_round_3", true);
    
    SetEntityActive("chair_nice02_5", false);
    SetEntityActive("chair_nice02_4", false);
    SetEntityActive("chair_nice02_6", false);
    SetEntityActive("table_nice_round_2", false);
}

So when I touch the cabinet or interact with the cabinet, (I am facing another direction) the tumbled over chair and table should dissapear and the chairs and table that are normal should appear. This doesn't work (this is 1 problem),
then I have another problem which is the normal standing table is already active when I load my map, which should be inactive untill I touch the cabinet.

I aready unchecked the active check saved loaded my map, and rechecked the active check saved and loaded my map but that doesn't work.

Or should I set the active and inactive things in my script in the onEnter function?

Thanks in advance, once again. :p
StaticObject entities cannot be (de)activated.
(07-12-2011, 05:00 PM)Tanshaydar Wrote: [ -> ]StaticObject entities cannot be (de)activated.

Damn, that sucks Sad, but why does it have an option to make it active or not then? :S
(07-12-2011, 05:26 PM)bigfoot Wrote: [ -> ]
(07-12-2011, 05:00 PM)Tanshaydar Wrote: [ -> ]StaticObject entities cannot be (de)activated.

Damn, that sucks Sad, but why does it have an option to make it active or not then? :S

It's not really an entity I guess, just a static object. There is a way to get it working by somehow editing the static object in the model editor to change it into an entity object. I tried doing it once, but I failed. I don't think I'll ever be able to figure completely how. :/
Oh it doesn't matter, then the chairs alone will circle around you :p just as creepy, maybe even creepier. anywho uuhm how can I make the interact callback actually work? cause I don't have any errors but the chairs don't activate.
(07-12-2011, 05:43 PM)bigfoot Wrote: [ -> ]Oh it doesn't matter, then the chairs alone will circle around you :p just as creepy, maybe even creepier. anywho uuhm how can I make the interact callback actually work? cause I don't have any errors but the chairs don't activate.

An interact callback looks like this, for example:

Code:
void OnStart()
{
     SetEntityPlayerInteractCallback("Object", "Func01", true);
}
void Func01(string &in asEntity)
{
     //Whatever you want to happen here.
}

You can use an interact callback with any entity or script area, but not a static object. The hook is that you could put a script area a little on the outside of the static object so it would be as if you interacted with the static object instead of the script area.

In your script, you forgot the parameters where your function is, as it should match (somewhat) with the callback you make.

void cabinet_nice_1_callback(string &in asEntity)

It isn't the callback that makes the function. It is the function already existing which gives the callback a reason to call the function.

In the function, you can refer to something as "asEntity" which makes the game know that you are talking about "cabinet_nice_1".
(07-12-2011, 06:01 PM)Kyle Wrote: [ -> ]
(07-12-2011, 05:43 PM)bigfoot Wrote: [ -> ]Oh it doesn't matter, then the chairs alone will circle around you :p just as creepy, maybe even creepier. anywho uuhm how can I make the interact callback actually work? cause I don't have any errors but the chairs don't activate.

An interact callback looks like this, for example:

Code:
void OnStart()
{
     SetEntityPlayerInteractCallback("Object", "Func01", true);
}
void Func01(string &in asEntity)
{
     //Whatever you want to happen here.
}

You can use an interact callback with any entity or script area, but not a static object. The hook is that you could put a script area a little on the outside of the static object so it would be as if you interacted with the static object instead of the script area.

In your script, you forgot the parameters where your function is, as it should match (somewhat) with the callback you make.

void cabinet_nice_1_callback(string &in asEntity)

It isn't the callback that makes the function. It is the function already existing which gives the callback a reason to call the function.

In the function, you can refer to something as "asEntity" which makes the game know that you are talking about "cabinet_nice_1".

Ah, I forgot the string &in asEntity
YUSH IT WORKS WOOHOO, THANK YOU SOOO MUCH.
(07-12-2011, 05:40 PM)Kyle Wrote: [ -> ]
(07-12-2011, 05:26 PM)bigfoot Wrote: [ -> ]
(07-12-2011, 05:00 PM)Tanshaydar Wrote: [ -> ]StaticObject entities cannot be (de)activated.

Damn, that sucks Sad, but why does it have an option to make it active or not then? :S

It's not really an entity I guess, just a static object. There is a way to get it working by somehow editing the static object in the model editor to change it into an entity object. I tried doing it once, but I failed. I don't think I'll ever be able to figure completely how. :/

Import the mesh from the static object into the Model Editor, then save it as its own custom entity in your custom story folder, and put it in the level editor like that. Make sure you make it a static entity!
(07-12-2011, 07:31 PM)Streetboat Wrote: [ -> ]Import the mesh from the static object into the Model Editor, then save it as its own custom entity in your custom story folder, and put it in the level editor like that. Make sure you make it a static entity!

Alright, I'll go try that. Thanks. Smile