How do you import scripts?

Post » Wed Jun 20, 2012 2:44 pm

I thought this would be intuitive, but apparently I'm doing it wrong.

So I've got this script EvalDerived, and in it is a function declared in the following way:

Sciptname EvalDerived extends Actorfunction EvalStrMod(int StrModifier)  ;codeendFunction



then in other scripts, I have imported EvalDerived and am trying to do this:
Scriptname BlahBlah extends magiceffectimport EvalDerived;code blah blahEvent OnEffectStart(actor akCaster, Actor akTarget)   Actor hitactor = akTarget   Actor mage = akCaster   hitactor.EvalStrMod(-1);more codeendEvent

But it's throwing "EvalStrMod is not a function or does not exist."
I have no idea what I'm doing wrong, but I have a feeling its a simple fix.

EDIT: I'm pretty sure this is because my function is not declared as global. The problem is, when I declare it as global, it completely breaks. Everything. What are the differences in how to code something as a global function rather than a non-global?

EDIT2: Pretty sure global functions are not the way to go on this...so if I cant import to use a function from one script in another, how do I do this? Saying hitactor.EvalDerived.EvalStrMod(-1) didn't work either...
it said EvalDerived could not be used as a property
User avatar
Juanita Hernandez
 
Posts: 3269
Joined: Sat Jan 06, 2007 10:36 am

Post » Wed Jun 20, 2012 10:12 pm

Add the Global flag to your function like this
edit: opps missed your edit :smile:

Hard to say for me. Ive been experimenting with custom functions today so I can give a few blind guesses.
-Have your function's script extend nothing
-Make sure your function is returning a value if you plan to modify a variable with it.
-Call function like this
int EvalReturnEvalReturn = EvalDerived.EvalStrMod(-1)Game.GetPlayer().ModActorValue("someStat", EvalReturn)

Something like that. Hard to say without seeing the whole script.
User avatar
Emma Parkinson
 
Posts: 3401
Joined: Wed Jul 26, 2006 5:53 pm

Post » Wed Jun 20, 2012 11:03 am

EDIT: I'm pretty sure this is because my function is not declared as global. The problem is, when I declare it as global, it completely breaks. Everything. What are the differences in how to code something as a global function rather than a non-global?

EDIT2: Pretty sure global functions are not the way to go on this...

How does declaring it as a global break everything?

Oh wait, nvm. I see you're not actually getting a return value on the function. You're doing trying to do something to an actor in the function. Very simple then. Do this:

Function EvalStrMod(Actor TargetActor, int StrModifier) Global    ;code hereEndFunction

EvalStrMod(hitactor, -1)
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Wed Jun 20, 2012 9:51 am

Tried that already, but I'll give it another shot. Maybe I forgot something last time...

Got the same problem again. As soon as it is a global function, it stops recognizing all the properties.
User avatar
Sarah Kim
 
Posts: 3407
Joined: Tue Aug 29, 2006 2:24 pm

Post » Wed Jun 20, 2012 11:23 pm

Wait, you mean you have properties in your 'EvalDerived' script that's being used in your 'EvalStrMod' function? No wonder... You just can't import a script like that. Importing a script doesn't import its properties.
User avatar
Robyn Howlett
 
Posts: 3332
Joined: Wed Aug 23, 2006 9:01 pm

Post » Wed Jun 20, 2012 9:22 pm

Script properties are filled locally right?

Ducey post your functions ";code here"
User avatar
Rachel Eloise Getoutofmyface
 
Posts: 3445
Joined: Mon Oct 09, 2006 5:20 pm

Post » Wed Jun 20, 2012 11:59 am

Global functions must have ALL information they are to use passed to them. By becoming global, they lose access to all member properties...you even need to pass in "self" if you want to use the global function in a local member function or event and use member properties.
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Wed Jun 20, 2012 8:28 pm

That just seems silly to me. Well, coding just got a bit more laborious.
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Wed Jun 20, 2012 9:49 am

well to access the local properties, you can do so like this:

Function MyGlobalFunction(MyScriptType InReference) Global   InReference.MyLocalProperty1 = Whatever.EndFunctionFunction UseGlobalFunction()   MyScriptType.MyGlobalFunction(Self)EndFunction
User avatar
xx_Jess_xx
 
Posts: 3371
Joined: Thu Nov 30, 2006 12:01 pm

Post » Wed Jun 20, 2012 9:20 pm

