Frictional Games Forum (read-only)

Full Version: Use item in other levels
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Yea so the idea is that you pick up an item in one level.
Use it on an area to get another item, in the same level.
Then that is used on an area in another level.

But the last thing won't work!

My keys work the same way (Except they ain't traded for another item)

My script:

LEVEL 1

void OnEnter()
{

AddUseItemCallback("", "glas", "gryde", "GlasGryde", true);
AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);
}

///////////////////// This is where you trade the item ("glas") to get "fiskeolie" (glass_container_mix_done)


void GlasGryde(string &in asItem, string &in asEntity)
{
GiveItem("", "glass_container_mix_done", "fiskeolie", "glass_container_mix_done.tga", 1);
RemoveItem("glas");
AddPlayerSanity(5.0f);
}

/////////////////////This is where the item is used in LEVEL 2 (But i also put it in this script file)
void UseItemOnArea(string &in asItem, string &in asEntity)
{
RemoveItem("fiskeolie");
SetEntityActive("Fiskeolie_static_1", true);
SetSwingDoorLocked("mansion_5", true, true);
StartPlayerLookAt("mansion_8", 10, 10, "");
AddTimer("", 0.3, "LookAtDoor_1");
}

LEVEL 2


void OnStart()
{
AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);

}

/////////////////////Same script from LEVEL 1


void UseItemOnArea(string &in asItem, string &in asEntity)
{
RemoveItem("fiskeolie");
SetEntityActive("Fiskeolie_static_1", true);
SetSwingDoorLocked("mansion_5", true, true);
StartPlayerLookAt("mansion_8", 10, 10, "");
AddTimer("", 0.3, "LookAtDoor_1");
}

But in LEVEL 2 i can't use the item on the area...

I tried making the item (with same subitemtypename) in LEVEL 2, so the player just had to pick it up.
It worked perfectly! What am i missing?
not that experienced with this sort of thing, but if you made a callback for an item on an area, no matter where you got the item (aslong as you have its name scripted to interact with the callback) it should still work the same. like i said, not too experienced with this sort of thing
You're right darkadders. You only need the item scripted and named and it will work. That's what Your Computer told me atleast.

"Items are carried over from other maps, and items are referenced by
their name, so it should work just like any other use item callback."
Edit: Nevermind. Missed a line.
So in the script what do i have to delete/add?
EDIT: And in which script?
Try this for level 2:
Code:
void OnStart()
{
AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);
void AddDebugMessage("OnStart has added AddUseItem.", 1);
}

If you enter the level for the second time, this message shouldn't pop up. If you have a level that can be exited and re-entered, use OnEnter() instead.
(04-23-2012, 10:54 AM)Cranky Old Man Wrote: [ -> ]Try this for level 2:
Code:
void OnStart()
{
AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);
void AddDebugMessage("OnStart has added AddUseItem.", 1);
}

If you enter the level for the second time, this message shouldn't pop up. If you have a level that can be exited and re-entered, use OnEnter() instead.
*SLAP* GET ON WITH YOUR MODDING! ø_ø ^^
(04-23-2012, 10:57 AM)darkadders Wrote: [ -> ]*SLAP* GET ON WITH YOUR MODDING! ø_ø ^^
But I've just woken up. Sad
Aw, you're right - I should get some breakfast first, though.

(04-23-2012, 11:07 AM)Cranky Old Man Wrote: [ -> ]
(04-23-2012, 10:57 AM)darkadders Wrote: [ -> ]*SLAP* GET ON WITH YOUR MODDING! ø_ø ^^
But I've just woken up. Sad
Aw, you're right - I should get some breakfast first, though.




...


Spoiler below!
(╯°□°)╯︵ ┻━┻
(At First: Always check the names of the objects that you want to use [CASE SENSITIVE]. 90% of the bugs I have are caused by that. And 9% of what is left is caused by forgetting to copy (string &in asEnitiy) or something like that to my new function.)
Maybe one of these AddUseItemCallbacks is overwriting the other. In order to avoid that I would remove the Function of the script of level 1. And I would put the function in the OnStart instead of OnEnter.

So this code:

Code:
void OnEnter()

{

AddUseItemCallback("", "glas", "gryde", "GlasGryde", true);

AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);

}

can you change to this:

Code:
void OnStart()

{

AddUseItemCallback("", "glas", "gryde", "GlasGryde", true);

}


If that doesn't solve your problem:I've created 2 Levels where I've done nearly the same as you did. The diffrence is that my item can be found in the one map and wasn't created by scripting. It works fine in my levels, so you could maybe make a entity with the object you want to get and make active = false and just set it active in the script of level 1.
Pages: 1 2