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
How do I make a lever???
Brute Offline
Member

Posts: 197
Threads: 10
Joined: Aug 2011
Reputation: 3
#1
Rainbow  How do I make a lever???

I have search in different threads, but with no efforts. My levers won't work! i am freaking out ;D
It would be nice, if someone of you could make a step-by-step tutorial for me. Just with... What must i set in the editor and in the script.

Please... I really need your help Sad






(This post was last modified: 09-25-2011, 07:42 AM by Brute.)
09-23-2011, 03:43 PM
Find
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#2
RE: How do I make a lever???

If you just place a lever (even in thin air i believe) it should work just fine.

Now if you want the lever to actually DO something when it's used, you're going to have to use script for that.

And if you're going to want help with that, you're also going to have to be more specific. ^^

09-23-2011, 04:37 PM
Find
Brute Offline
Member

Posts: 197
Threads: 10
Joined: Aug 2011
Reputation: 3
#3
RE: How do I make a lever???

OK more specific Big Grin

A lever opens a door. Sounds simple. NOT FOR ME!!! Rolleyes Shy Rolleyes
What must I do in the editor and which script must I wrote?
Damn you won't believe, what I have tried... It is terrible... no success...





09-23-2011, 05:48 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#4
RE: How do I make a lever???

there isn't any extremely difficult code to do, the principle is exactly the same as a script area. - A Callback is called then a function(such as Unlock) is run. The only difference is that the callback is a LeverState callback instead of a Collide Callback.

So first of all, unlike "AddEntityCollideCallback" there is no script function called for example... "AddLeverCallback"
You must Add the Callback in LevelEditor.

So click on the Lever, click the Tab on the right. Then scroll to ConnecctionStateChangeCallback, put a name in the box (Such as "OnLeverPull")

then in your code put:

void OnLeverPull(string &in asEntity , int alState)
{
if(alState==x){}
}

// - if(alState==x){} can be used to determine whether the lever is up or down. Good Luck Smile

(This post was last modified: 09-23-2011, 06:24 PM by DRedshot.)
09-23-2011, 06:22 PM
Find
Brute Offline
Member

Posts: 197
Threads: 10
Joined: Aug 2011
Reputation: 3
#5
RE: How do I make a lever???

Sadly it doesn't work. The lever doesn't stuck or do anything Sad Confused
HELP!!!





09-24-2011, 08:13 AM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#6
RE: How do I make a lever???

well does it call the callback? I'm not sure what you want it to do, but if you want it to stick up if you pull it up, use the "SetLeverStuckState"

Sorry if it doesn't work, I haven't made any levers in a while

if(alState==1){
SetLeverStuckState(asEntity , 1 , true);
}

That should work, if not, then just use script areas which collide with the lever at the top and the bottom Smile

09-24-2011, 08:51 AM
Find
Brute Offline
Member

Posts: 197
Threads: 10
Joined: Aug 2011
Reputation: 3
#7
RE: How do I make a lever???

It doesn't work again, but thanks for your try DRedshot! Big Grin
At this point I show you my script :
------------------------------------------------------------------------------------------------------
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "Enemy02_appear" , "Enemy02_appear" , true , 1);
AddEntityCollideCallback("LeverExit" , "ExitOpen" , "OpentheExit" , true , 1);
SetEntityPlayerInteractCallback("Library_Key", "Enemy03_appear", true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
SetPlayerLampOil(0);
PlayMusic("10_amb.ogg", true, 1.0f, 0, 0, true);
AddUseItemCallback("", "PrisonDoor_Key", "PrisonDoor", "KeyOnDoor1", true);
AddUseItemCallback("", "Ceiling_Key", "Ceiling", "KeyOnDoor2", true);
AddUseItemCallback("", "Library_Key", "Library", "KeyOnDoor3", true);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
////////////////////////////
// Actual functions

void KeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("PrisonDoor", false, true);
RemoveItem("PrisonDoor_Key");
PlaySoundAtEntity("", "unlock_door.snt", "PrisonDoor", 0.0f, true);
SetEntityActive("Enemy01" , true);
}

void Enemy02_appear(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("Enemy02" , true);
}

void Enemy03_appear(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("Enemy03" , true);
AddEnemyPatrolNode("Enemy03", "Path0", 1000000.0f, "true");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Ceiling", false, true);
RemoveItem("Ceiling_Key");
PlaySoundAtEntity("", "unlock_door.snt", "Ceiling", 0.0f, true);
}

void KeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Library", false, true);
RemoveItem("Library_Key");
PlaySoundAtEntity("", "unlock_door.snt", "Library", 0.0f, true);
}

void OpentheExit(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Basement", false, true);
SetEntityActive("Guard01" , true);
PlaySoundAtEntity("LeverExit", "levelexitopen.ogg", "Player", 0.5f, false);
SetEntityActive("Guard02" , true);
SetEntityActive("Guard03" , true);
}
------------------------------------------------------------------------------------------------------
(I have removed the PatrolNodes, because they would explode my post)
The Lever has the settings:
Name: LeverExit
The ScriptArea has the setting:
Name: ExitOpen

Huh Huh Huh
So what is wrong? Any ideas?





09-24-2011, 11:52 AM
Find
Brute Offline
Member

Posts: 197
Threads: 10
Joined: Aug 2011
Reputation: 3
#8
RE: How do I make a lever???

I found the error. This line was wrong:
void OpentheExit(string &in asItem, string &in asEntity)
Big Grin Thanks for your help Big Grin





09-24-2011, 03:21 PM
Find




Users browsing this thread: 1 Guest(s)