Author |
Message |
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
"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. I really suck at this stuff.
|
Sat May 16, 2009 5:10 pm |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
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 |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
Re: "Conveyor zone"
You lost me at px dim?
|
Sat May 16, 2009 7:38 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
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 |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
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 |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
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 |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
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 |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
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 |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
Re: "Conveyor zone"
Uhmmm... no... What do you do instead of IncludeFile?
|
Sun May 17, 2009 9:21 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: "Conveyor zone"
ScriptPath = modulename.rte/script.lua
In whatever object has the script attached.
|
Sun May 17, 2009 9:45 am |
|
|
war_man333
Joined: Sun Nov 11, 2007 1:49 pm Posts: 785
|
Re: "Conveyor zone"
So you don't need to include it in the index file? Thanks!
|
Sun May 17, 2009 9:55 am |
|
|
geforz
Joined: Tue May 29, 2007 6:21 pm Posts: 5
|
Re: "Conveyor zone"
You should also add the corresponding "end" for "if actor.Team == 1 then"
|
Sun May 17, 2009 10:27 am |
|
|
|