Treexter Posted December 6, 2017 Share Posted December 6, 2017 Hi, I'm trying to experiment with turrets systems. But every attempt to get player craft leads to this Spent couple of hours playing with the code with no luck. The current code is (Avorion\data\scripts\systems\militarytcs.lua): function getNumTurrets(seed, rarity) local numTurrets = math.max(1, rarity.value + 1) local player = Player().craft return numTurrets end What's the problem? Is this a bug? How to obtain player craft properly here? Link to comment Share on other sites More sharing options...
Dirtyredz Posted December 6, 2017 Share Posted December 6, 2017 system (modules) are attached to the entity not the player, so you want to use: local craft = Entity() there are a few places inside an entity where you can call Player() particularly on client side functions like onPreRender and onInstalled to name a few In which case if you want the players craft you need to do this local craftIndex = Player().craftIndex local ship = Entity() local player = Player() if not player.craftIndex == ship.index then return end Link to comment Share on other sites More sharing options...
Treexter Posted December 6, 2017 Author Share Posted December 6, 2017 Thanks! I get it. The final correct code without errors looks like this This is the starting point for my further experiments. function getNumTurrets(seed, rarity) local numTurrets = math.max(1, rarity.value + 1) local ship = Entity() if ship == nil then return numTurrets end <... some stuff here with ship properties ...> return numTurrets end Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now