Scripts / Check for "allready spawned"

Author
Message
Snake675
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Planet Earth
Posted: 16th Feb 2019 13:45
Hi everyone

I wonder if there is a variable to check in the script wether a entity has allready been spawned that has "spawn at start = no" set in the editor.
It seems scripts are executed even when "no spawn" is set and the entity has not been spawned yet. Very odd...

Best, Snake675
-Snake675
------------------------------------------------------------

Intel Core i5 760 @ 2.80GHz, RAM 16.0GB, NVIDIA GeForce GT 1030 2047MB

GameGuru
FPS Creator
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Feb 2019 14:11 Edited at: 16th Feb 2019 16:00
Interesting, you are correct if you've set 'spawn at start' to no GG runs the _main function once then stops calling it until the entity is spawned.

So you could simply treat the first call as an extra initialisation phase and make the 'real' code only run from pass 2 onwards.

For example add a 'state' variable to the script:

local state = {}

Then in the _init function:

state[ e ] = nil

and then in _main:

if state[ e ] == nil then
state[ e ] = 'initialised'
return
end

…. real code
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: 16th Feb 2019 15:28
i believe g_Entity[e]['activated'] will return the spawned state of the entity -> 0 being not spawned
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Snake675
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Planet Earth
Posted: 16th Feb 2019 16:08
@both
Thanks for your suggestions.

@AmenMoses
Ok, that's the way it works. Funny...

@smallg
Yes, I used to use this. In combination with the corrosions script to make enemies attacking the player immidiatly, it does not work because "activated" is allready set to 2 from start, even if the entity has not been spawned yet. So I will try AmenMoses' suggestion, even if I will have to modify the standard ai scrips...

Best, Snake675
-Snake675
------------------------------------------------------------

Intel Core i5 760 @ 2.80GHz, RAM 16.0GB, NVIDIA GeForce GT 1030 2047MB

GameGuru
FPS Creator

Login to post a reply

Server time is: 2024-12-22 14:14:28
Your offset time is: 2024-12-22 14:14:28