View unanswered posts | View active topics It is currently Fri Mar 29, 2024 12:01 am



Reply to topic  [ 4 posts ] 
 In need of a simple script 
Author Message
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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?


Mon Jul 09, 2012 9:16 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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.


Mon Jul 09, 2012 9:32 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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.


Mon Jul 09, 2012 9:35 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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.


Mon Jul 09, 2012 9:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.232s | 15 Queries | GZIP : Off ]