Aki Posted May 16, 2016 Share Posted May 16, 2016 I'm in need and I have ran out of ideas. Maybe someone in here has an idea or even completed script. I need to clean up wreckages in a sector. Can't call Sector() in command or even serverstartup.lua. Most of Galaxy() function names I have tried do no work too. I was thinking of attaching script to a ship but I would need to modify existing one (Station Founder maybe?). But the part of guessing name of getWreckages() (I would laugh if it is the one) function will still be a problem. Another thing will be trying to run proper loop if wreckages function does not return proper array. Any ideas? Link to comment Share on other sites More sharing options...
Boxelware Team koonschi Posted May 16, 2016 Boxelware Team Share Posted May 16, 2016 You can call Sector():getEntitiesByType(EntityType.Wreckage), that should return all wreckage entities. You only have access to Sector() in a script that has a sector in its context, i.e. a sector, player or an entity script (since players and entities are in a sector). Link to comment Share on other sites More sharing options...
Aki Posted May 16, 2016 Author Share Posted May 16, 2016 Actually I almost did it after writing this post using some really weird logic and ideas but it seems to work. Anyway, thanks a lot. Your suggestion will help it making cleaner (haha, got it? Cleaner code for clean-up script 8)) for sure! Link to comment Share on other sites More sharing options...
Boxelware Team koonschi Posted May 16, 2016 Boxelware Team Share Posted May 16, 2016 It should also be way more performant since you don't have to touch all entities, especially not the hundreds/thousands of asteroids. Link to comment Share on other sites More sharing options...
Aki Posted May 16, 2016 Author Share Posted May 16, 2016 especially not the hundreds/thousands of asteroids thousands of asteroids ca. 1,200 asteroids in sector. I have just deleted over 4,000 wrecks from home sector 8). I wonder if I can do it more selective way, just to leave some newer wrecks in their place. Anyway, thanks again. (: Link to comment Share on other sites More sharing options...
StormWing0 Posted May 17, 2016 Share Posted May 17, 2016 lol why not have AI miners go out and clean up the messes as able? :-\ So no one has to wright a script for it. ;D Link to comment Share on other sites More sharing options...
Magnamura Posted May 17, 2016 Share Posted May 17, 2016 lol why not have AI miners go out and clean up the messes as able? :-\ So no one has to wright a script for it. ;D So the Devs should write an AI script so no one has to write a script? ;D # #scriptception OK fun aside. An AI miner script would also collect/destroy the loot from the wreckages. So you've survived a mayor pirate raid and you're now on your way to search the wrecks for loot. Wouldn't it be sad if an AI miner steals your loot then? ;) // Given your post in the Suggestions Forum (which I've read after posting here) your idea makes sense. <3 Link to comment Share on other sites More sharing options...
StormWing0 Posted May 17, 2016 Share Posted May 17, 2016 Not like you couldn't blow the cargo bays on the miner and steal it back. :P Link to comment Share on other sites More sharing options...
Aki Posted June 2, 2016 Author Share Posted June 2, 2016 I have wrote temporary script for Demo mp server to clean up mess: function getUpdateInterval() return 60 end function update(timeStep) local sector = Sector() if onServer() == 1 then local entities = {Sector():getEntitiesByType(EntityType.Wreckage)} if #entities > 120 then local number = math.min(#entities, 60) for i=1,number do Sector():deleteEntity(entities[i]) end end end end Enjoy. It is a sector script. Link to comment Share on other sites More sharing options...
gn_leugim Posted June 6, 2016 Share Posted June 6, 2016 would it be possible to change the script to only clean up very small wrecks, and leave the big ones? because those (small ones) are the one that get really annoying, like tips of antennas, or one cube wrecks. Also, I've been noticing that most wrecks do not have metal on it for harvest. once a ship is destroyed, only one of the fragments has metal, others don't. is this intended? Link to comment Share on other sites More sharing options...
Boxelware Team koonschi Posted June 6, 2016 Boxelware Team Share Posted June 6, 2016 No, that's a bug and it'll be fixed in the full version. Link to comment Share on other sites More sharing options...
gn_leugim Posted June 8, 2016 Share Posted June 8, 2016 nice to know. and regarding the script? is it possible? Link to comment Share on other sites More sharing options...
Boxelware Team koonschi Posted June 10, 2016 Boxelware Team Share Posted June 10, 2016 Yeah, you can read the number of blocks of a plan. I can't tell you how it works exactly off the top of my head, but something like this should be used in the repairdock script to determine whether a ship is damaged. Link to comment Share on other sites More sharing options...
Aki Posted June 10, 2016 Author Share Posted June 10, 2016 amount = #{plan:getBlockIndices()} Where plan is a plan. I think this will do. Or you could just go with getResourceValue or getMoneyValue to leave only wrecks that will actually give some profit to players. Link to comment Share on other sites More sharing options...
gn_leugim Posted June 13, 2016 Share Posted June 13, 2016 Or you could just go with getResourceValue or getMoneyValue to leave only wrecks that will actually give some profit to players. That! :D Link to comment Share on other sites More sharing options...
daemonreaver Posted September 27, 2019 Share Posted September 27, 2019 Not to troll an ancient thread, but is there any updates to the code, given all the API changes of late? I Admin for a MP server, and if this will run once and exit cleanly in a messy sector, I'd use it. Invoking entitydbg.lua every jump to clean things up bugs out every so often. 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