Halstrom Posted September 5, 2018 Share Posted September 5, 2018 I'm screwing something basic up in this script and can't work it out, something to do with AAF_MainQuestScript by the looks, I'm getting errors like this in the log: Quote [09/05/2018 - 11:09:52AM] error: Cannot call makeActorData() on a None object, aborting function call stack: [SAL_MainScriptQuest (12000842)].SAL:SAL_Main.ChangeStat() - "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\SAL\SAL_Main.psc" Line 109 [SAL_MainScriptQuest (12000842)].SAL:SAL_Main.OnTimer() - "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\SAL\SAL_Main.psc" Line 81 [09/05/2018 - 11:09:52AM] error: Cannot call sendEvent() on a None object, aborting function call stack: [SAL_MainScriptQuest (12000842)].SAL:SAL_Main.ChangeStat() - "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\SAL\SAL_Main.psc" Line 113 [SAL_MainScriptQuest (12000842)].SAL:SAL_Main.OnTimer() - "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\SAL\SAL_Main.psc" Line 81 SAL_Main.psc Link to comment
Tyrant99 Posted September 5, 2018 Share Posted September 5, 2018 Silly question, but are you using a valid actor in the ChangeStat function? You're returning none object for (targetActor). Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 42 minutes ago, Tyrant99 said: Silly question, but are you using a valid actor in the ChangeStat function? You're returning none object for (targetActor). Yes, rActor = Game.GetPlayer() And the second error line has no reference to actor, its the AAF_MainQuestScript I can't seem to get to work. I use this line in another script and it seems to work fine: AAF:AAF_API AAF_API = Game.GetFormFromFile(0x00000F99, sModName) as AAF:AAF_API Link to comment
Tyrant99 Posted September 5, 2018 Share Posted September 5, 2018 I see rActor = Game.GetPlayer() in fnInit(). But ChangeStat(Actor targetActor, String statID, Float statValue) targetActor does not have the actor property assigned like rActor does elsewhere in the script, so wherever you are calling ChangeStat() you would need the actor specified. Or change targetActor to rActor in your ChangeStat function. Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 18 minutes ago, Tyrant99 said: I see rActor = Game.GetPlayer() in fnInit(). But ChangeStat(Actor targetActor, String statID, Float statValue) targetActor does not have the actor property assigned like rActor does elsewhere in the script, so wherever you are calling ChangeStat() you would need the actor specified. Or change targetActor to rActor in your ChangeStat function. Yes but I am setting targetActor to rActor when I call the function with: ChangeStat(rActor, sStatID, fStatValue) unless I'm missing something obvious? Link to comment
Tyrant99 Posted September 5, 2018 Share Posted September 5, 2018 rActor is getting defined inside of a function, it would be better if that variable was defined outside of all functions. And also, since rActor is always pointing to Game.GetPlayer() and is being passed through as the targetActor in the ChangeStat function. Why not just do - Actor Property PlayerRef Auto - then swap out all your rActor and targetActor stuff to PlayerRef? Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 23 minutes ago, Tyrant99 said: rActor is getting defined inside of a function, it would be better if that variable was defined outside of all functions. And also, since rActor is always pointing to Game.GetPlayer() and is being passed through as the targetActor in the ChangeStat function. Why not just do - Actor Property PlayerRef Auto - then swap out all your rActor and targetActor stuff to PlayerRef? Hmm, but at the top I am doing: Actor rActor String sScriptName = "Main" Float fCurrVersionNum So although I am defining its value within the init function, it should retain its value throughout the script unless changed? I've done pretty much the same thing in many scripts and never got this error. I don't understand the script intercommunication.bit, I'm missing something to define it between. AAF:AAF_MainQuestScript property AAF_MainQuestScript Auto and sendData[0] = Utility.VarArrayToVar(AAF_MainQuestScript.makeActorData(targetActor)) I think I need something like this, but it doesn't compile: AAF:AAF_MainQuestScript AAF_MainQuestScript = Game.GetFormFromFile(0x00000F99, sModName) as AAF:AAF_MainQuestScript Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 AhAh! I think I just worked out I've been on the wrong track, I should be doing this because the ChangeStat function is already in the API: AAF_API.ChangeStat(rActor, sStatID, fStatValue) So I have this script now but it won't compile Scriptname SAL:SAL_Main extends Quest Group Misc Quest Property qMQ101 Auto EndGroup Group ReadValues ActorValue Property SAL_LustPerc Auto ActorValue Property SAL_ArousalPerc Auto ActorValue Property SAL_OrgasmPerc Auto ActorValue Property SAL_DominationPerc Auto EndGroup Group AAFHUDWrite ActorValue Property HUD_LustPerc Auto ActorValue Property HUD_ArousalPerc Auto ActorValue Property HUD_OrgasmPerc Auto ActorValue Property HUD_DominationPerc Auto EndGroup ;----------------------------------------------------------------------------------------------------------------------------- Actor rActor String sScriptName = "Main" Float fCurrVersionNum String sModName = "AAF.esm" Int iDebugSetting Int iCurrArousalPerc Int iPrevArousalPerc Int iCurrLustPerc Int iPrevLustPerc Int iCurrOrgasmPerc Int iPrevOrgasmPerc Int iCurrDominationPerc Int iPrevDominationPerc Int iTimerID = 1 Float fFrequencyTimer = 1.0 ;----------------------------------------------------------------------------------------------------------------------------- Event OnInit() Utility.Wait(1.0) If (Game.IsPluginInstalled(sModName)) fnInit() Else fnCleanup() EndIf EndEvent Function fnInit() fCurrVersionNum = 1800905.0 iDebugSetting = 1 rActor = Game.GetPlayer() fnDebug("SAL Version: " + fCurrVersionNum) AAF:AAF_API AAF_API = Game.GetFormFromFile(0x00000F99, "AAF.esm") as AAF:AAF_API If (!AAF_API ) Debug.Notification("AAF not detected.") fnCleanup() Else StartTimer(fFrequencyTimer, iTimerID) EndIf EndFunction ;----------------------------------------------------------------------------------------------------------------------------- Event OnTimer(Int aiTimerID) If (aiTimerID >= iTimerID) && (qMQ101.IsCompleted()) iCurrLustPerc = rActor.GetValue(SAL_LustPerc) as Int iCurrArousalPerc = rActor.GetValue(SAL_ArousalPerc) as Int iCurrOrgasmPerc = rActor.GetValue(SAL_OrgasmPerc) as Int iCurrDominationPerc = rActor.GetValue(SAL_DominationPerc) as Int Int iHUD_LustPerc = rActor.GetValue(HUD_LustPerc) as Int Int iHUD_ArousalPerc = rActor.GetValue(HUD_ArousalPerc) as Int Int iHUD_OrgasmPerc = rActor.GetValue(HUD_OrgasmPerc) as Int Int iHUD_DominationPerc = rActor.GetValue(HUD_DominationPerc) as Int If (iCurrLustPerc != iPrevLustPerc) && (iCurrLustPerc != iHUD_LustPerc) Float fStatValue = iCurrLustPerc as Float String sStatID = "LustPerc" AAF_API.ChangeStat(rActor, sStatID, fStatValue) fnDebug("Lust: Curr/Prev/HUD: " + iCurrLustPerc + "/" + iPrevLustPerc + "/" + iHUD_LustPerc) EndIf If (iCurrArousalPerc != iPrevArousalPerc) && (iCurrArousalPerc != iHUD_ArousalPerc) Float fStatValue = iCurrArousalPerc as Float String sStatID = "ArousalPerc" AAF_API.ChangeStat(rActor, sStatID, fStatValue) fnDebug("Arousal: Curr/Prev/HUD: " + iCurrArousalPerc + "/" + iPrevArousalPerc + "/" + iHUD_ArousalPerc) EndIf If (iCurrOrgasmPerc != iPrevOrgasmPerc) && (iCurrOrgasmPerc != iHUD_OrgasmPerc) Float fStatValue = iCurrOrgasmPerc as Float String sStatID = "OrgasmPerc" AAF_API.ChangeStat(rActor, sStatID, fStatValue) fnDebug("Orgasm: Curr/Prev/HUD: " + iCurrOrgasmPerc + "/" + iPrevOrgasmPerc + "/" + iHUD_OrgasmPerc) EndIf If (iCurrDominationPerc != iPrevDominationPerc) && (iCurrDominationPerc != iHUD_DominationPerc) Float fStatValue = iCurrDominationPerc as Float String sStatID = "DominationPerc" AAF_API.ChangeStat(rActor, sStatID, fStatValue) fnDebug("Domination: Curr/Prev/HUD: " + iCurrDominationPerc + "/" + iPrevDominationPerc + "/" + iHUD_DominationPerc) EndIf iPrevLustPerc = iCurrLustPerc iPrevArousalPerc = iCurrArousalPerc iPrevOrgasmPerc = iCurrOrgasmPerc iPrevDominationPerc = iCurrDominationPerc EndIf StartTimer(fFrequencyTimer, iTimerID) EndEvent ;----------------------------------------------------------------------------------------------------------------------------- Function fnDebug(String sDebug) If (iDebugSetting > 0) Debug.Trace("SAL: " + sScriptName + ": " + sDebug) EndIf EndFunction Function fnMessage(String sMessage) Debug.NotIfication(sMessage) If (iDebugSetting > 0) Debug.Trace(sMessage) EndIf EndFunction Function fnCleanup() UnregisterForAllEvents() CancelTimer(iTimerID) EndFunction The error is this: Quote Papyrus Compiler Version 2.8.0.4 for Fallout 4 Copyright (C) ZeniMax Media. All rights reserved. Starting 1 compile threads for 1 files... Compiling "SAL:SAL_Main"... C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(80,3): variable AAF_API is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(80,11): none is not a known user-defined script type C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(86,3): variable AAF_API is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(86,11): none is not a known user-defined script type C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(92,3): variable AAF_API is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(92,11): none is not a known user-defined script type C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(98,3): variable AAF_API is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SAL\SAL_Main.psc(98,11): none is not a known user-defined script type No output generated for SAL:SAL_Main, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on SAL:SAL_Main Link to comment
Tyrant99 Posted September 5, 2018 Share Posted September 5, 2018 If the targetActor is defined in the AAF_MainQuestScript and not in your local script, then you might try: AAF:AAF_MainQuestScript property AAF_MainQuestScript Auto and sendData[0] = Utility.VarArrayToVar(AAF_MainQuestScript.makeActorData(AAF_MainQuestScript.targetActor)) Usually you should only need to break out the Game.GetFormFromFile stuff if you are trying to hook into scripts from an external Mod without creating a dependency. Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 19 minutes ago, Tyrant99 said: If the targetActor is defined in the AAF_MainQuestScript and not in your local script, then you might try: AAF:AAF_MainQuestScript property AAF_MainQuestScript Auto and sendData[0] = Utility.VarArrayToVar(AAF_MainQuestScript.makeActorData(AAF_MainQuestScript.targetActor)) Usually you should only need to break out the Game.GetFormFromFile stuff if you are trying to hook into scripts from an external Mod without creating a dependency. Yes the API is in an external mod, hmm, but you've given me another angle on it to try tommorow, I need to sleep now, thank you for your help Link to comment
Guest Posted September 5, 2018 Share Posted September 5, 2018 Try to rename the variable AAF_API to something different. Not sure if just the different namespace is enough. Try something like: AAF:AAF_API AAFAPI = ... Link to comment
dagobaking Posted September 5, 2018 Share Posted September 5, 2018 1 hour ago, Halstrom said: So I have this script now but it won't compile You defined AAF:AAF_API AAF_API within a function. So, it can only be referenced from within that function. Variables are limited to being used within the "scope" that they are created in. If you create them in a function, they live only in the function and disappear when the function is over. If you create the variable at the top level like below example, then the variable remains available to all functions and its value becomes part of the save. Put it up with your other properties like this: AAF:AAF_API AAF_API Actor rActor String sScriptName = "Main" ... Then, in your init script, you populate it like: AAF_API = Game.GetFormFromFile(0x00000F99, "AAF.esm") as AAF:AAF_API And for the love of sanity, put code-blocks that large into spoilers! Link to comment
Halstrom Posted September 5, 2018 Author Share Posted September 5, 2018 7 hours ago, dagobaking said: You defined AAF:AAF_API AAF_API within a function. So, it can only be referenced from within that function. Variables are limited to being used within the "scope" that they are created in. If you create them in a function, they live only in the function and disappear when the function is over. If you create the variable at the top level like below example, then the variable remains available to all functions and its value becomes part of the save. Put it up with your other properties like this: AAF:AAF_API AAF_API Actor rActor String sScriptName = "Main" ... Then, in your init script, you populate it like: AAF_API = Game.GetFormFromFile(0x00000F99, "AAF.esm") as AAF:AAF_API And for the love of sanity, put code-blocks that large into spoilers! Oh.... so stupidly simple...it now works!!!! Thank you My sanity was highly questionable by 2am last night Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.