Jump to content

Can't set a quest ref variable in a function script


hexef

Recommended Posts

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 MainNPC

ref 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

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,SpawnedNPCs

Looks like the MainNPC parameter always took the value of 0 instead of GetSelf Ref ID

 

This is the fix:

set SelfRef to GetSelf

call scriptfunction SelfRef,SpawnedNPCs

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...