Calling a function from actor script in an objectreference s

Post » Wed Jun 20, 2012 7:13 am

I'm not even sure if this can be done. what i'm trying to do is call a function from an actor script (attached to the base actor) from an objectreference script (attached to an activator) onto a reference of said actor. confused yet?


here's what i have so far


script attached on the Base actor


actorscript extends Actorform property somevariable autoform property somevalue autoform property anothervalue autoFunction CoolFunction();Does something using variables on this script;such asIf somethingSomeVariable = SomeValueelseSomeVariable = AnotherValueEndIfEndFunction




script attached to ObjectReference (an activator)


activatorscript extends objectReferenceactor property actorref01 autoactor property actorref02 autoevent OnActivate(ObjectReference akActionRef);actorref01 performs actorscript.coolfunction();actorref02 performs actorscript.coolfunction() independently of actorref01 depending on conditionEndEvent



both actorref01 and actorref02 are references of the same base actor, and both have actorscript attached at their base.

i tried importing actorscript into the objectreferencescript using

Import ActorScript

but i get an error saying i cannot call coolfunction() by itself, it must be cast as a variable (something like that)


i also tried activatorscript extends actorscript, but that nullifies the activation, as it is now an actor script and not an objectreference script (does not activate in game)


any ideas?
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Wed Jun 20, 2012 2:54 pm

I believe the usual syntax would be:

(actorref01 as actorscript).coolfunction()

Your script extends actor, so you need to cast your specific actor into your script's datatype in order to tell the engine which instance of the script you want to call.

I haven't tried the specific configuration of data elements you're using, though, so I don't know if this will work.
User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Wed Jun 20, 2012 3:30 pm

thanks.

i actually just now tried doing

actorref01.registerforsingleupdate(0.1)


and changed coolfunction() into Event OnUpdate()

and it fired off my debug message, so it works that way, but i don't know if that's a really inefficient way of doing it.

i will try your suggestion above

Edit: that works perfectly. thanks
User avatar
Christine Pane
 
Posts: 3306
Joined: Mon Apr 23, 2007 2:14 am


Return to V - Skyrim