Scripts / e# from object number?

Author
Message
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 30th Dec 2020 06:36
Trying to get the entity number from object number.
But always getting error message: "ObjectToEntity" is nil

I've tried so far a new map with just one barrel

local P = require "scriptbank\\physlib"
Text(33,33,3, "o2e ; "..ObjectToEntity( g_Entity[e]['obj'] ) )

Next tried;
Text(33,33,3, "o2e ; "..ObjectToEntity( 70002 ) )

Still nil -- any help?


PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 30th Dec 2020 09:52
If you try to get some info from some entity, that entity should be dynamic.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Dec 2020 10:16
it is P.ObjectToEntity( obj )
so
local P = require "scriptbank\\physlib"
Text(33,33,3, "o2e ; "..P.ObjectToEntity( g_Entity[e]['obj'] ) )
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 30th Dec 2020 14:01
Wot smallg said.

Plus don't try to use that function in the _init function of your scripts, the first time it is called must come after all entities have been initialised so that the g_Entity list is fully populated.

When the _init function is called the only g_Entity list entry that is guaranteed to be populated is the one for that entity.
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 30th Dec 2020 16:44
Thanks for the help. So that's how those libraries work!
Didn't I try it with P. lol it was getting late.
PM

Login to post a reply

Server time is: 2024-12-22 02:08:10
Your offset time is: 2024-12-22 02:08:10