player:HasPerk doesn't work in quests?

Machiavelli24

Mod creator
Joined
May 9, 2012
Messages
818
Update:

I worked around the issue by using LuaEvents to pass the input & outputs. The outputs were added by side effect in normal lua code that listened for the event.
--------------------
There are some lua functions that work fine when I use them as part of normal lua files but don't work when I use them as part of quests. For example, player:HasPerk doesn't seem to work. Add and remove perks work, but not evaluating.

There also doesn't seem to be a way to tell what cargo loadouts a player has within a quest. PreGame (for PreGame.GetLoadoutCargo(playerID)) doesn't work. There is a Game.GetLoadoutSpacecraft(playerID) but no similar method for Cargo.

Is there any known way to work around these limitations?
 
Are you sure checking for perks doesn't work? Wouldn't know of any reason why a quest script wouldn't be able to use a global function, and I don't think I ever ran into such limitations when playing around with custom quests.

But if there's indeed a limitation that I'm not aware of you can always workaround by using persistent data, those can be shared around different lua scripts. So you can just index and keep it updated in one script and then load that global variable by the quest script.
 
Top Bottom