Scripts / Multiple object spawn

Author
Message
monte
9
Years of Service
User Offline
Joined: 12th Apr 2015
Location:
Posted: 5th Apr 2016 04:10
Hello All,

I'm looking for a way to spawn multiple objects without using fixed object numbers in scripts, so I know of
Spawn(100)
Spawn(101) etc
But I need to get the entity number and spawn it like
Spawn(object)

The trouble I'm having is identifying another object entityid's from a single script, like a tree falling and spawning a log multiple times over a map

I tried to call a script eg log.lua which only had Spawn(e) as the main function but either the script call didn't work or the function didn't and I couldn't work out which. So this was attached to the object that needed spawning...


I'm calling this script in the same way but once the tree has fallen, health=0 but nothing happens, is there a better way to achieve this ? - I have checked the directory paths and any typos for the include and switch scripts.

Thanks
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Apr 2016 10:42
Place some entities that you wish to spawn in the map in the desired location (this can be changed via script later though) and name them all the same if they will he spawned at the same time (i.e 3x "log1" 4x "log2" for giving 3 logs from 1 tree and 4 logs from another etc)
Set them to have a script to allow them to be picked up.
Finally set them 'spawn at start = no'

Now on your tree in the 'ifused' field enter the name of the logs it should spawn and instead of calling spawn in the code use ActivateIfUsed(e)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
monte
9
Years of Service
User Offline
Joined: 12th Apr 2015
Location:
Posted: 11th Apr 2016 05:04
Thanks smallg, that got it -

For so long I couldn't see the wood for the trees

M
PM

Login to post a reply

Server time is: 2024-04-27 08:42:34
Your offset time is: 2024-04-27 08:42:34