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
Trying to get a script to work
Akasu Offline
Member

Posts: 62
Threads: 6
Joined: Aug 2010
Reputation: 2
#1
Trying to get a script to work

This is what I've got:

void StateChangeLever(string &in asEntity, int alState)
{
if(alState == 1){
SetLeverStuckState(asEntity, 1, true);
}
}

^ This part works allright.
...

void Burn("fireplace_1",OnIgnite)
{
if(GetLeverState ("fire_lever_1") < 1){
SetLampLit("fireplace_1", false, true);
}

if(GetLeverState ("fire_lever_1") == 1){
SetLampLit("fireplace_1", true, true);
}
}

The Burn is written on the CallbackFunc-field of the fireplace_1 in the editor
It crashes when I try to start the level and gives an error like this :
"main (8,11) : ERR : expected data type"

I was trying to make a fire burn only when a specific lever had been pulled... Any ideas why it doesn't work ?
09-19-2010, 11:02 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#2
RE: Trying to get a script to work

I can't try out if it works, but I'd say it has to be like this:

void StateChangeLever(string &in asEntity, int alState)
{
if(alState == 1){
SetLeverStuckState(asEntity, 1, true);
}
Burn();
}

void Burn()
{
if(GetLeverState ("fire_lever_1") < 1){
SetLampLit("fireplace_1", false, true);
}

if(GetLeverState ("fire_lever_1") == 1){
SetLampLit("fireplace_1", true, true);
}
}

09-19-2010, 12:06 PM
Find
Akasu Offline
Member

Posts: 62
Threads: 6
Joined: Aug 2010
Reputation: 2
#3
RE: Trying to get a script to work

Thanks, it didn't crash but now pulling the lever lights the fire. It's supposed to be lit by the player after pulling the lever. And the script doesn't stop the player from lighting the fire when the lever is not in the right position.
I tried removing the "Burn();" from the StateChangeLever part and the lever didn't light the fire (as it's not supposed to) but it didn't fix the problem with the fire catching only when the lever is in correct position.
09-19-2010, 03:14 PM
Find
khawaja07 Offline
Junior Member

Posts: 47
Threads: 9
Joined: Sep 2010
Reputation: 0
#4
RE: Trying to get a script to work

oooooh... i think that this is all C++ coding..
09-19-2010, 03:35 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#5
RE: Trying to get a script to work

Then do:
void StateChangeLever(string &in asEntity, int alState)
{
if(alState == 1){
SetLeverStuckState(asEntity, 1, true);
Burn();
}
}

instead. I just put Burn() one line further up inside the if(alState == 1){ } instead of after it.

09-19-2010, 03:36 PM
Find
Akasu Offline
Member

Posts: 62
Threads: 6
Joined: Aug 2010
Reputation: 2
#6
RE: Trying to get a script to work

Umm.. It does the same thing. I'm not sure if you understood what I'm trying to do here.
The player needs to make the fire with a tinderbox but that is only possible after pulling a certain lever (Open a chimney hatch so the fire gets air in this case)
09-19-2010, 05:59 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#7
RE: Trying to get a script to work

Edit: Nvm about what I wrote. I have something in mind that could be of use. I will quickly build a map and try it out.

Old post:
Spoiler below!

Ah.. that's a totally different case.
I know no solution for that, only a workaround which doesn't look well.
I would deactivate the bonfire and uncheck lit in the editor and make it active with that lever trigger, but that means you wouldn't see the wood pile as long as the lever isn't pulled.


09-19-2010, 06:08 PM
Find
Akasu Offline
Member

Posts: 62
Threads: 6
Joined: Aug 2010
Reputation: 2
#8
RE: Trying to get a script to work

Nice. Try it Smile I'm guessing you'll have to use the OnIgnite thingy but what do I know :S Big Grin
09-19-2010, 06:29 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#9
RE: Trying to get a script to work

Okay, here is my solution:

Add a script area that covers the wood pile in the stove so you won't be able to interact with the fire. I called it "InteractArea".

Here comes the script part:
void OnStart()
{
SetEntityPlayerInteractCallback("InteractArea", "ChimneyNotClosed", false); //makes the area interactable
SetEntityCustomFocusCrossHair("InteractArea", "Ignite"); //gives the InteractArea an ingite icon instead of a hand icon
}

void ChimneyNotClosed(string &in entity)
{
    AddDebugMessage("pull the freaking lever first!", false);
//ToDo: Stuff that you want to happen when the player "interacts" with the fire and the lever is not pulled yet
}

void StateChangeLever(string &in asEntity, int alState)
{
    if(alState == 1){
    SetLeverStuckState(asEntity, 1, true);
    SetEntityActive("InteractArea", false);
}
}

You won't need the burn part anymore, just make sure you uncheck the "lit"-box in the editor.
The player won't be able to interact with the pile as long as the lever is not pulled, since the script area blocks it. You can give the player a message (by using SetMessage("Message", "YourEntryHere", 0); <- also need to add an entry in extra_english.lang) that he has to open the hatch in the chimney first.

<CATEGORY Name ="Message">
<Entry Name="YourEntryHere">I can't light the fire as long as the hatch in the chimney is closed. Maybe there is a lever around.</Entry>
</CATEGORY>

09-19-2010, 06:42 PM
Find
Akasu Offline
Member

Posts: 62
Threads: 6
Joined: Aug 2010
Reputation: 2
#10
RE: Trying to get a script to work

Thanks a lot, man! Big Grin No way I could have figured that out myself.
09-19-2010, 07:14 PM
Find




Users browsing this thread: 3 Guest(s)