Rinart73 Posted September 27, 2018 Share Posted September 27, 2018 I need to know which ship fired the shot. So, I register a callback: function MyMod.initialize() Sector():registerCallback("onStartFiring", "onSomeoneFired") end function MyMod.onSomeoneFired(turretId) local turret = Entity(turretId) end And now what? There is no way to get "parent entity" of other entity. Link to comment Share on other sites More sharing options...
Laserzwei Posted September 27, 2018 Share Posted September 27, 2018 I'm also interested. There is a "ParentEntity"- Component (Enums -> ComponentType -> ParentEntity), but it's not surfaced to the LUA API. There is also the possibility of going through the ships of the same faction and search for that specific turret: function MyMod.onSomeoneFired(turretId) local turret = Entity(turretId) local parent local possibleParents = {getEntitiesByFaction(turret.factionIndex)} for _,p in pairs(possibleParents) do if (p.isShip or p.isStation) then local pTurrets = {p:getTurrets()} for _,t in pairs(pTurrets) do if t.index.number == turret.index.number then parent = p end end end if parent then print("parent found", parent.name) else print("no parent found, weird!") end end I didn't try the code but it should work ;D Link to comment Share on other sites More sharing options...
Rinart73 Posted September 27, 2018 Author Share Posted September 27, 2018 Thanks, your code worked ;) I wish one day we will have access to all components.. 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