Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

How to tell if an Object is a background object ?

Give us your input on how we may improve the ScriptAPI in the game in future versions.
Forum rules
By using the forum you agree to the following rules.
Post Reply
nerdist
Fighter
Fighter
Posts: 22
Joined: Sat Aug 20, 2016 8:09 pm

How to tell if an Object is a background object ?

Post by nerdist » Thu Aug 25, 2016 3:03 pm

I am working on a script and I really need a fast way to tell if an object can collide with other object.
this method Game.GetObjectsByArea() returns all kinds of unnecessary tiles even far-background object.

I could make a string list of all the 809 Bg Tiles and 101 FarBG tiles but it's gonna take a lot of time..

hint : It is possible to get the name of IObject as a string . If it is a Background object it will begin with the prefix "Bg" , such as :"BgLamp00A" . Getting the initials of a string might be the key to the problem.

big thanks in advance !
0 x

User avatar
gwendalaze
Superfighter
Superfighter
Posts: 84
Joined: Sat Mar 19, 2016 12:55 pm
Title: Jarate Yellow Belt
Started SFD: PreAlpha 1.1.4
Location: France

Post by gwendalaze » Fri Aug 26, 2016 2:16 am

area triggers don't detect background and far background tiles
that may help you
0 x
- Gwendalaze, failing at being fun, just like this signature

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Fri Aug 26, 2016 7:22 am

nerdist wrote:I am working on a script and I really need a fast way to tell if an object can collide with other object.
this method Game.GetObjectsByArea() returns all kinds of unnecessary tiles even far-background object.

I could make a string list of all the 809 Bg Tiles and 101 FarBG tiles but it's gonna take a lot of time..

hint : It is possible to get the name of IObject as a string . If it is a Background object it will begin with the prefix "Bg" , such as :"BgLamp00A" . Getting the initials of a string might be the key to the problem.

big thanks in advance !
As Gwen says, the area triggers are ok, but I think that they dont recognize static tiles. You could maybe use something like this:

Code: Select all

		Area SomeArea=new Area(0,0,0,0);
		public void Check(TriggerArgs args){
			IObject[] objs = Game.GetObjectsByArea (SomeArea);
			List <IObject> TheObjects = new List<IObject> ();
			foreach(IObject obj in objs)
				if (!obj.Name.StartsWith ("Bg") && !obj.Name.StartsWith ("FarBg"))
					TheObjects.Add (obj);
				//Do something with the tiles
				TheObjects.Clear();
		}
I'm sure that you understand how this works, and that it is not very efficient. But works ok. ;)
1 x
Image

nerdist
Fighter
Fighter
Posts: 22
Joined: Sat Aug 20, 2016 8:09 pm

Post by nerdist » Fri Aug 26, 2016 6:42 pm

Thanks man ! I really needed this :)
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Fri Aug 26, 2016 8:05 pm

For info:
"How to tell if an Object is a background object ?" We lack that feature in the ScriptAPI today. Meta data like this will most likely be available in later versions of the game.
You probably want something like obj.Name.ToUpper().StartsWith ("BG" / "FARBG") or similar today.
2 x
Gurt

Post Reply