[SCRIPT] SetLanternLitCallback - 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] SetLanternLitCallback (/thread-22185.html) Pages:
1
2
|
SetLanternLitCallback - hunchbackproduction - 07-19-2013 void SetLanternLitCallback(string& asCallback); Sets the function to call when the player uses his lantern. Callback syntax: MyFunc(bool abLit) I am using this code in my custom story, however it seems to be doing nothing and I'd like to think I didn't make an error in code. Any help would be appreciated!!! <3 void LanternTinderCheck(string& asCallback) { if (GetGlobalVarInt("Tinderboxes") == 0) { SetMessage("Chemical", "notinderboxes", 1); SetLanternActive(false, true); SetLanternDisabled(true); AddTimer("", 1, "ReAllowLighting"); } if (GetGlobalVarInt("Tinderboxes") > 0) { AddGlobalVarInt("Tinderboxes", -1); SetMessage("Chemical", "lanternlit", 1); SetLanternLitCallback("LanternTinderCheck"); } } void ReAllowLighting(string &in asTimer) { SetLanternDisabled(false); SetLanternLitCallback("LanternTinderCheck"); } void OnStart() { SetLanternLitCallback("LanternTinderCheck"); SetGlobalVarInt("Tinderboxes", 0); } void OnEnter() { AddEntityCollideCallback("Player", "ScriptArea_1", "ArthurCheck", true, 1); PlayMusic("RopeFootstep.ogg", true, 1, 1, 1, false); } void OnLeave() { SetupLoadScreen("LoadingText", "Loading", 7, "HNBKChapterOne.jpg"); } RE: SetLanternLitCallback - Your Computer - 07-19-2013 Lantern callback requires a boolean parameter. RE: SetLanternLitCallback - hunchbackproduction - 07-20-2013 (07-19-2013, 09:20 PM)Your Computer Wrote: Lantern callback requires a boolean parameter. Alrighty, so how would I implement that ? RE: SetLanternLitCallback - Tomato Cat - 07-20-2013 The SetLanternLitCallback is what sets your callback, it isn't called when you light your lantern. For example: PHP Code: void onStart { RE: SetLanternLitCallback - hunchbackproduction - 07-20-2013 (07-20-2013, 01:02 PM)Tomato Cat Wrote: The SetLanternLitCallback is what sets your callback, it isn't called when you light your lantern. Aaaaaaaaaaaaaaaaaaaaaaaah, I see now. void LitCallback(bool abLit /*Your boolean parameter*/) With that line of code would I do something like: void LitCallback(true) ? RE: SetLanternLitCallback - Tomato Cat - 07-20-2013 No, it's a parameter. It specifies that the function takes a boolean value, which is passed by the callback. (I'm assuming true for lit, false for unlit.) =p RE: SetLanternLitCallback - hunchbackproduction - 07-29-2013 (07-20-2013, 02:58 PM)Tomato Cat Wrote: No, it's a parameter. It specifies that the function takes a boolean value, which is passed by the callback. (I'm assuming true for lit, false for unlit.) =p Alright, just came back from holidays and ready to code I ain't no pro haxor, so could you please explain to me wtf is a parameter and actually give me a example of the SetLanternLitCallback being used please xD. Sorry for the hassle and thanks for the help so far dudes! RE: SetLanternLitCallback - Tomato Cat - 07-29-2013 (07-29-2013, 04:24 PM)hunchbackproduction Wrote: Alright, just came back from holidays and ready to code Welcome back! A parameter is a value passed to a function. In the most basic sense. PHP Code: //For example In this snippet, "i" and "k" represent integers. Their values are "passed" (think, "sent to") the function addNumber. Say you wanted to use the function somewhere. You would write: PHP Code: addNumber(3, 1); In this case, the parameter "i" represents the integer value of 3. Whereas "k" represents 1. Now, for the lantern callback, it's pretty much the same. Only what's passed is a "boolean" (true/false) type. PHP Code: public void test(bool lanternLit) Only in this case, the parameter is passed internally. RE: SetLanternLitCallback - hunchbackproduction - 07-30-2013 (07-29-2013, 07:37 PM)Tomato Cat Wrote:(07-29-2013, 04:24 PM)hunchbackproduction Wrote: Alright, just came back from holidays and ready to code Alrighty, making more sense now ^^ Your really good at this I'll try this stuff out, then come back if I need some more clarification! RE: SetLanternLitCallback - hunchbackproduction - 08-03-2013 Ok! tried to get this to work, I thought I understood this, But boy was I wrong xD I need a little more clarification on how this whole thing works. When you explained the I and K parameter thing I got it, But why is I and K needed ? Can't you just code: "addnumber(3,1)" ? Also what is up with "public" I saw you put that there before your voids I still do not get the whole lanternlit, and how it links to parameters ? Are the parameters "true" or "false" and do I have to define these somewhere ? void LanternLit(bool lanternLit) { if(lanternLit) { SetMessage("test", "test", 1); } else { } } I have this piece of test code, please explain to me why it does not work! As when I light my lantern the test message does not appear. PS: I have given you a reputation for the help so far ^ Thanks! |