Frictional Games Forum (read-only)
[SCRIPT] Machine puzzle and other things - 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: [SCRIPT] Machine puzzle and other things (/thread-19060.html)

Pages: 1 2 3


RE: Machine puzzle and other things - The chaser - 11-04-2012

void OnStart()



{



AddEntityCollideCallback("Entity_1", "Script_1", "Blah", true, 1);



AddEntityCollideCallback("Entity_2", "Script_2", "Blah_1", true, 1);



}







void Blah (string &in asParent, string &in asChild, int alState)



{



AddLocalVarInt("Gangnam", 1);



func_check();



}







void Blah_1 (string &in asParent, string &in asChild, int alState)



{



AddLocalVarInt("Gangnam", 1);



func_check();



}







void func_check()



{



if (GetLocalVarInt("Gangnam") == 2)



{



SetEntityConnectionStateChangeCallback("Levar_elevator", "Map");



}



}







void Map (string &in asEntity, int alState)



{



if (alState == 1)



{



ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);



}



}

Sorry, now it should be fine.


RE: Machine puzzle and other things - CorinthianMerchant - 11-04-2012

It's still crashing...
Spoiler below!
Code:
void OnStart()
{
AddUseItemCallback("SteamRod", "MachineScript_1", "Elevator", true);
AddUseItemCallback("FlowRod", "MachineScript_2", "Elevator_1", true);
}

void Elevator (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("SteamRod_static", true);
PreloadSound("rod_in.snt");
AddLocalVarInt("ElevatorWork", 1);
func_check();
}

void Elevator_1 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("FlowRod_static", true);
PreloadSound("rod_in.snt");
AddLocalVarInt("ElevatorWork", 1);
func_check();
}

void func_check()
{
if (GetLocalVarInt("ElevatorWork") == 2)
{
PreloadSound("13_flow_done.snt");
SetEntityConnectionStateChangeCallback("elevator_lever_1", "Map");
}
}

void Map (string &in asEntity, int alState)
{
if (alState == 1)
{
ChangeMap("00_Buda.map", "PlayerStartArea_1", "14_elevator_activate.snt", "elevator_move_normal.snt");
}
}

My hpl.log...
Spoiler below!

------- SCRIPT OUTPUT BEGIN --------------------------
main (1, 1) : INFO : Compiling void OnStart()
main (3, 2) : ERR : No matching signatures to 'AddUseItemCallback(string@&, string@&, string@&, const bool)'
main (3, 2) : INFO : Candidates are:
main (3, 2) : INFO : void AddUseItemCallback(string&in, string&in, string&in, string&in, bool)
main (4, 2) : ERR : No matching signatures to 'AddUseItemCallback(string@&, string@&, string@&, const bool)'
main (4, 2) : INFO : Candidates are:
main (4, 2) : INFO : void AddUseItemCallback(string&in, string&in, string&in, string&in, bool)
------- SCRIPT OUTPUT END ----------------------------
FATAL ERROR: Could not load script file 'TheManMachine/maps/14_MechanicalLaboratory.hps'!
main (3, 2) : ERR : No matching signatures to 'AddUseItemCallback(string@&, string@&, string@&, const bool)'
main (4, 2) : ERR : No matching signatures to 'AddUseItemCallback(string@&, string@&, string@&, const bool)'




RE: Machine puzzle and other things - The chaser - 11-04-2012

Wait a sec:

How do you want it, activated by a collision (AddEntityCollideCallback) or using an item?


RE: Machine puzzle and other things - Adny - 11-04-2012

There are 4 string arguments in a UseItemCallback, not 3 (Name, Item, Entity, Function). The "No Matching Signatures" error means you have the wrong amount or type of arguments in your function/callback.


RE: Machine puzzle and other things - Steve - 11-04-2012

try this
Spoiler below!
void OnStart()
{
AddUseItemCallback("Usedsteam", "SteamRod", "MachineScript_1", "Elevator", true);
AddUseItemCallback("Usedflow" ,"FlowRod", "MachineScript_2", "Elevator_1", true);
}

void Elevator (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("SteamRod_static", true);
PreloadSound("rod_in.snt");
AddLocalVarInt("ElevatorWork", 1);
func_check();
}

void Elevator_1 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("FlowRod_static", true);
PreloadSound("rod_in.snt");
AddLocalVarInt("ElevatorWork", 1);
func_check();
}

void func_check()
{
if (GetLocalVarInt("ElevatorWork") == 2)
{
PreloadSound("13_flow_done.snt");
SetEntityConnectionStateChangeCallback("elevator_lever_1", "Map");
}
}

void Map (string &in asEntity, int alState)
{
if (alState == 1)
{
ChangeMap("00_Buda.map", "PlayerStartArea_1", "14_elevator_activate.snt", "elevator_move_normal.snt");
}
}



RE: Machine puzzle and other things - CorinthianMerchant - 11-06-2012

(11-04-2012, 08:18 PM)Robosprog Wrote:
(11-03-2012, 07:19 PM)CorinthianMerchant Wrote:
(11-03-2012, 02:26 PM)beecake Wrote: Changing to another map would be:
ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);
Immediatly loads another map.
asMapName - the file to load
asStartPos - the name of the StartPos on the next map
asStartSound - the sound that is played when the change starts
asEndSound - the sound that is played when the new map is loaded

You would have to play with variables to solve the other stuff
It doesn't work, I've tried SetEntityPlayerInteractCallback and SetEntityCallbackFunc.
void OnStart()
{
SetEntityPlayerInteractCallback("area", "changemap", false);

}

void changemap(string &in asEntity)

{
SetMessage ("Messages", "messageone", 3.00);

ChangeMap("NextMap", "PlayerStartArea_1", "sanity_flick.snt", "sanity_flick.snt");

}




That should work and would do the same as an examinearea, obviously adjust to whatever yours are. I don't know if that's what you did but..
Sadly enough, no luck. My hpl.log says the following:
------- SCRIPT OUTPUT BEGIN --------------------------
main (26, 9) : ERR : Expected identifier
------- SCRIPT OUTPUT END ----------------------------
FATAL ERROR: Could not load script file 'TheManMachine/maps/00_Buda.hps'!
main (26, 9) : ERR : Expected identifier


RE: Machine puzzle and other things - Steve - 11-07-2012

can you put your whole script here?


RE: Machine puzzle and other things - CorinthianMerchant - 11-08-2012

Code:
void OnStart()
{
SetEntityPlayerInteractCallback("TeleportArea", "changemap", false);
}

void changemap(string &in asEntity)

{
SetMessage ("Messages", "messageone", 3.00);
ChangeMap("Forest.map", "PlayerStartArea_1", "sanity_flick.snt", "sanity_flick.snt");
}
  void OnEnter()
{ }void OnLeave()
{ }



RE: Machine puzzle and other things - CorinthianMerchant - 11-11-2012

Bump.


RE: Machine puzzle and other things - Your Computer - 11-11-2012

(11-11-2012, 02:03 PM)CorinthianMerchant Wrote: Bump.

The code you provided has no (syntax) errors in it, nor does it contain at least 26 lines of code.