Hi, I recently decided to make a simple little test addon to get better at it. I decided to make a present addon where you have a present, and when you open it it spawns a random entity. The problem is that it spawns lots of items (because you hold the use button down), I realized I could solve it by having the present dissapear after opening, but i cant figure out how, I've looked for a while and haven't found one that I understood. (Keep in mind, I have no previous lua experience)
Here's my opening function:
function Open()
local SpawnableEntities =
{
"item_ammo_357",
"item_ammo_357_large",
"item_ammo_ar2"
}
local pl = player.GetByID( 1 )
local PlyLookDir = pl:GetTable()
local EntityToSpawn = SpawnableEntities[ math.random( #SpawnableEntities ) ]
SpawnFunction( pl, PlyLookDir, EntityToSpawn )
--This is where i want to remove the entity--
return
end
Again i have no previous lua experience so apologies if my code is bad :P
Take a look at these 2 wiki pages:
Entity/SetUseType
Entity/Remove
Next time please do at least try to search on the wiki before making a thread.
Well I've seen the ent/remove one but again, i have no previous lua experience, and there were no examples (that i understood) that explained how i would put it into my code