addremove vanillacustom perk

Post » Sat Nov 17, 2012 12:02 am

If my diagnosis of the problem is correct, and the problem is due to Game.GetPlayer() taking some time to execute, then that while loop may well cause the function to be called multiple times, as the next iteration of the loop would run before the first instance of the function returns.

Cipscis
User avatar
Charles Weber
 
Posts: 3447
Joined: Wed Aug 08, 2007 5:14 pm

Post » Sat Nov 17, 2012 7:06 am

ok, I will put in a counter and see how many loops I get as a test. Thanks.


Edit:


While PlayerRef == none || PlayerRef.gettype() != 62
; || !Playerref.haskeyword(actortypeNPC) ;kCharacter = 62
PlayerRef = game.GetPlayer()
run = run + 1
endwhile

debug.messagebox(run)


well... I only get a 1 count each time I load the game. :shrug:

But this was in one of my other scripts, the issue I was having was in a quests start up script in an OnInt block. I did not do it there because I had already changed all the ref to Game.getplayer().Addperk(). So I did not need it there. But I will try the test there as well latter.


If my diagnosis of the problem is correct, and the problem is due to Game.GetPlayer() taking some time to execute, then that while loop may well cause the function to be called multiple times, as the next iteration of the loop would run before the first instance of the function returns.

Cipscis
User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am

Post » Sat Nov 17, 2012 8:17 am

Well it is not a matter of how fast it is, because I only do it ONCE in the script.

But per the thread : http://www.gamesas.com/topic/1360171-playerref-gamegetplayer-or-do-it-in-properties/page__view__findpost__p__20520338
There was at the time a question about the reliability of using a property, and a danger of making actors persistent as well (for other actors, not the player).

However if there is no question NOW that the Player ref can change then I will "start" to use that now. But I am not going back over 50 scripts and making that change when I can just paste in:


While PlayerRef == none || PlayerRef.gettype() != 62
PlayerRef = game.GetPlayer()
endwhile

And this will NOT be run over and over and over UNLESS PlayerRef = game.GetPlayer() refuses to get the player. If that happens I have bigger issues than the script slowing down.

I was wrong about what SmkViper said, I think I was thinking about how THERE ARE NO BETHESDA SCRIPTS (that I have found so far) that use a property, they all use getplayer()
Well, PlayerREF "Prisoner" [ACHR:00000014] is already persistent and always loaded. Property never failed me. You can, with Sublime Text 2/N++, search/replace across multiple documents... Makes editing en masse a cinch.

No Beth scripts using the property: That's a shame given how much cheaper a property has proven to be.
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Sat Nov 17, 2012 1:24 am

I just managed to find 'PlayerRef' without any plugins loaded when selecting an alias for a Reference Alias. As I expected, here's what it says:
Ref: 'PlayerRef' (00000014) to NPC_ 'Player' (00000007)

To me, at least, this pretty much confirms that the player's reference is hard-coded and never changes.

Cipscis
User avatar
Svenja Hedrich
 
Posts: 3496
Joined: Mon Apr 23, 2007 3:18 pm

Previous

Return to V - Skyrim