Page 1 of 1

"For loop", to make notsolids script error.

Posted: Thu Feb 13, 2003 11:31 am
by Angex
I'm working on an SP map for AA, and I want to make a loop that will set certain brushes to notsolid. I have made them script_objects and named them notsolid1, notsolid2, notsolid3, etc. I'm using the following code:

Code: Select all

main:
  exec global/loadout.scr "maps/test_drive.scr"

  level waittill prespawn

//SET NON SOLIDS
  waitthread nonSolids 3

  level waittill spawn
  level.script = "maps test_drive.scr"
end

//SET NON SOLIDS THREAD
nonSolids local.amount:
  for (local.i = 1; local.i <= local.amount; local.i++) {
    $nonsolid[local.i] notsolid
  }
end
I keep getting a script error:

^~^~^ Script Error: command 'notsolid' applied to NULL listener

How can I make it target $notsolid1,2,3 etc instead of $notsolid which doesn't exsist.

Posted: Thu Feb 13, 2003 12:15 pm
by mohaa_rox
It means that your nonsolid1,2,3 have the "nonsolid properties" which didn't apply to them.

Posted: Thu Feb 13, 2003 1:21 pm
by jv_map
No, you have a slightly wrong understanding of the code you typed.

$nonsolid[local.i]

returns an entity with targetname 'nonsolid'. If you have multiple entities with this targetname, you can use the [ and ] to access array components. e.g.

$nonsolid[2]

returns the second-spawned entity with targetname 'nonsolid'.

What you want however, is the following:
$("nonsolid" + local.i)

Which creates a targetname string first and then returns the corresponding entity.

Posted: Thu Feb 13, 2003 9:24 pm
by Angex
Cheers jv, I didn't realise I could do that, I though it would try and add the integer to the string, causing an incompatible types error.