oreganor Posted February 23, 2017 Share Posted February 23, 2017 I'm trying to tune some salvaging scripts for personal use and I want my salvaging ships to ignore wreckage chunks that are still moving... ...Is there in the API a property/method/function to check the "immobile status" of an Entity (The small difference in the UI when an entity has a speed entry on its tooltip compared to one totally immobile that lacks it)? So far I have found 2 interesting ones on the Entity Object, but both have problems: property var isTurning [read-only] I don't have a clear idea on the format and seems to fail on wreckages. property float desiredVelocity Has all the problems associated to 0 comparisons with floating point variables :(. Link to comment Share on other sites More sharing options...
Polyman Posted February 23, 2017 Share Posted February 23, 2017 You can access variables attached to gameObjects in most game engines by doing something like gameObject.var, so try local velocity = gameObject.velocity or local velocity = gameObject.speed. I'm not very familiar with LUA scripting so it might not be correct. Link to comment Share on other sites More sharing options...
oreganor Posted February 23, 2017 Author Share Posted February 23, 2017 Thanks for the points. After inspecting more and more scripts I found some interesting bits into the docking scripts the AI uses... ...The API follows a component approach to hierarchy, instead of the standard objective parent/child trees. ATM I'm playing with "Velocity" component and referencing each wreckage by its index... But TBH I'm mostly just randomly changing things until they explode :) (The hackish way :) ). So far the code runs and my Salvagers seems to ignore SOME of the fast moving wreckages until they slow down... But there are strange things and I'm suspecting that I'm not understanding well the index used to reference different "components" attached to the same entity... So most likely SOMETIMES it works but the speed I'm looking at may be of some other moving object in the sector. Link to comment Share on other sites More sharing options...
oreganor Posted February 25, 2017 Author Share Posted February 25, 2017 I found a way that more or less works so I post it here as a code example for ppl interested: -- We check if a wreckage is moving too fast to pursue it -- We use squared distances and functions to reduce computational needs function isslowwreck(wreck) local v = Velocity(wreck.index) if not valid(v) then return true elseif length2(v.velocityf) < 5 * 5 then return true end return false 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