Jump to content

Clean-up script


Aki

Recommended Posts

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

  • Boxelware Team

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

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

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

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

  • 3 weeks later...

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

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

  • Boxelware Team

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

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

  • 3 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...