Forum

> > CS2D > Scripts > How do you check if there are no enteties alive?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How do you check if there are no enteties alive?

9 replies
To the start Previous 1 Next To the start

old Re: How do you check if there are no enteties alive?

Apache uwu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("always","_always")

npcs=false

function _always()
	npcs=false
	for _,id in ipairs(object(0,"table")) do
		if object(id,"type")==30 then
			npcs=true
		end
	end
	if npcs==false then
		msg("no enemies")
	else
		msg("there are enemies")
	end
end

30 = Zombie, not sure what the rest are might have to check up on that.

old Re: How do you check if there are no enteties alive?

olivebates
User Off Offline

Quote
Hmm, ok, trying to implement it now, but I am having trouble understanding the "
for _,id in ipairs(object(0,"table")) do
if object(id,"type")==30 then
npcs=true
end
end
"

I'm extreemly new to lua, do you think you could explain this?

old Re: How do you check if there are no enteties alive?

olivebates
User Off Offline

Quote
Oh, so this would actually be a fully functioning code?

if aa==nil then aa=={} end
aa.bb={}

addhook("trigger","aa.bb.trigger")
addhook("second","aa.bb.second")
aa.bb.npcs=false

function aa.bb.trigger(waves,0)
     
     function aa.bb.second()
      npcs=false
      for _,id in ipairs(object(0,"table")) do
      if object(id,"type")==30 then
      npcs=true
      end
      end
      if npcs==false then
      msg("no enemies")
      else
      msg("there are enemies")
      end
     end
end

old Re: How do you check if there are no enteties alive?

olivebates
User Off Offline

Quote
Oh so just like this? (also how do you put it in that green box?)

if aa==nil then aa=={} end
aa.bb={}

addhook("trigger","aa.bb.trigger")
addhook("second","aa.bb.second")
aa.bb.npcs=false

function aa.bb.second()
npcs=false
for _,id in ipairs(object(0,"table")) do
if object(id,"type")==30 then
npcs=true
end
end
if npcs==false then
msg("no enemies")
else
      msg("there are enemies")
end
end

EDIT: Also, would it be possible to add a variable like this:
parse("trigger wave"..wavnum)
so it triggers wave1 or wave2 etc.
edited 1×, last 24.08.11 10:41:09 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview