Can anyone see what in Oblivion I'm doing wrong here? I have a formlist set up to contain the five carriage drivers. It's populated in the CK and correctly linked to the drivers property:
formlist property drivers autoactor function random_driver() trace(" bridge: driver formlist = " + drivers) int len = drivers.getsize() trace(" bridge: driver formlist size = " + len) int lim = len - 1 trace(" bridge: driver formlist index limit = " + lim) int idx = utility.randomint(0, lim) trace(" bridge: driver formlist index = " + idx) form f = drivers.getat(idx) as actor trace(" bridge: driver formlist selected form = " + f) actor a = f as actor if a == none trace(" bridge: error - selected form is not an actor") endif return aendfunction
This is what happens
[10/10/2015 - 07:23:47AM] bridge: stage 00[10/10/2015 - 07:23:47AM] bridge: driver formlist = [FormList < (350137D3)>][10/10/2015 - 07:23:47AM] bridge: driver formlist size = 5[10/10/2015 - 07:23:47AM] bridge: driver formlist index limit = 4[10/10/2015 - 07:23:47AM] bridge: driver formlist index = 3[10/10/2015 - 07:23:47AM] bridge: driver formlist selected form = None[10/10/2015 - 07:23:47AM] bridge: error - selected form is not an actor[10/10/2015 - 07:23:47AM] bridge: carter ref = None
The form id is correct, the size is correct, the index is within bounds ... and yet I get None as the value returned.
I do believe the CK is trolling me again. Can anyone see what I'm missing?
[edit]
Hmm... the formlist is filled with _NPC instances. Which I believe means they're ActorBase objects rather than actual Actors. So what I'm trying wouldn't have worked anyway.
I still want to know why I don't get a form out of it though... wait a minute, I'm casting the result to Actor before assigning it to a form. And since it's not an Actor, it's nulling out.
Thanks for listening, everyone. Nothing like explaining to an audience to help you see your own Stupid