Hi,
i try to outsource my functions to another script. Lets say there are 2 Actors who have all a different scripts on them, but they are all using the same functions.
So i thought i outsource the functions to another script, but i don't know how to access them. I tried it like this:
Actor 1 - Team "bandits"
Scriptname MS_SpawnTeamBandits extends Actor MS_SpawnActorsFUNCTIONS Property myFunctions autoActorBase Property EncSkeever autoActor Property ThisActor auto Hiddenstring Property team = "bandits" autoEvent onInit() myFunctions.spawn(team, ThisActor, EncSkeever, 10) Debug.Notification ("10 Skeevers spawned at the actor")EndEvent
Actor 2 - Team "falmer"
Scriptname MS_SpawnTeamFalmers extends Actor MS_SpawnActorsFUNCTIONS Property myFunctions autoActorBase Property EncWolf autoActor Property ThisActor auto Hiddenstring Property team = "falmer" autoEvent onInit() myFunctions.spawn(team, ThisActor, EncWolf, 10) Debug.Notification ("10 Wolfs spawned at the actor")EndEvent
Script which holds the function - the script is attached nowhere, because i don't know where i should put it, i tried to attach it to the player alias, but i can't fill the property of the script as you can see http://www.pasteall.org/pic/show.php?id=78976
Scriptname MS_SpawnActorsFUNCTIONS extends Actor
;========================================
; Functions
;========================================
function spawn (string team, Actor ThisActor_p, ActorBase BASE_p, int amount_p )
bool loop = true
int counter = 1
while loop && BASE_p != None && amount_p > 0
ThisActor_p = self.PlaceActorAtMe (BASE_p, 1)
ChangeTeam (ThisActor_p, team )
if counter == amount_p
loop = false
endif
counter += 1
endwhile
endfunction
Faction Property BanditFaction auto
Faction Property MS_FalmerFaction auto
function ChangeTeam(Actor myActor_p, string team_p)
myActor_p.RemoveFromAllFactions()
if team_p == "falmer"
myActor_p.AddToFaction( MS_FalmerFaction )
elseif team_p == "bandits"
myActor_p.AddToFaction( BanditFaction )
else
Debug.Notification ("Error 1")
endif
myActor_p.setAV("Aggression", self.getAV("Aggression") as int)
endfunction
If i try to fill the script property then i only can pick a cell (http://www.pasteall.org/pic/show.php?id=78976)
I try it now for hours without success. Can someone help me please ?
Thanks in advance for any help!!