Page 1 of 1
Help with bad logic syntax
Posted: 12 Oct 2010, 05:56
by bobthedinosaur
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?
Re: Help with bad logic syntax
Posted: 12 Oct 2010, 06:17
by SpliFF
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.
Re: Help with bad logic syntax
Posted: 12 Oct 2010, 06:20
by knorke
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?
Based on "it delets all or nothing at all" it would guess this:
Code: Select all
if Spring.GetUnitDefID(u) ~= watchers then
Spring.DestroyUnit(u, false, true)
end
does not correctly recognize if a unit is a to be deleted or not.
(I do not understand what
means.) I think it might be something like you are comparing a DefID (number) to a name (string)
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
But really you would better explain your problem more clearly I have no idea if I understood correctly what you want

Re: Help with bad logic syntax
Posted: 12 Oct 2010, 06:36
by bobthedinosaur
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
Re: Help with bad logic syntax
Posted: 12 Oct 2010, 17:10
by knorke
knorke what are you trying to do
trying to do this:
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.
with that last unlocalized function?
didnt think about local/not local or synthax just the general idea.
Re: Help with bad logic syntax
Posted: 13 Oct 2010, 22:00
by SirMaverick
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:
You can't copy&paste a body of a function and expect it to work in the same way (your DestroyUnit() is never executed).
Re: Help with bad logic syntax
Posted: 14 Oct 2010, 04:11
by bobthedinosaur
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.