Assuming exp2 now entirely resembles lua;
findResult(findInSphere(self:pos(),1000))
will give you the entity.
Can someone PLEASE show me some WORKING code of this?
Everything i try doesn't seem to work?
For example this should just target the closest entity to me?Code:@name FINDY @outputs E:entity GPS:vector Owner:entity O_GPS:vector @persist interval(1000) Name="chiss" if(Owner:name() == Name) { findExcludePlayer(Owner) findInSphere(Owner:pos(),1000) E = findResult(findInSphere(Owner:pos(),1000)) GPS = E:pos() O_GPS = Owner:pos() } else { Owner=findPlayerByName(Name) }
(Most of this is someone elses code - no credit to me)
I can easily get them to track me, or some specific other player. But i can't get it working as a target finder at all.
I get timer errors all the time too :\ why?
Last edited by chiss; 12-23-2008 at 09:04 PM.
Assuming exp2 now entirely resembles lua;
findResult(findInSphere(self:pos(),1000))
will give you the entity.
That is nearly correct usage right there (findResult() isn't supposed to take findInSphere() as an argument, just a number between 1 and whatever findInSphere() returns.). It's just that one or other update broke findInSphere()/findInBox() (and maybe findInCone() too, I haven't checked). Not much to do but revert to the original find.lua or wait until Gwahir's not so busy, I suppose.
Last edited by Magos Mechanicus; 12-24-2008 at 02:24 AM.
I can wire anything directly into anything! I'm the Professor!
-Professor Hubert Farnsworth
findInSphere returns the entity ID, which findresult uses to select an entity, so used together like that will return the entity.
Gwahir's given findInSphere() and such a different interface in E2, so it's not quite like the lua one. Instead, it saves a table from which you can pull results with findResult(Index).
I can wire anything directly into anything! I'm the Professor!
-Professor Hubert Farnsworth
Ok this may not be what you are looking for, but it might help. Ill give you an example of a working target finder.
@ Name Test
@ Inputs
@ Outputs X Y Z
@ Persists Position:vector Target:entity ** You must define the variable as an entity **
interval (10) ** You need interval otherwise the position will not update, it set for 10milliseconds **
findByClass ("Players") ** This could be Props, Npcs, Players, etc. **
Target = findresult(#) **Replace 3, if there were 3 players, you would either be 1 2 or 3 **
Position = Target: pos() ** Please ignore the space from t: pos, I am trying to avoid***
X = Position:x()
Y = Position:y()
Z = Position:z()
Last edited by SpectreCat; 01-03-2009 at 10:25 PM.
My conclusion is that a lot of the FIND functions are broken.
If your above code works it would seem findByClass and findPlayerByName and maybe a few others work.
I havent heard of anyone getting findInSphere working.
Chiss, remember how you said to me that when I tried to make something you thought could not be done that I have good aspiration?
Looks like it paid of after a few HOURS:
Finished just then... its still fresh.. not perfect thoCode:@name TargetFinder @inputs GPS:vector @outputs TargetName:string TargetModel:string X Y Z @persist Gpsx Gpsy Gpsz Pos:vector TheEnt:entity Find VecPos:vector interval(10) #Init GPU Gpsx = GPS:x() Gpsy = GPS:y() GpsZ = GPS:z() #Set the Vector VecPos = vec(Gpsx, Gpsy, Gpsz) #Find the Target within 1000units of the GPS Find = (findInSphere(VecPos,1000)) #Return TheEnt = findResult(1) #Output Pos = TheEnt:pos() X = Pos:x() Y = Pos:y() Z = Pos:z() TargetName = TheEnt:name() TargetModel = TheEnt:model()(welll..?)
Code:@name TargetFinder @inputs GPS:vector @outputs @persist TheEnt:entity Find #Most Basic form, Add outputs freely #Kudos to Chiss for the GPS tip =] interval(10) Find = (findInSphere(GPS,1000)) TheEnt = findResult(1)
Last edited by chizley; 01-09-2009 at 07:37 AM.
Bookmarks