How do you call a function?

Post » Wed Jun 20, 2012 9:24 am

So I wrote a custom function called VampireFeedCountPowers that updates the vampires powers based on a variable I wrote called FeedCount

How do I call that function from within the script? What is the syntax to call a function from inside a quest script?
User avatar
Syaza Ramali
 
Posts: 3466
Joined: Wed Jan 24, 2007 10:46 am

Post » Wed Jun 20, 2012 8:04 am

Just VampireFeedCountPowers()

As far as you call it from the script defining it and didn't have arguments.
User avatar
jess hughes
 
Posts: 3382
Joined: Tue Oct 24, 2006 8:10 pm

Post » Wed Jun 20, 2012 7:57 am

Yeah I tried that earlier and got an error: PlayerVampireQuestScript.psc(57,1): argument player is not specified and has no default value

I added VampireFeedCountPowers() to the event block Event OnUpdateGameTime() and got that error. Here is my function:

;MM give the player powers after x feedsFunction VampireFeedCountPowers(Actor Player)    If Feedcount >=500        ;Immortal Kiss. Turn mortals into subserviant vampires.    ElseIf Feedcount >=400        ;add 400 powers here. Greater Vampire Speed, transform into a dire wolf.    ElseIf Feedcount >=350        ;add 350 powers here. Resist paralasis +25. Mortis shield gives a 25% increase in unarmored protection.    ElseIf Feedcount >=300        ;add 300 powers here. Vampiric Seduction. Convince non hostile NPCs to go to bed so you can feed on them. Ones that like you will offer their neck to you for feeding on the spot.    ElseIf Feedcount >=250        ;add 250 powers here. Vampiric Domination. Undead Frenzy.  Forces lower level undead into a frenzy to fight for you. Vampiric Regeneration II    ElseIf Feedcount >=200        ;add 200 powers here. Eviscerate. (vampire finishing move that cuts heads off with claws)    Elseif Feedcount >=175        ;add 175 powers here. Vampiric Charm. Convince people to give bottled blood if they like you (people you have done quests for). Make thralls (mortals    Elseif Feedcount >=150        ;add 150 powers here. Shadow Master. Fortify sneak, muffle    Elseif Feedcount >=125        ;add 125 powers here. Vampiric intimidation. (Fortify chance of intimidation by 40). Can bottle blood from sleeping people.    Elseif Feedcount >=100        ;add 100 powers here. Vampire strength. Increase carry capacity by 100 and get super jump.    Elseif Feedcount >=75        ;add 75 powers here. Claws which boost h2h damage & unlimited fall damage.    Elseif Feedcount >=50        ;add 50 powers here. Vampiric regeneration and vampire speed (fortify speed toggle power)    Elseif Feedcount >=25        ;add 25 powers here. Detect Dead. Resist paralasis +10        Player.Addspell(VampireDetectDead, abVerbose = False)    EndifEndFunction
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Wed Jun 20, 2012 6:53 pm

"Function VampireFeedCountPowers(Actor Player)" - "Actor" and "Player" are arguments you are passing to the function.

"Function VampireFeedCountPowers()" would not require any arguments so VampireFeedCountPowers() would work. This is fine if you do not need to pass any variables into to function.
User avatar
Chelsea Head
 
Posts: 3433
Joined: Thu Mar 08, 2007 6:38 am

Post » Wed Jun 20, 2012 5:14 pm

Call your function with:

VampireFeedCountPowers(Game.GetPlayer())
User avatar
Prohibited
 
Posts: 3293
Joined: Tue Jun 12, 2007 6:13 am

Post » Wed Jun 20, 2012 5:51 pm

Indeed, there's no reason in having the player argument for your function. there is only one player... unless you're hiding that you're working in a multiplayer environment lol.

You generally just refer to the player by using Game.Getplayer() like Game.Getplayer().Addspell(
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am

Post » Wed Jun 20, 2012 6:02 am

Call your function with:

VampireFeedCountPowers(Game.GetPlayer())
This compiled. How come I need to pass the player as an argument into that function?
User avatar
Breautiful
 
Posts: 3539
Joined: Tue Jan 16, 2007 6:51 am

Post » Wed Jun 20, 2012 8:31 am

When you wrote your function, you had this:

Function VampireFeedCountPowers(Actor Player)

This is telling the compiler that your function must have an actor for a parameter. Similar to how OnEffectStart() must have two actors as a parameter. So in order to call your function, you must pass an actor to the function. I assumed that you were only concerned with the player, so:

VampireFeedCountPowers(Game.GetPlayer())

If you don't want to have to have to pass an actor for the parameter, you need to rewrite the beginning of your function to something like this:

Function VampireFeedCountPowers()    Actor Player = Game.GetPlayer()
User avatar
remi lasisi
 
Posts: 3307
Joined: Sun Jul 02, 2006 2:26 pm


Return to V - Skyrim