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
Transferring Items from Different Maps
TimmayIsHawt Offline
Junior Member

Posts: 20
Threads: 9
Joined: Jul 2011
Reputation: 0
#1
Transferring Items from Different Maps

Hey guys, I don't really understand how to transfer items to other scripts or maps. Can someone explain how I could do this? Huh
(This post was last modified: 08-15-2011, 12:50 AM by TimmayIsHawt.)
08-13-2011, 09:38 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: Transferring Items from Different Maps

If you pick something in one map, it will automatically transfer to another map in your inventory.

08-14-2011, 12:56 AM
Website Find
TimmayIsHawt Offline
Junior Member

Posts: 20
Threads: 9
Joined: Jul 2011
Reputation: 0
#3
RE: Transferring Items from Different Maps

No like, what I want to do is have the item from a different map (say it was a key.) Make it able to unlock a door from the map you're in. Pretty much using an item from a different map to make it do something (anything) on another.
08-14-2011, 01:12 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: Transferring Items from Different Maps

I think you're confused, or I am.

A key is an item, items can be carried around through whichever maps and used for whichever thing you want it to be used for. There's nothing complicated to it. Worse case, you can just use a global variable to check if the player has the item or not. I don't really know what you are trying to get out of this, but I'm sure it was answered before.

08-14-2011, 01:24 AM
Find
TimmayIsHawt Offline
Junior Member

Posts: 20
Threads: 9
Joined: Jul 2011
Reputation: 0
#5
RE: Transferring Items from Different Maps

Lol, I think I'm confused. I'm still a beginner at scripting. I wanted to know how I could make it so that if I use a key from a different map, it'll be able to unlock a door from another map.
08-14-2011, 03:43 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: Transferring Items from Different Maps

You find a key in a map, for the sake of examples. The key's name is "Key01" and the map's name is "Map01". The map where you use the key will be called "Map02". So the player picks up the item "Key01" in "Map01", and then goes to "Map02" where the locked door is. Let's call this locked door, "LockedDoor01". Then you add an AddUseItemCallback command function followed by another function that unlocks the door with that key. It's quite simple, no crazy stuff involved. Smile

void OnStart()
{
     AddUseItemCallback("", "Key01", "LockedDoor01", "Func01", false);
}
void Func01(string &in asItem, string &in asEntity)
{
     SetSwingDoorLocked(asEntity, false, true);
     PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
     RemoveItem(asItem);
}

But if it doesn't work, then it'll require some more scripting that involves global variables to check if the player picks up the key so then the item can properly be removed when leaving the level, and then recieving a new one once they enter another level. Tongue

08-14-2011, 04:07 AM
Find
TimmayIsHawt Offline
Junior Member

Posts: 20
Threads: 9
Joined: Jul 2011
Reputation: 0
#7
RE: Transferring Items from Different Maps

if it doesn't work, how will I be able to do it then? I'm still confused about global variables and how it works, so I really don't know how I should start if it doesn't work out.
08-14-2011, 09:07 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#8
RE: Transferring Items from Different Maps

(08-14-2011, 09:07 PM)TimmayIsHawt Wrote: if it doesn't work, how will I be able to do it then? I'm still confused about global variables and how it works, so I really don't know how I should start if it doesn't work out.

A global variable can be used across your whole custom story. There is a file called "global.hps" which is a file that is created in your custom story's "maps" folder or where you put all your scripts and maps for your custom story. In that file that you make, that's called "global.hps", you can setup global variables that can check something throught your maps. In this case it will be "Key01", for the sake of examples. This is what the "global.hps" file will look like when including a global variable called, "KeyCheck01":

void OnGameStart()
{
     SetGlobalVarInt("KeyCheck01", 0);
}

So now, corresponding to the example I previously posted, in "Map01.hps" you could add this in your script:

void OnStart()
{
     SetEntityPlayerInteractCallback("Key01", "Func01", true);
}
void Func01(string &in asEntity)
{
     SetGlobalVariableInt("KeyCheck01", 1);
}
void OnEnter()
{
     if (GetGlobalVarInt("KeyCheck01") == 1)
     {
          GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);
     }
}
void OnLeave()
{
     if (GeGlobalVarInt("KeyCheck01") == 1)
     {
          RemoveItem("Key01");
     }
}

Then in the script file called "Map02.hps", have this:

void OnEnter()
{
     if (GetGlobalVarInt("KeyCheck01") == 1)
     {
          GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);
     }
}
void OnLeave()
{
     if (GeGlobalVarInt("KeyCheck01") == 1)
     {
          RemoveItem("Key01");
     }
}

Then still in the "Map02.hps" script file, you'll have to add this line of code into the function where the key gets used and removed when it unlocks the door:

SetGlobalVarInt("KeyCheck01", 0);


Where I had this, I don't know exactly what the key is, so I just copy and pasted it out of the wiki, which does require for you to fill it out with the correct information about the key.

GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);

I hope this helps! Smile

08-14-2011, 09:52 PM
Find
Nathannnnr93 Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2011
Reputation: 0
#9
RE: Transferring Items from Different Maps

Do you mean use the key on an entity (object) in one map, then it unlocks a door on a different map, so you wont be carrying the key to that door?
08-14-2011, 09:59 PM
Find
TimmayIsHawt Offline
Junior Member

Posts: 20
Threads: 9
Joined: Jul 2011
Reputation: 0
#10
RE: Transferring Items from Different Maps

Okay, thanks guys! It worked! Smile
08-15-2011, 12:49 AM
Find




Users browsing this thread: 1 Guest(s)