Script help - 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 help (/thread-20936.html) Pages:
1
2
|
RE: Script help - Rakez68 - 03-27-2013 Then you use AddUseItemCallback then. I know. But there came this problem what I said earlier: ''I have another problem now, something I can't understand. I pick up all four chemicals, and I try to put them into the pot (which is on the table). There does not come text ''Cannot use this item this way.'' But the SECOND time I try, there comes the text. The item does not disappear from my inventory, and no sound effect plays. After putting all four chemicals to the pot, nothing happens. It is supposed to play the event after all 4 chemicals have been put into the pot.'' But clearly there happens something when it doesn't give me ''Cannot use this item this way'' message when trying to put one of the chemicals into the pot. On second attempt however, it does give the message. Never encountered something like this before. This is the script once again: void OnStart() { SetLocalVarInt("Var1", 0); for(int i=1;i<=4;i++) AddUseItemCallback("Chemicals", "Chem"+i, "GetAcidComplete", "UsedChemsOnPot", true); } void UsedChemsOnPot(string &in asItem, string &in asEntity) { if("asParent" == "Chem1" && GetLocalVarInt("Var1") == 1) { AddLocalVarInt("Var1", 1); RemoveItem("Chem1"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if("asParent" == "Chem2" && GetLocalVarInt("Var1") == 1) { AddLocalVarInt("Var1", 1); RemoveItem("Chem2"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if("asParent" == "Chem3" && GetLocalVarInt("Var1") == 1) { AddLocalVarInt("Var1", 1); RemoveItem("Chem3"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if("asParent" == "Chem4" && GetLocalVarInt("Var1") == 1) { AddLocalVarInt("Var1", 1); RemoveItem("Chem4"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } if(GetLocalVarInt("Var1") == 4) { GiveSanityBoostSmall(); SetEntityActive("GetAcidComplete", false); SetEntityActive("chemical_container_full_1", true); PlayMusic("26_event_agrippa_head.ogg", false, 0.7, 0.1, 10, false); } } Also: All item names are correct. RE: Script help - Adrianis - 03-27-2013 Code: if("asParent" == "Chem1" && GetLocalVarInt("Var1") == 1) asParent doesn't exist in that function, and "Var1" will not be equal to 1 after 2 of the chemicals have been added, since 1 is being added to the value each time. Also, when using the name of a variable, you need to not have it surround by the quotation marks " ", those are only used for the value of a string variable. here... Code: void UsedChemsOnPot(string &in asItem, string &in asEntity) So the 'if' statement should be Code: if (asItem == "Chem1") RE: Script help - Rakez68 - 03-27-2013 Sigh, I can't figure this out. This is so complicated! I'm starting to feel embarrassed to bother you guys for so long. People must appreciate alot that you spend so much time with people that are bad at scripting like I am. Honestly, I have no idea what you meant in your latest post. I don't understand English very well, I'm finnish. EDIT: HOORAY IT WORKS! void OnStart() { SetLocalVarInt("Var1", 0); for(int i=1;i<=4;i++) AddUseItemCallback("Chemicals", "Chem"+i, "GetAcidComplete", "UsedChemsOnPot", true); } void UsedChemsOnPot(string &in asItem, string &in asEntity) { if (asItem == "Chem1") { AddLocalVarInt("Var1", 1); RemoveItem("Chem1"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if (asItem == "Chem2") { AddLocalVarInt("Var1", 1); RemoveItem("Chem2"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if (asItem == "Chem3") { AddLocalVarInt("Var1", 1); RemoveItem("Chem3"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } else if (asItem == "Chem4") { AddLocalVarInt("Var1", 1); RemoveItem("Chem4"); PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false); } if(GetLocalVarInt("Var1") == 4) { GiveSanityBoostSmall(); SetEntityActive("GetAcidComplete", false); SetEntityActive("chemical_container_full_1", true); PlayMusic("26_event_agrippa_head.ogg", false, 0.7, 0.1, 10, false); } } Thank you so much for helping me out guys! RE: Script help - Adrianis - 03-27-2013 No problem, I'll try to remember for next time to make it easier to understand for you - sorry about that. But don't worry too much about how long it takes, the record for a support thread is about 8 pages, over many days I think You might find it helpful to just spend some time going over tutorials for basic programming concepts, it may help to explain some stuff and help you avoid problems in the future. Also if you get more issues, don't forget to look at this thread, it's got some really useful info in it http://www.frictionalgames.com/forum/thread-19868.html |