Okay I am messing around with this to delete every unit but the unit defined as the local watchers UnitDefNames.testor.id when they only ones remaining are the does not counts.
http://sl.pastebin.com/4NM14Mim
Playing with it I can either get it to delete them all including the watchers, or nothing at all.
What am I doing wrong?
Help with bad logic syntax
Moderator: Moderators
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Help with bad logic syntax
Last edited by bobthedinosaur on 12 Oct 2010, 06:37, edited 1 time in total.
Re: Help with bad logic syntax
Well the first thing you're doing wrong is mixing your words into utter nonsense. I've never seen any sentence structure like "when they only ones remaining are the does not counts" before so any possible meaning it might have is totally lost on me.
You better start by explaining what you are trying to do in something closer to English grammar. I'm not being a Nazi about it, I'm honestly baffled.
You better start by explaining what you are trying to do in something closer to English grammar. I'm not being a Nazi about it, I'm honestly baffled.
Re: Help with bad logic syntax
Based on "it delets all or nothing at all" it would guess this:bobthedinosaur wrote:Playing with it i can either get it to delete them all including the watchers, or nothing at all.
What am I doing wrong?
Code: Select all
if Spring.GetUnitDefID(u) ~= watchers then
Spring.DestroyUnit(u, false, true)
end
(I do not understand what
Code: Select all
UnitDefNames.testor.id
Instead of DefIDs you could try comparing names.
So try something like:
Code: Select all
unitname_not_to_delete = "watcherunit"
in the loop:
for _,u in ipairs(Spring.GetTeamUnits(t)) do
if (delete_this_unit(u)==true then
Spring.DestroyUnit(u, false, true)
end
end
function delete_this_unit (u)
local unitDef = UnitDefs[u]
if (unitDef.name == unitname_not_to_delete) then return false else return true end
end

- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Help with bad logic syntax
Sorry, the "doesnotcount" are a custom param, I thought some people would recognize from kdr's doesnotcount gadget, that this gadget was originally.
Anyhow, I have a unit "testor", and when it is left with only other units that are does not count, I want the team to be marked for deletion and then delete all of the "doesnotcount" units, but not the "testor" unit.
knorke what are you trying to do with that last unlocalized function?
edit:
I added a custom para to the camera unit aka "testor" or old local watchers. But apparently I am doing this very wrong:
http://sl.pastebin.com/ESra6Dfd
Anyhow, I have a unit "testor", and when it is left with only other units that are does not count, I want the team to be marked for deletion and then delete all of the "doesnotcount" units, but not the "testor" unit.
knorke what are you trying to do with that last unlocalized function?
edit:
I added a custom para to the camera unit aka "testor" or old local watchers. But apparently I am doing this very wrong:
http://sl.pastebin.com/ESra6Dfd
Re: Help with bad logic syntax
trying to do this:knorke what are you trying to do
Anyhow, I have a unit "testor", and when it is left with only other units that are does not count, I want the team to be marked for deletion and then delete all of the "doesnotcount" units, but not the "testor" unit.
didnt think about local/not local or synthax just the general idea.with that last unlocalized function?
-
- Posts: 834
- Joined: 19 May 2009, 21:10
Re: Help with bad logic syntax
You can't copy&paste a body of a function and expect it to work in the same way (your DestroyUnit() is never executed).bobthedinosaur wrote:I added a custom para to the camera unit aka "testor" or old local watchers. But apparently I am doing this very wrong:
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Help with bad logic syntax
I wasn't exactly copy pasting. It works now, kind of. It just conflicts with other gadgets, not error wise, but action wise.
edit:
Here is what I have now: http://sl.pastebin.com/eK8c8KY5
Unfortunately I think the dead team sticks, because if a round is won and new units spawn for the new round they are deleted right away.
So I am going to have to find out how to kill the bad team after it has done it's job, so it doesn't eat the next round's units.
edit:
Here is what I have now: http://sl.pastebin.com/eK8c8KY5
Unfortunately I think the dead team sticks, because if a round is won and new units spawn for the new round they are deleted right away.
So I am going to have to find out how to kill the bad team after it has done it's job, so it doesn't eat the next round's units.