Hmm. Got this 99% working, but I get one weird error.
Here is my script. You can CTRL+F "squid" to see where the problem is.
Scriptname ChromaticOrbScript extends activemagiceffect Faction Property DnDMageLevel autoFaction Property DnDTHAC0 autoFaction Property DnDArmorClass autoFaction Property DnDStrength autoFaction Property DnDDexterity autoFaction Property DnDLinearDamageAdjuster autoSpell Property DnDParalyse1Sec autoSpell Property DnDStun1Sec autoEvent OnEffectStart(Actor akTarget, Actor akCaster)   int d4randomdam = Utility.RandomInt(1,4)   int d6randomdam = Utility.RandomInt(1,6)   int d8randomdam = Utility.RandomInt(1,8)   int d10randomdam = Utility.RandomInt(1,10)   int d12randomdam = Utility.RandomInt(1,12)   int twod4randomdam = Utility.RandomInt(2,8)   int twod8randomdam = Utility.RandomInt(2,16)   int fourd10randomdam = Utility.RandomInt(4,40)   int duration = 0   int durationcounter = 0   Actor Mage =  akCaster   actor hitactor = akTarget   if Mage.GetFactionRank(DnDMageLevel) as int ==1	  hitactor.DamageAV("Health", d4randomdam)	  hitactor.SetFactionRank(DnDArmorClass, (hitactor.GetFactionRank(DnDArmorClass) as int) +- 4)	  hitactor.SetFactionRank(DnDTHAC0, (hitactor.GetFactionRank(DnDTHAC0) as int) +- 4)	  Utility.Wait(2)	  hitactor.SetFactionRank(DnDArmorClass, (hitactor.GetFactionRank(DnDArmorClass) as int) + 4)	  hitactor.SetFactionRank(DnDTHAC0, (hitactor.GetFactionRank(DnDTHAC0) as int) + 4)	    endIf   if Mage.GetFactionRank(DnDMageLevel) as int ==2	  hitactor.DamageAV("Health", d6randomdam)	  ;Usage      ;squid Right here it is saying that DnDThac0 is not specified and has no initial value. Everything else in the script runs fine.	  EvalDerived.EvalStrMod(hitactor, -1, DnDStrength, DnDLinearDamageAdjuster, DnDTHAC0)	  EvalDerived.EvalStrMod(hitactor, -1, DnDDexterity, DnDArmorClass)	  Utility.Wait(2)	  EvalDerived.EvalStrMod(hitactor, 1, DnDStrength, DnDLinearDamageAdjuster, DnDTHAC0)	  EvalDerived.EvalStrMod(hitactor, 1, DnDDexterity, DnDArmorClass)	    endIf   if Mage.GetFactionRank(DnDMageLevel) as int ==3	  hitactor.DamageAV("Health", (d8randomdam+ d4randomdam))	    endIf   if Mage.GetFactionRank(DnDMageLevel) as int ==4	  hitactor.DamageAV("Health", d10randomdam)	  hitactor.SetFactionRank(DnDArmorClass, (hitactor.GetFactionRank(DnDArmorClass) as int) +- 4)	  hitactor.SetFactionRank(DnDTHAC0, (hitactor.GetFactionRank(DnDTHAC0) as int) +- 4)	  Utility.Wait(2)	  hitactor.SetFactionRank(DnDArmorClass, (hitactor.GetFactionRank(DnDArmorClass) as int) + 4)	  hitactor.SetFactionRank(DnDTHAC0, (hitactor.GetFactionRank(DnDTHAC0) as int) + 4)	    endIf   if Mage.GetFactionRank(DnDMageLevel) as int ==5	  hitactor.DamageAV("Health", d12randomdam)		    int Stun1Counter = 0	  while Stun1Counter <= 5		 Stun1counter = Stun1Counter + 1		 duration = duration + Utility.RandomInt(1,4)	  endwhile	  duration = duration +5	  duration = duration/6	  while  durationcounter <= duration		 DnDStun1Sec.Cast(mage, hitactor)		 Utility.Wait(1)		 durationcounter = durationcounter + 1	  endWhile   endIf   if Mage.GetFactionRank(DnDMageLevel) as int ==6	  int SleepCounter = 0	  while SleepCounter <= 5		 Sleepcounter = SleepCounter + 1		 duration = duration + Utility.RandomInt(1,4)	  endwhile	  duration = duration +5	  duration = duration/6	  hitactor.DamageAV("Health", twod4randomdam)	  hitactor.SetUnconscious()	  Utility.Wait(duration)	  hitactor.SetUnconscious(false)   endIf   if Mage.GetFactionRank(DnDMageLevel) as int >=7 && Mage.GetFactionRank(DnDMageLevel) as int <10	  hitactor.DamageAV("Health", twod8randomdam)	  int StunCounter = 0	  duration = 30 + Utility.RandomInt(0,70)	  duration = duration/6	  while  durationcounter <= duration		 DnDParalyse1Sec.Cast(mage, hitactor)		 Utility.Wait(1)		 durationcounter = durationcounter + 1	  endWhile   endIf   if (Mage.GetFactionRank(DnDMageLevel) as int) >=10 && (Mage.GetFactionRank(DnDMageLevel) as int) < 12	    endIf   if Mage.GetFactionRank(DnDMageLevel) as int >=12	  hitactor.DamageAV("Health", fourd10randomdam)	  duration = 10 + Utility.RandomInt(0,30)	  duration = duration/6	  while  durationcounter <= duration		 DnDParalyse1Sec.Cast(mage, hitactor)		 Utility.Wait(1)		 durationcounter = durationcounter + 1	  endWhile	    endIfendEvent

P.S You'll not that at level 10 it doesn't do anything. This is because it is supposed to have a chance to turn people to stone. Is it even remotely possible to dynamically apply a texture to something? Because turning people to stone would be purty sweet.
User avatar
Big Homie
 
Posts: 3479
Joined: Sun Sep 16, 2007 3:31 pm

Post » Wed Jun 20, 2012 10:58 am

Nvm, the problem was actually that I forgot to make the line afterwards EvalDEXMod instead of EvalSTRMod
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am


Return to V - Skyrim