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


Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
script again..
Alento Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2012
Reputation: 0
#1
Exclamation  script again..

Hey again!

Look:


void startoven(string &in asEntity, int alState)
{
if (asName == "ovenlever")
{
GetEntitiesCollide("contWW_2", "placeWW");
if(alState == -1){
SetEntityActive("contWW_2", false);
SetEntityActive("contBmeat", true);

}
}
}

What I want, it that the "contBmeat" will be active IF you have placed "contWW_2" at the "placeWW" area.
And only when you have placed it there, will the "ovenlever" make the "contBmeat" exist. Do you get what I mean? Tongue I've never used "GetEntitiesCollide", how does it work? In general, what does "bool" mean exactly, cuz in Engine script, it says bool before GetEntitiesCollide, what does it mean? please help me asap! need to continue the scripting.
and this is in my path to do that.. Sad

Peace!

---------Want help with YOUR Custom Story? ---------
http://www.frictionalgames.com/forum/user-19049.html
09-09-2012, 11:43 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: script again..

If you look in the HPL2 Engine Scripts Wiki, you will see any "Get" function prefaced with something like bool, int, or float. bool (Boolean) means true or false, int (Integer) means a whole number and float is a decimal (i.e. 27.8f). Based on whether it is bool, int, or float will dictate what you put after the "==".

"GetEntitiesCollide" is used to check if two entities are in contact with one another. It is generally used with a movable entity and a script area ("Player" isn't compatible with this function, and the 2 entities must be able to enter one another, not just make surface contact.)

As for your script problem, there are a few questions I'd like to ask before delving into this:

-Are you using the extraction oven from entities/lab
-What entities (items) correspond to the name? It would be tremendously helpful if I knew what "contWW_2" or "placeWW" were. If I try to make guesses, there is a much higher chance of me not being able to help you properly.

I rate it 3 memes.
09-10-2012, 12:15 AM
Find
Alento Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2012
Reputation: 0
#3
RE: script again..

(09-10-2012, 12:15 AM)andyrockin123 Wrote: If you look in the HPL2 Engine Scripts Wiki, you will see any "Get" function prefaced with something like bool, int, or float. bool (Boolean) means true or false, int (Integer) means a whole number and float is a decimal (i.e. 27.8f). Based on whether it is bool, int, or float will dictate what you put after the "==".

"GetEntitiesCollide" is used to check if two entities are in contact with one another. It is generally used with a movable entity and a script area ("Player" isn't compatible with this function, and the 2 entities must be able to enter one another, not just make surface contact.)

As for your script problem, there are a few questions I'd like to ask before delving into this:

-Are you using the extraction oven from entities/lab
-What entities (items) correspond to the name? It would be tremendously helpful if I knew what "contWW_2" or "placeWW" were. If I try to make guesses, there is a much higher chance of me not being able to help you properly.
Oh! okey,Smile sooo.. am I using the right code, or should I use another? Or is it after the "==" i have to change something? Smile

---------Want help with YOUR Custom Story? ---------
http://www.frictionalgames.com/forum/user-19049.html
09-10-2012, 12:22 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: script again..

Like I said before, until I'm sure what entities correspond with what names in the script I couldn't tell you if you are using them correctly. I understand what you're trying to accomplish, I just don't understand what a "contWW_2" (or any other name) is in game.

I rate it 3 memes.
09-10-2012, 12:28 AM
Find
Alento Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2012
Reputation: 0
#5
RE: script again..

(09-10-2012, 12:28 AM)andyrockin123 Wrote: Like I said before, until I'm sure what entities correspond with what names in the script I couldn't tell you if you are using them correctly. I understand what you're trying to accomplish, I just don't understand what a "contWW_2" (or any other name) is in game.
oh.. sorry.. okey. here it is!

void startoven(string &in asEntity, int alState)
{
GetEntitiesCollide("contWW_2", "placeWW");
if (GetEntitiesCollide("contWW_2", "placeWW") == true);<-- contWW_2 is a container, placeWW is an area
{


if(alState == -1){
SetEntityActive("contWW_2", false);
SetEntityActive("contBmeat", true); <-- another container which should replace the other one.

}
}
}

did that help more? Smile

used by this:
SetEntityConnectionStateChangeCallback("ovenlever", "startoven");

---------Want help with YOUR Custom Story? ---------
http://www.frictionalgames.com/forum/user-19049.html
(This post was last modified: 09-10-2012, 12:37 AM by Alento.)
09-10-2012, 12:35 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: script again..

First, in the level editor find the area "placeWW", in the second tab, make sure "Item Interaction" is checked. Here's the script based on what I think you're trying to accomplish:


void OnStart()
{
SetLocalVarInt("PlaceItemVar", 0);
AddUseItemCallback("", "contWW_2", "placeWW", "ItemInOven", true); ///when the player uses "contWW_2" on "placeWW", it triggers "ItemInOven".
SetEntityConnectionStateChangeCallback("ovenlever", "PullLever"); //Triggers the function "PullLever" when the lever is pulled.
}

void ItemInOven(string &in asItem, string &in asEntity) //Removes the item from inventory, adds a variable
{
RemoveItem(asItem);
AddLocalVarInt("PlaceItemVar", 1);
}

void PullLever(string &in asEntity, int alState) //If the variable is 1 and the lever is pulled, "contBmeat" will be set active
{
if(GetLocalVarInt("PlaceItemVar") == 1 && alState == -1)
{
SetEntityActive("contBmeat", true);
}
}

I hope that's more along the lines of what you want to accomplish;l if there are still any issues/problems, reply back with explicit detail of exactly you want the player to do for this puzzle.

Hope that helped!

I rate it 3 memes.
09-10-2012, 12:49 AM
Find




Users browsing this thread: 1 Guest(s)