Data Realms Fan Forums
http://45.55.195.193/

In need of a simple script
http://45.55.195.193/viewtopic.php?f=73&t=31422
Page 1 of 1

Author:  4zK [ Mon Jul 09, 2012 9:16 pm ]
Post subject:  In need of a simple script

I'm learning the ropes on lua, but I'm putting this here since I have zero experience with rays.

I'm looking for a simple script that scans for actors within a certain distance from an object (self), without any obstructing terrain. I'm guessing this has something to do with MORays and ObstacleRays?

Author:  Roast Veg [ Mon Jul 09, 2012 9:32 pm ]
Post subject:  Re: In need of a simple script

Really a ray isn't going to do you any good here, since it can cause lag in large quantities and only looks on one direction. What you want is this short snippet here:

Code:
function Create(self)
    self.minDistance = 10 --distance in pixels from the centre of the actor
end

function Update(self)
    for actor MovableMan.Actors do
    local actorDist = sqrt(actor.Pos.X^2+actor.Pos.Y^2)
    if actorDist <= self.minDistance then
        actor:GibThis() --Alter this to do whatever it is that you want.
    end
end


There are simplifications of the seventh line there, but since I don't remember the functions this will suffice.

Author:  4zK [ Mon Jul 09, 2012 9:35 pm ]
Post subject:  Re: In need of a simple script

I'm able of doing that myself, I just wanted for the object to not affect actors if they're obstructed by terrain.

Author:  Roast Veg [ Mon Jul 09, 2012 9:47 pm ]
Post subject:  Re: In need of a simple script

Ah ok, try:
Code:
function Create(self)
    self.minDistance = 10 --distance in pixels from the centre of the actor
end

function Update(self)
    for actor MovableMan.Actors do
    local actorDist = sqrt(actor.Pos.X^2+actor.Pos.Y^2)
    if actorDist <= self.minDistance then
        if SceneMan:CastFindMORay(self.Pos, actor.Pos, actor.RootID, Vector(), 0, false, 1) == true then
            actor:GibThis()
        end
    end
end

That new line is all sorts of untested, so it might well not work without tweaking.

EDIT: Just corrected this, try again if it wasn't working before.

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