Jump to content

[LE] Which one works faster in a Script ?.


Recommended Posts

Has been tested to death in the past. PlayerRef is 1000x faster

 

Is that really suprise?

 

Actor Property QPlayer Auto

{ Player Ref. }

 

When need in Script what game do:

- ask to acces for memory

 

Game.GetPlayer()

 

When need in script what game do:

- create return and generate self

- do Function stuff

- recive pointer to Player

- return pointer

- clear stack

 

 

Also when you call Function this function may call even more functions

 

 

C++

; define just replace this on left with this on right, in short :o

#define add(a,b) (a) + (b)

 

; new function that make his own return and 2 ints then move them to stack

; waste time to create "s***" on stack and also waste memory :x... cause a and b takes 2x more memory than need

int add(int a,int b){return a+b;}

 

 

//Edit:

{

IN SHORT:

}

 

want to save memory? -> Use Functions

want to save power? -> Use Variables

 

ALWAYS !...

Edited by TobiaszPL
Link to comment
Share on other sites

If it weren't for the framelinking there wouldn't be particularly noticeable differences, TBH. There's a bit of overhead in function calls just generally, but very, very few Papyrus scripts need to be optimized that tightly for performance. In most cases even Game.GetPlayer() would be fine, too.

 

Performance issues really only start to come into play when you're doing either a lot of processing or have something that needs to happen with as little latency as possible; inventory manipulation is a common example of both.

Link to comment
Share on other sites

Has been tested to death in the past. PlayerRef is 1000x faster than Game.GetPlayer(). Also the 'convenience' functions are only convenient in typing speed. GetActorRef -> GetReference() as Actor(), and GetActorReference -> GetActorRef -> GetReference() as Actor. Yes the game will go through all of those steps, so you can see why those kinds of functions aren't very good in practice.

 

Function calls generally are bad when they are called more than necessary. When you expect their values to change throughout a script it's ok to keep using them, otherwise assign to a variable.

So, if a script, or in my case three Scripts (they are communicating through a controller Script), calls for the "Game.GetPlayer()" multiple times to fire each Script's Functions (play each script's FX > while > exchanging each script Player's AV + each script accessing his inventory), is 1000x times better to replace it with a "PlayerREF", so that nothing gets overlap and plays - executes in the order that is was created to.

(this is just a concern of mine for Slower PCs).

Link to comment
Share on other sites

If you're just using it once, in an initialization routine, that's fine. I do that sort of thing a lot, especially for scripts I'm going to make a lot of copies of (e.g. on aliases). Putting it in a loop is bad mojo: It won't ever change, so there's no need to keep checking it. Stuff it in a variable and access that.

 

EDIT:

 

If you need more specific advice, I'd suggest giving code samples.

Edited by foamyesque
Link to comment
Share on other sites

Thanks foamyesque for the advice.

But, there is no need anymore to post my scripts, i Simplified - Optimize things even further.


1st) In the beginning it was one Activator and one HUGE Script with a big options Menu with a lot of sub - options & sub sub - options.


2nd) After first Optimization, i ended up with three Activators - three Scripts - one Controller Script, which each script had a 3 options Menu, which later on i added a 6 sub - options menu to each one of the options.


3rd) Then i realized that all of this is still too complicated and not user friendly enough (too much stuff going on...).


Final :

Now they all work just like VENDORS, more elegant, not complicated anymore and completely user friendly, what ever the Player wants to "Buy - Exchange" will go to the corresponding vendor, and choose from the options given to him, from 3 to 5, depending on the activator with NO sub - Options.

Three Scripts with No Controller Script and NO Communication between them - " exchange ".


1 Script 1 Activator for " Perks for Dragonsouls ".

1 Script 3 Activators for each " Health, Stamina, Magicka for Filled Black Souls Gems ".

1 Script 18 Activators for each " Skill for Gold ".

(And probably i will make a fourth one to sell - exchange AV for Gold and - or Filled Black Souls and - or Dragon Souls = Buy Back).


* All of this conversation that took place here was very educational !.


* I still had the option to just make one script for all ( Global Script ), but then i would have to add a bunch of different " Int & Float Properties ", and intentional give myself a headache in trying to fill them correctly...


* Still if you want me to post the script, i will, but they are now very simple - small scripts (nothing impressive).


Have a great summer all of you !.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...