Recommended Posts

penguin0616    1084
16 hours ago, MalusNox said:

VarSpawner = GetClosestInstWithTag({"buzzardspawner"} and {"CLASSIFIED"}, ThePlayer, 5) VarSpawner:Remove()

 

This will target anything with a classified tag, not just buzzardspawners.

You only need to check for the buzzardspawner tag.

  • Like 3

Share this post


Link to post
Share on other sites
Owlrus    4898

I'll add this to my signature. Not really a legal "guide" per say, but still very useful should the need arise.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
MalusNox    10

@Friendly Grass during my initial testing I was using c_selectnear and it didn't work, c_selectnext does work but it removes the next spawn instead of the one you're standing at, not a big issue with proper planning but currently the best way I'm aware of because of the unintended issue described below. The c_find to remove the stuck shadow animation works nicely :)

c_selectnext("buzzardspawner"):Remove()
c_find(“circlingbuzzard”):Remove()

 

@penguin0616 I'm new to LUA code and you're correct it doesn't work entirely as intended, I tested it with a MeteorSpawner which only has the classified tag and it removed it, so I guess the SelectNext method mentioned above is the better way to do it. What I was trying to do was search for an entity with both tags using "and" so it would only select an entity with both the "buzzardspawner" and "CLASSIFIED" tags because my code doesn't work without the Classified tag, it returns a nil value error with only "buzzardspawner" but it works with both tags. When I looked in the "buzzardspawner.lua" file in prefabs it adds both tags in the CreateEntity function so that's why I tried using both. I wanted to make it only remove the 1 buzzard spawner you're standing at and nothing else.

Thank you :)

Edited by MalusNox
typo
  • Like 1

Share this post


Link to post
Share on other sites
MalusNox    10

Any reason not to use the RemoveEntity(#) function? it works using the numbers provided by c_gonext("buzzardspawner").

Share this post


Link to post
Share on other sites
Friendly Grass    553
15 hours ago, MalusNox said:

@Friendly Grass during my initial testing I was using c_selectnear and it didn't work, c_selectnext does work but it removes the next spawn instead of the one you're standing at, not a big issue with proper planning but currently the best way I'm aware of because of the unintended issue described below. The c_find to remove the stuck shadow animation works nicely :)

you're right this is an issue. Now I remember why I prefer c_find :wilson_laugh:

14 hours ago, MalusNox said:

Any reason not to use the RemoveEntity(#) function? it works using the numbers provided by c_gonext("buzzardspawner").

Yeah, that works. It's not numbers that it returns but essentially the entity itself. So you can totally just do:

c_gonext("buzzardspawner"):Remove()

However, I am sorry to inform you that c_gonext does use the same exact code as c_selectnext to find which entity to reference. It iterates through the same way.

With everything's downsides, it looks like you were right on from the beginning!

GetClosestInstWithTag({"buzzardspawner", "CLASSIFIED"}, ThePlayer, 50):Remove()

-- the command c_findtag simplifies this but does the same thing

c_findtag({"buzzardspawner", "CLASSIFIED"}):Remove()

c_findtag({"buzzardspawner", "CLASSIFIED"}):Remove()

The classified tag is necessary because the engine function to find nearby entities that these functions stem from seems to ignore prefabs with the tag by default. That is also why only the commands that iterated through all the prefabs in the world worked for this scenario :/

 

15 hours ago, MalusNox said:

What I was trying to do was search for an entity with both tags using "and" so it would only select an entity with both the "buzzardspawner" and "CLASSIFIED"

Just a minor syntax issue. You only needed to separate the tags with a comma and inside the same curly brackets.

 

By the way, to just remove all buzzards and buzzard spawners in your world you can run this while on the surface. I swear this one actually works as I say it does! :???:

for k,v in pairs(Ents) do if v.prefab and v.prefab:find("buzzard") then v:Remove() end end

 

Edited by Friendly Grass
  • Like 1

Share this post


Link to post
Share on other sites
MalusNox    10

@Friendly Grass I'm very new to LUA and syntax will get you every time, no matter what language :wilson_laugh:

I wish there was a DST code syntax manual or something lol...

After more testing I think the fixed original version (simplified with correct syntax) is the way to go as it will only remove the buzzard spawn you're standing at and hopefully nothing else. The goal is to remove only specific buzzard spawners and not all of them. I tested both versions using Buzzard and Meteor Spawners again and using the GetClosestInst version gives a nil value error if you're out of range of a buzzardspawner (range I believe is basically wall sections so 5 is a very small radius, I'm guessing 4 would be 1 pitchfork tile), while the c_findtag version removes the next buzzardspawner it finds no matter the distance.

to remove all buzzard spawners why not just use

c_removeall("buzzardspawner")

thanks again, it looks like we'll crack this one yet lol

I wonder if I should edit the OP with the final version of the code once we figure it out lol...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now