Scripts / Can't make npc disappear

Author
Message
LGoat
5
Years of Service
User Offline
Joined: 16th Sep 2018
Location:
Posted: 31st Oct 2018 11:50
I want to add a trigger when you step on it to make an npc disappear but none of the scripts work

destroyzone doesnt work when the npc walks over it

-- LUA Script - precede every function and global member with lowercase name of script + '_main'

-- Player Enters Win Zone



function destroyzone_init(e)

end



function destroyzone_main(e)

if g_Entity[e]['plrinzone']==1 then

for x = e+1, e+5 do

Destroy(x)

end

ActivateIfUsed(e)

end

end

and neither the disappear.lua in GG
Anyone has a script?

PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 31st Oct 2018 15:50
You could use the Hide command perhaps. Hide(e) and where e is you put the ID of the character entity you want to hide.
Twitter - Teabone3 | Youtube - Teabone3 | Twitch - Teabone3 | TGC Assets - Store Link | Patreon - Teabone3

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 31st Oct 2018 18:36
bit confused what you are asking for here, is it the player or the entity that should be walking into the zone?
if g_Entity[e]['plrinzone']==1 then
checks for the player entering the zone, not the NPC.

if it's the player entering the zone then you will need to make sure the entity to destroy is within the range you give in your for loop
for x = e+1, e+5 do
(e is the entity number of the zone - so assuming the zone is entity 2 then it will destroy entities 3 to 7)
and that the NPC is not set to always active.
would be better to do it by name to ensure the right entity is destroyed.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 31st Oct 2018 23:53 Edited at: 31st Oct 2018 23:55
You should be able to hide or destroy any npc by either using hide(entityID you need) or destroy(entityID). You could also use the heath setting and set it to 0, although that would only work on npc's and of course make them die rather than just vanish.
I use the hide command in this to place decorations and set the fire going for instance.
SPECS: Ryzen 1700 CPU. Nvidia 970GTX. 16 Gig Memory. Win 10.
LGoat
5
Years of Service
User Offline
Joined: 16th Sep 2018
Location:
Posted: 1st Nov 2018 06:57
@TeaBone how do you get the id number?It used to be in properties but id doesnt show anymore
And you mean something like dis?

-- LUA Script - precede every function and global member with lowercase name of script + '_main'

function hideentity_init(e)
end

function hideentity_main(e)
if g_Entity[e]['plrinzone']==1 then
Hide(idhere)
end
e
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 2nd Nov 2018 14:34
You can see the ID of an entity when you hover over them with the mouse in the editor. Its really small text at the very bottom of the GG window.
Twitter - Teabone3 | Youtube - Teabone3 | Twitch - Teabone3 | TGC Assets - Store Link | Patreon - Teabone3

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Nov 2018 14:36
The ID number is the first one on the bottom bar when you highlight the object in editor. That hasn't ever changed, so you can easily test this by using that. To get an ID number in game, you need code in the objects script to save it such as
IDnum=e
Then you can use IDnum to hide the object in another script.
That will work with a single object, you would need to use an array (table in lua speak) to store many object ID numbers. For the odd object though, it is simply way easier to use a variable.
SPECS: Ryzen 1700 CPU. Nvidia 970GTX. 16 Gig Memory. Win 10.

Login to post a reply

Server time is: 2024-05-18 15:16:41
Your offset time is: 2024-05-18 15:16:41