Scripts / [SOLVED] Remove animated entity

Author
Message
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 15th Dec 2018 00:47
Hi guys,
Is there away to remove a animated entity.
Example- I want an animated airplane to take off into the darkness and at a certain point disappear from the game.
I tried the hide entity script but you could still hear the airplane running even though it disappeared.
Didn't know if there was a script to remove both sound and the plane.
Thanks

The author of this post has marked a post as an answer.

Go to answer
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 15th Dec 2018 06:18
Once the object has reached the end of the script, You can insert a destry(e) statement, and that will remove the entity from the level permanently. That is provided you don't need to use this same entity again in the current level.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 15th Dec 2018 11:21
Thanks, I will try that.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Dec 2018 11:53
StopSound might also be useful.
Been there, done that, got all the T-Shirts!
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 15th Dec 2018 17:45
I tried to add the destroy function, then tried the stop sound function to the hide entity script and couldn't get neither of them to work with it.

I am very new to scripting and definitely need some help.

Thanks guys
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Dec 2018 18:12 Edited at: 15th Dec 2018 18:14
How is the sound being played, is there a line LoopSound( e, 0 ) or similar?

If so the 0 part is the sound slot number so you would have to match that in the StopSound command, i.e. StopSound( e, 0 )


It's Destroy( e ) btw, Lua is case sensitive so make sure you have any commands exactly as shown in global.lua.
Been there, done that, got all the T-Shirts!
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 15th Dec 2018 18:44
I basically cut and pasted from the global lua file, I obviously did it wrong.

I'm still in the clueless stage with scripting , but you have to start somewhere.

this is what I did

-- 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(1) then
stopsound (e,v)
end
end

The 1 is the animated airplane I was using from the Polaris pack I bought from the store.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Dec 2018 20:43
If '1' is indeed the entity id of the airplane then you would need StopSound( 1, 0 )

Assuming that the airplane uses sound slot 0, if you look at its script you should be able to determine if that is the case.

So you are then attaching this script to a zone and if the player enters the zone it triggers this script to hide the airplane?

If so add a Destroy( e ) after the StopSound line so that this script will not run again.


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 Dec 2018 00:13
Also / or Destroy(1)
To clarify Amen's point, the e in the brackets is a variable which stores the current entity running the script - as you are wanting it to effect another entity you replace e in any such commands to relate to the number of the desired entity (to make it easier you can store that number in a variable too).
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 16th Dec 2018 12:31
Everytime I add a stopsound or destroy line, it gives me a nil value error
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 16th Dec 2018 12:35
All I need the plane to do is dissapear completely from the game when I hit a triggerzone.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Dec 2018 14:58
This post has been marked by the post author as the answer.
Check the case, i.e. 'Destroy' and 'StopSound'.

A 'nil' error means Lua can't find something, so for example as there is no command called 'destroy' if you forget to capitalise the 'D' Lua will let you know.

Been there, done that, got all the T-Shirts!
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 16th Dec 2018 15:44
Yes !
It finally worked. Thanks for helping.

function hideentity2_init(e)
end

function hideentity2_main(e)
if g_Entity[e]['plrinzone']==1 then
Hide(1)
Destroy(1)
end
end

PM

Login to post a reply

Server time is: 2024-12-22 14:51:45
Your offset time is: 2024-12-22 14:51:45