FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
Use item in other levels
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?
Trying is the first step to success.
|
|
04-23-2012, 09:22 AM |
|
Mine Turtle
Senior Member
Posts: 647
Threads: 32
Joined: Mar 2011
Reputation:
29
|
RE: Use item in other levels
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
|
|
04-23-2012, 09:40 AM |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
RE: Use item in other levels
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."
|
|
04-23-2012, 10:26 AM |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
RE: Use item in other levels
Edit: Nevermind. Missed a line.
(This post was last modified: 04-23-2012, 10:40 AM by Cranky Old Man.)
|
|
04-23-2012, 10:39 AM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Use item in other levels
So in the script what do i have to delete/add?
EDIT: And in which script?
Trying is the first step to success.
|
|
04-23-2012, 10:45 AM |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
RE: Use item in other levels
Try this for level 2:
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 |
|
Mine Turtle
Senior Member
Posts: 647
Threads: 32
Joined: Mar 2011
Reputation:
29
|
RE: Use item in other levels
(04-23-2012, 10:54 AM)Cranky Old Man Wrote: Try this for level 2:
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
RE: Use item in other levels
(04-23-2012, 10:57 AM)darkadders Wrote: *SLAP* GET ON WITH YOUR MODDING! ø_ø ^^ But I've just woken up.
Aw, you're right - I should get some breakfast first, though.
|
|
04-23-2012, 11:07 AM |
|
Mine Turtle
Senior Member
Posts: 647
Threads: 32
Joined: Mar 2011
Reputation:
29
|
RE: Use item in other levels
(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.
Aw, you're right - I should get some breakfast first, though.
...
(This post was last modified: 04-23-2012, 12:26 PM by Mine Turtle.)
|
|
04-23-2012, 12:25 PM |
|
Knittel
Junior Member
Posts: 8
Threads: 1
Joined: Apr 2012
Reputation:
0
|
RE: Use item in other levels
(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:
void OnEnter()
{
AddUseItemCallback("", "glas", "gryde", "GlasGryde", true);
AddUseItemCallback("", "fiskeolie", "gryde1", "UseItemOnArea", true);
}
can you change to this:
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.
[TRACKMANIA]
|
|
04-23-2012, 01:06 PM |
|
|