"For loop", to make notsolids script error.

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

"For loop", to make notsolids script error.

Post 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.
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

It means that your nonsolid1,2,3 have the "nonsolid properties" which didn't apply to them.
Live to map, not map to live.
-mohaa_rox, .map
moderator
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post 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.
Post Reply