Frictional Games Forum (read-only)
[HELP] Script Enabling/Variables - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [HELP] Script Enabling/Variables (/thread-16639.html)

Pages: 1 2 3


RE: [HELP] Script Enabling/Variables - Cruzore - 07-04-2012

tell us exactly what you are trying to achieve, what the problem is and if there's an error message.
"There still is no restriction, I'm able to commit the scripts even if I haven't done the previous action leading up."
That doesn't make sense in any way I can think off.


RE: [HELP] Script Enabling/Variables - himynamebob1 - 07-04-2012

The purpose of the variables is to prevent the player of putting a glass jar on the ground until they stab a knife into a keg of wine. But, the script is ignoring the variables and allows me to put down the jar before I even stab the knife in.


RE: [HELP] Script Enabling/Variables - Cruzore - 07-04-2012

Looking at the names of your script gives me headaches, so i'll just explain it like this:
So, you want to only put down a jar if you used the knife first.
void OnStart()
{
AddUseItemCallback("randomname1", "knife", "keg", "KnifeTheKeg", false);
AddUseItemCallback("randomname2", "jar", "keg", "JarTheKeg", false);
AddLocalVarInt("SomeVariable", 0);
}
void KnifeTheKeg(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
//fancy stuff like sounds etc here
AddLocalVarInt("SomeVariable", 1);

}
JarTheKeg(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("SomeVariable")==1)
{
RemoveItem(asItem);
//Your other stuff here, like fancy stuff and what should happen
}
}

This is just an example


RE: [HELP] Script Enabling/Variables - himynamebob1 - 07-05-2012

It did not work.


RE: [HELP] Script Enabling/Variables - Cruzore - 07-05-2012

Woops, I made a mistake myself.
void OnStart()
{
AddUseItemCallback("randomname1", "knife", "keg", "KnifeTheKeg", false);

}
void KnifeTheKeg(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
//fancy stuff like sounds etc here
AddUseItemCallback("randomname2", "jar", "keg", "JarTheKeg", false);

}
JarTheKeg(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
//Your other stuff here, like fancy stuff and what should happen

}
That should work. And even without variables, by just placing the callbacks in the right position.


RE: [HELP] Script Enabling/Variables - himynamebob1 - 07-05-2012

That works with the keg but not the fire.


RE: [HELP] Script Enabling/Variables - Cruzore - 07-05-2012

what fire? You only mentioned that the keg wouldn't work. You only said something like "I want to let the jar be only placeable once you knifed the keg" and nothing about a fire...?
EDIT: Oh, I see. I think there was a similiar topic, wait a minute.


RE: [HELP] Script Enabling/Variables - himynamebob1 - 07-05-2012

After the jar is full I would like the player to take it to a furnace then have to light the furnace before they can cook the containments.


RE: [HELP] Script Enabling/Variables - Cruzore - 07-05-2012

I don't know if it works, but try this:
inside the JarTheKeg function, place this:

AddUseItemCallback("randomname3", "tinderbox_1", "Your furnace Name Here", "LightTheFire", true);

then, add this function somewhere:

void LightTheFire(string &in asItem, string &in asEntity)
{
AddUseItemCallback("randomname4", "jar", "Your furnace Name Here", "JarTheFire", true);
}

then, another function:

void JarTheFire(string &in asItem, string &in asEntity)
{
stuff you want to happen here.
}

However, I am not sure if it works like this with the tinderbox. I'm assuming by "checking if the furnace is on" you mean using a tinderbox on a unlit fireplace or something. If so, then this might work. You can also do this with a lever or something, but it's a different code then.


RE: [HELP] Script Enabling/Variables - himynamebob1 - 07-05-2012

The player is able to receive other tinderboxes previously in the CS though.