View unanswered posts | View active topics It is currently Sat Oct 19, 2019 12:59 am

 Page 2 of 2 [ 22 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Control over MOPixels
Author Message
happy carebear mom

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7094
Location: b8bbd5
Re: Control over MOPixels
I remember from my own modding attempts that after a certain size, MO hitboxes cut off and just become boxes no matter the shape of the sprite, so you might need to split your MO into several different ones.
Could be entirely an different issue though.

Sat May 31, 2014 3:19 am

Joined: Mon May 26, 2014 4:10 pm
Posts: 9
Re: Control over MOPixels
Well, i have decided to use MOSRotating's erase from terrain (it's strange only MOSRotating has such function, but i have no choice - using MOPixels causes tons of lags because of loose terrain it leave (i can't remove them instantly. The wiki doesn't have any information about controlling over particles except RemoveParticle and GetParticleCount).

Unfortunately, i must somehow make:
Quote:
Moreover, i can evade spawning tons of MOPixels every tick, but that's kinda complicated. Instead of deleting and spawning new MOPixels, i can just _add_ new MOPixels to circle
In this case formula starts to be even worse: r>0; count = round(6.28*r) - round(6.28*(r-1)). And put these new particles in their place and accelerate them in same manner.
So, even for radius 1000 i have to spawn upto:
6280 - 6273 = SEVEN particles.
7 particles a tick is really fast spawning, but tricky. It's also easy to find that i have to spawn 6-7 pixels a tick no matter of radius. So...

At this moment i try to figure out how to use associated arrays for that.

Code:
function Create(self)
self.associated = {} --Associated array.
end

function Update(self)
local cr_am = math.floor(6.28*self.radius)
local cr_am_old = math.floor (6.28*(self.radius-1))
local ang_dif = 360 / cr_am
local ang_dif_old = 360 / cr_am_old
for i = 1, cr_am do
local old_pos = {math.floor(self.Pos.X + math.cos(i*ang_dif_old) * (self.radius-1)), math.floor(self.Pos.Y + math.sin(i*ang_dif_old) * (self.radius-1))}
local new_pos = Vector (math.floor(self.Pos.X + math.cos(i*ang_dif) * self.radius), math.floor(self.Pos.Y + math.sin(i*ang_dif) * self.radius))
local new_pos_id = { math.floor(self.Pos.X + math.cos(i*ang_dif) * self.radius), math.floor(self.Pos.Y + math.sin(i*ang_dif) * self.radius) }
if self.associated[old_pos] ~= nil then
self.associated[new_pos_id] = self.associated[old_pos]
self.associated[old_pos] = nil
else
local S = CreateMOSRotating("Cleaner")
self.associated[new_pos_id] = S
end
self.associated[new_pos_id].Pos = new_pos
self.associated[new_pos_id]:EraseFromTerrain()
end

self.ToDelete = true
else
end
end

function Destroy(self)
--for k, v in pairs(self.associated) do
--   MovableMan:RemoveParticle(v)
--end
end

Code:
if self.associated[old_pos] ~= nil then
self.associated[new_pos_id] = self.associated[old_pos]
self.associated[old_pos] = nil

This part doesn't work at all. Any ideas?

Sat May 31, 2014 10:37 am

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Re: Control over MOPixels
For control over particles you'll want to use this table:

Code:
for Particle in MovableMan.Particles do
Particle.ToDelete = true
end

Also, a general question, what exactly is the benefit of using EraseFromTerrain() over just using a circle MOSR with for instance, ini code set like this:

Code:
AtomGroup = AtomGroup
AutoGenerate = 1
Material = Material
CopyOf = Concrete
Resolution = 2
Depth = 0
DeepGroup = AtomGroup
AutoGenerate = 1
Material = Material
CopyOf = Concrete
Resolution = 3
Depth = 0
DeepCheck = 1

That will produce exactly the same effect as erasing it from the terrain, so what's the benefit for using the lua method? Speed or effieciency or something?

Sat May 31, 2014 4:31 pm

Joined: Mon May 26, 2014 4:10 pm
Posts: 9
Re: Control over MOPixels
Quote:
Also, a general question, what exactly is the benefit of using EraseFromTerrain() over just using a circle MOSR with for instance, ini code set like this:

Two quotes for answer:
Quote:
Using EraseFromTerrain works, but two problems:
1. Scaling MOSRotating is REALLY lagging.
2. It deletes square, not circle.

Quote:
I remember from my own modding attempts that after a certain size, MO hitboxes cut off and just become boxes no matter the shape of the sprite, so you might need to split your MO into several different ones.

Quote:
for Particle in MovableMan.Particles do
Particle.ToDelete = true
end

Damn.

Sun Jun 01, 2014 1:29 am
Data Realms Elite

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Re: Control over MOPixels
Quote:
That will produce exactly the same effect as erasing it from the terrain, so what's the benefit for using the lua method? Speed or effieciency or something?

As far as anything consistency/efficacy, MO-Terrain Collisions are one of the more chaotic/random thing you can do.

Sun Jun 01, 2014 1:31 am

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11831
Location: Here
Re: Control over MOPixels
MO scaling is extremely fast compared to throwing a bajillion particles around.

EraseFromTerrain has a limit where it can only clear terrain within a 128 x and y range of the SpriteOffset.

To get around the size limit, use more MOs/move the same one around different positions.

Sun Jun 01, 2014 2:14 am

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Re: Control over MOPixels
Foa wrote:
Quote:
That will produce exactly the same effect as erasing it from the terrain, so what's the benefit for using the lua method? Speed or effieciency or something?

As far as anything consistency/efficacy, MO-Terrain Collisions are one of the more chaotic/random thing you can do.

Nah, collision isn't a problem. You just run a script that delete the object in the create function.

Here are 2 perfect tunnels created by spawning MOSRotatings (with deepcheck = 1 and an instant delete script) using the 96x96 square concrete fill sprite:

Here is the result using a 200 pixel radius circle:

This method also doesn't seem to be that laggy, because it only knocks lose a handful of terrain particles (kinda hard to see because of the buy menu shadow thingy):

EditorRUS wrote:
Two quotes for answer:
Quote:
Using EraseFromTerrain works, but two problems:
1. Scaling MOSRotating is REALLY lagging.
2. It deletes square, not circle.

Quote:
I remember from my own modding attempts that after a certain size, MO hitboxes cut off and just become boxes no matter the shape of the sprite, so you might need to split your MO into several different ones.

1: So don't scale the MOSRotating.
2: Because the sprite is too big. 200 pixel radius works, 400 pixel radius doesn't. The maximum should be easy enough to figure out with some more experimentation. If the maximum is too small you'll need to cut the sprite up into smaller ones. Spawning 4 quarter circle sprites isn't really that much more complicated than spawning 1 big full circle sprite...

Edit: Of course, this is all pretty moot, considering what CaveCricket posted just before me...

Sun Jun 01, 2014 2:16 am
Display posts from previous:  Sort by
 Page 2 of 2 [ 22 posts ] Go to page Previous  1, 2

#### Who is online

Users browsing this forum: No registered users

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Cortex Command    Dev Log    Wiki    Game Discussion    Game and Licensing Support    Mod Making       Lua Scripting       Requests    Mod Releases       Older Mods    Scene Releases       Scene Making Planetoid Pioneers    Game Discussion    Pioneer Program Lounge Data Realms Off-Topic    Off Topic Chat       Gaming       Forum Games    Site Support & Feedback
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.020s | 13 Queries | GZIP : Off ]