Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use item in other levels
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
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
Find
Mine Turtle Offline
Senior Member

Posts: 647
Threads: 32
Joined: Mar 2011
Reputation: 29
#2
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

[Image: 201107142327000.gif]
04-23-2012, 09:40 AM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#3
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."

"What you think is irrelevant" - A character of our time

A Christmas Hunt
04-23-2012, 10:26 AM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#4
RE: Use item in other levels

Edit: Nevermind. Missed a line.

Noob scripting tutorial: From Noob to Pro

(This post was last modified: 04-23-2012, 10:40 AM by Cranky Old Man.)
04-23-2012, 10:39 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
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.
(This post was last modified: 04-23-2012, 10:48 AM by FlawlessHappiness.)
04-23-2012, 10:45 AM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#6
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.

Noob scripting tutorial: From Noob to Pro

04-23-2012, 10:54 AM
Find
Mine Turtle Offline
Senior Member

Posts: 647
Threads: 32
Joined: Mar 2011
Reputation: 29
#7
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! ø_ø ^^

[Image: 201107142327000.gif]
04-23-2012, 10:57 AM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#8
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. Sad
Aw, you're right - I should get some breakfast first, though.


Noob scripting tutorial: From Noob to Pro

04-23-2012, 11:07 AM
Find
Mine Turtle Offline
Senior Member

Posts: 647
Threads: 32
Joined: Mar 2011
Reputation: 29
#9
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. Sad
Aw, you're right - I should get some breakfast first, though.




...


Spoiler below!
(╯°□°)╯︵ ┻━┻

[Image: 201107142327000.gif]
(This post was last modified: 04-23-2012, 12:26 PM by Mine Turtle.)
04-23-2012, 12:25 PM
Find
Knittel Offline
Junior Member

Posts: 8
Threads: 1
Joined: Apr 2012
Reputation: 0
#10
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.

[Image: 2ZwH0ZGD0AwL2.png]
[TRACKMANIA]


04-23-2012, 01:06 PM
Find




Users browsing this thread: 1 Guest(s)