View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:53 pm



Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
 "Conveyor zone" 
Author Message
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post "Conveyor zone"
Code:
if (actor.Pos.X >= self.Pos.X - 24) and (actor.Pos.X <= self.Pos.X + 24) and (actor.Pos.Y >= self.Pos.Y - 25) and (actor.Pos.Y <= self.Pos.Y + 25) and (actor.PinStrength <= 0) then


So basically this thing describes an area or a zone that's square-shaped, that's what I understood, but the problem is that I suck at offsets.
So I thought maybe some of you guys could help me out here, I got a 288x192 sprite, and I want the red area to be the zone/area.

Image
I really suck at this stuff.


Sat May 16, 2009 5:10 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: "Conveyor zone"
General rule of thumb:

Replace the X values(the first two) with half the width.
Replace the Y values(the last two) with half the length.
Much easyer than offsets.

Code:
if (actor.Pos.X >= self.Pos.X - 144) and (actor.Pos.X <= self.Pos.X + 144) and (actor.Pos.Y >= self.Pos.Y - 96) and (actor.Pos.Y <= self.Pos.Y + 96) and (actor.PinStrength <= 0) then


Sat May 16, 2009 6:21 pm
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
But then it's the whole Module, then it's not just the red zone.


Sat May 16, 2009 6:52 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: "Conveyor zone"
Oh.

My mistake.

Code:
if (actor.Pos.X >= self.Pos.X - 81) and (actor.Pos.X <= self.Pos.X + 81) and (actor.Pos.Y >= self.Pos.Y - 11) and (actor.Pos.Y <= self.Pos.Y + 11) and (actor.PinStrength <= 0) then


Just copy out the area in paint, change the px dim to 1,1 , paste and measure the new px dim.


Sat May 16, 2009 7:26 pm
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
You lost me at px dim?


Sat May 16, 2009 7:38 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: "Conveyor zone"
If Lua offsets are like every other programming language's offsets ever, you should define everything as if it's the fourth quadrant of a graph.

EG, the top right corner would be X+24, Y+0; then X+whatever, Y+0; etc

Not 100% sure, but that's how, say, C++ would do it, and how Area areas do it.


Sat May 16, 2009 8:06 pm
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
Uhh. Okay?

Another question,
Code:
for actor in MovableMan.Actors do


Is there any way to make it focus on green team only, and ignore team red?


Sat May 16, 2009 8:21 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: "Conveyor zone"
war_man333 wrote:
You lost me at px dim?


Go to attributes in paint.

Oh, and my calculations assume that the red area is an object centered around a point.


Sat May 16, 2009 8:26 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: "Conveyor zone"
war_man333 wrote:
Uhh. Okay?

Another question,
Code:
for actor in MovableMan.Actors do


Is there any way to make it focus on green team only, and ignore team red?


if actor.Team == 1 then

Add that after the for loop but before anything else.


Sat May 16, 2009 8:35 pm
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
I'm getting this

Property name was not followed by a value in xxx.rte/xxx.lua at line 1!
Code:
function Update(self)
   for actor in MovableMan.Actors do
   if actor.Team == 1 then
       if (actor.Pos.X >= self.Pos.X - 80) and (actor.Pos.X <= self.Pos.X + 80) and (actor.Pos.Y >= self.Pos.Y - 10) and (actor.Pos.Y <= self.Pos.Y + 10) and (actor.PinStrength <= 0) then
      actor.Health = 0;
       end
   end
end


Sun May 17, 2009 9:01 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: "Conveyor zone"
How in god's name are you getting an .ini error in a .lua file?

How are you loading it?

Are you using IncludeFile = whatever.lua?


Sun May 17, 2009 9:12 am
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
Uhmmm... no... :grin:
What do you do instead of IncludeFile?


Sun May 17, 2009 9:21 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: "Conveyor zone"
ScriptPath = modulename.rte/script.lua

In whatever object has the script attached.


Sun May 17, 2009 9:45 am
Profile
User avatar

Joined: Sun Nov 11, 2007 1:49 pm
Posts: 785
Reply with quote
Post Re: "Conveyor zone"
So you don't need to include it in the index file? Thanks!


Sun May 17, 2009 9:55 am
Profile

Joined: Tue May 29, 2007 6:21 pm
Posts: 5
Reply with quote
Post Re: "Conveyor zone"
You should also add the corresponding "end" for "if actor.Team == 1 then" ;)


Sun May 17, 2009 10:27 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page 1, 2  Next

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.112s | 13 Queries | GZIP : Off ]