Data Realms Fan Forums
http://forums.datarealms.com/

Control over MOPixels
http://forums.datarealms.com/viewtopic.php?f=73&t=45719
Page 2 of 2

Author:  Duh102 [ Sat May 31, 2014 3:19 am ]
Post subject:  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.

Author:  EditorRUS [ Sat May 31, 2014 10:37 am ]
Post subject:  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.radius = 1
   self.maxradius = 50
   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
         MovableMan:AddParticle(S)
      end
      self.associated[new_pos_id].Pos = new_pos
      self.associated[new_pos_id]:EraseFromTerrain()
   end
         
   if self.radius >= self.maxradius then
      self.ToDelete = true
   else
      self.radius = self.radius + 1
   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?

Author:  clunatic [ Sat May 31, 2014 4:31 pm ]
Post subject:  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?

Author:  EditorRUS [ Sun Jun 01, 2014 1:29 am ]
Post subject:  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.

Author:  Foa [ Sun Jun 01, 2014 1:31 am ]
Post subject:  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.

Author:  CaveCricket48 [ Sun Jun 01, 2014 2:14 am ]
Post subject:  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.

Image

Image

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

Image

Author:  clunatic [ Sun Jun 01, 2014 2:16 am ]
Post subject:  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...

Page 2 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/