hexef Posted August 16, 2015 Share Posted August 16, 2015 I cannot set a ref variable from a quest script inside a function script. Here is how the script function looks like scn scriptfunction ref MainNPCref MainNPCSpawned Begin Function { MainNPC , MainNPCSpawned } <Some code> if QuestName.MyRef == 0 ; if the quest ref variable doesn't hold any reference<Some code>set QuestName.MyRef to MainNPC endif <Some code> END Problem is that the MyRef variable from the quest doesn't take the value of MainNPC ref. Any suggestions? Link to comment Share on other sites More sharing options...
hexef Posted August 16, 2015 Author Share Posted August 16, 2015 Nvm,I figured out the problem.It was not the functions fault,it was the call to the function. The call looked like this:call scriptfunction GetSelf,SpawnedNPCsLooks like the MainNPC parameter always took the value of 0 instead of GetSelf Ref ID This is the fix:set SelfRef to GetSelfcall scriptfunction SelfRef,SpawnedNPCs Link to comment Share on other sites More sharing options...
Gribbleshnibit8 Posted August 18, 2015 Share Posted August 18, 2015 You should be able to use the original call by using Script Compiler Override. By placing an underscore under the block type name (_Function, _Gamemode, etc) you enable override mode. Override lets you use functions inside of functions. The tradeoff is that the compiler will no longer check to make sure that return types are valid, it puts all that work on you. You can read a little more about Script Compiler Override here. I'm pretty sure there's a page on the GECK wiki that covers it too, but as that's been down for over 12 hours now, I can't link to it. Link to comment Share on other sites More sharing options...
Recommended Posts