05-30-2011, 02:34 PM
Searched the forum, and couldn't really find a thread to help me, neither could I fully understand the one on the wiki, so I hope maybe one of you guys can make me understand a bit more
So I've been trying to understand how "if" actually works, I know it's something with locked door got state 0 and unlocked like 1, and if it's 1 something happens, and 0 something else happens, but i have no clue how to script it, and where to put which line of code
This is my script, and what I wanna do is remove the message after the door is unlocked :o
So I've been trying to understand how "if" actually works, I know it's something with locked door got state 0 and unlocked like 1, and if it's 1 something happens, and 0 something else happens, but i have no clue how to script it, and where to put which line of code
This is my script, and what I wanna do is remove the message after the door is unlocked :o
Spoiler below!
void OnStart()
{
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
SetPlayerLampOil(100.0f);
for(int i = 0;i < 10;i++)
{
GiveItemFromFile("tinderbox", "tinderbox.ent");
}
}
AddUseItemCallback("", "Honey", "mansion_1", "UsedHoneyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "TriggerFunction", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Ragdoll", true, 1);
SetEntityPlayerInteractCallback("mansion_1", "LockedDoor", false);
}
void LockedDoor(string &in entity)
{
SetMessage("TestStory", "ItemDesc_mansion_1", 0);
}
void UsedHoneyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
RemoveItem("Honey");
}
{
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
SetPlayerLampOil(100.0f);
for(int i = 0;i < 10;i++)
{
GiveItemFromFile("tinderbox", "tinderbox.ent");
}
}
AddUseItemCallback("", "Honey", "mansion_1", "UsedHoneyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "TriggerFunction", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Ragdoll", true, 1);
SetEntityPlayerInteractCallback("mansion_1", "LockedDoor", false);
}
void LockedDoor(string &in entity)
{
SetMessage("TestStory", "ItemDesc_mansion_1", 0);
}
void UsedHoneyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
RemoveItem("Honey");
}