Scripts / Obtaining Entities Count

Author
Message
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 7th Sep 2017 13:48 Edited at: 8th Sep 2017 09:43
ok, so this it what I originally posted, which apparently seems correct but as AmenMoses pointed out g_Entity only populates for Dynamic entities which I hadn't realised at the time. Also, don't do what I did initially and put the call to the function in the _init section. Must be called within the _main loop section. Doh!

Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 7th Sep 2017 19:42 Edited at: 7th Sep 2017 20:15


That's how I'd count the entities, if you want to only find activated ones you could add a check for v.activated == 1 as well.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Sep 2017 19:46
there's also an variable in global.lua for the value
g_EntityElementMax
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 7th Sep 2017 19:55
@AmenMoses-my code was similar but I was getting a count of 2 even after adding more entities into the editor. Thanks, I'll give that a try.

@smallg-thanks I must have missed that one in the global.lua file. Will play around with that also.

Gotta get back into the LUA scene it's been a while.

Bw
Mike
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 7th Sep 2017 20:22 Edited at: 7th Sep 2017 20:25
The g_Entity list only contains active entities btw, you can't get at static ones as although the ray casting commands will give a object id for them there doesn't appear to be any way to get at any information about them.

So you can count soldiers and doors and collectables (and helicopters ) but you can't count rocks and walls and stuff.

I've bugged Lee about this before, to maybe have a separate static entity list accessible from Lua that has name, position, rotation and size that we can then use in scripts.

Currently I can detect an object in front of my vehicles but cannot really make much use of that info because I don't even know what it is! Could be a building or a tree or a traffic cone.

Even better would be a way of directly accessing the collision box of an object, maybe as a list of coordinates, that way I could extend my zones scripts to include functions like returning true if a given point is inside an specific object. (or maybe Lee could give us a primitive function that directly does this?)
Been there, done that, got all the T-Shirts!
PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 7th Sep 2017 22:01
ok yes that makes sense although I'm sure I placed all dynamic entites but will double check. Also the g_EntityElementMax always returns 0. Anyway, will do some more investigating into the world of LUA. Not my main language but fun messing about with it see what can be done.
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 8th Sep 2017 07:12 Edited at: 8th Sep 2017 07:13
looks like there is some sort of bug as I placed more dynamic entities, doors, barrels, weapon etc into the scene and the count is still 2 with both AM code and my code:
Maybe I will try with a fresh new level but my hopes aren't high ha
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 8th Sep 2017 08:16 Edited at: 8th Sep 2017 08:19
Just tested my code here and it works fine.

Check you're using pairs and not ipairs.
Been there, done that, got all the T-Shirts!
PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 8th Sep 2017 09:01
both functions (yours and mine) use pairs. will try again later after work, must be something I'm not doing correct. thanks for the help though
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 8th Sep 2017 09:11
ok I am a total plum, I didn't put the code in the _main section.... oh dear ...... Count is now above 4+ ... phew thought I was going crazy
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 8th Sep 2017 14:12
phew that's better.....gonna have a lot of fun with this and waypoints plus floating bridges etc.....
g_EntityElementMax also working...again I put the call in _init instead of _main (what a dope ha)

Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-12-23 00:43:48
Your offset time is: 2024-12-23 00:43:48