Frictional Games Forum (read-only)
Trying to get a script to work - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Trying to get a script to work (/thread-4562.html)

Pages: 1 2


Trying to get a script to work - Akasu - 09-19-2010

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 ?


RE: Trying to get a script to work - Pandemoneus - 09-19-2010

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

Code:
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);
}
}



RE: Trying to get a script to work - Akasu - 09-19-2010

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.


RE: Trying to get a script to work - khawaja07 - 09-19-2010

oooooh... i think that this is all C++ coding..


RE: Trying to get a script to work - Pandemoneus - 09-19-2010

Then do:
Code:
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.


RE: Trying to get a script to work - Akasu - 09-19-2010

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)


RE: Trying to get a script to work - Pandemoneus - 09-19-2010

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.




RE: Trying to get a script to work - Akasu - 09-19-2010

Nice. Try it Smile I'm guessing you'll have to use the OnIgnite thingy but what do I know :S Big Grin


RE: Trying to get a script to work - Pandemoneus - 09-19-2010

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:
Code:
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.

Code:
<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>



RE: Trying to get a script to work - Akasu - 09-19-2010

Thanks a lot, man! Big Grin No way I could have figured that out myself.