Jump to content

How do I efficiently run this script?


Guest

Recommended Posts

Posted

So this is the script I am running.

Basically as soon as the player interacts with the activator "everything turns on"

 

ObjectReference Property DweWallSconceSmall01 Auto
ObjectReference Property DweWallSconceSmall01On Auto
ObjectReference Property DweLightFireLamp01 Auto
 
Event OnActivate(ObjectReference akActionRef)
If akActionRef == Game.GetPlayer()
DweWallSconceSmall01.Disable()
DweWallSconceSmall01On.Enable()
DweLightFireLamp01.Enable()
 
EndIF
 
EndEvent
 
Problem this is only for one room. I have 24 rooms divided amongst 4 activators which means the player can turn on the lights or turn them off. Obviously I got other things like traps, flame throwers and etc linked to these activators but the lights seem to be problematic. I got 1 of the rooms with this script but I cant add other rooms and when I turn on lights I cant turn them off. (initially disabled).
Suggestions?
Posted

One big improvement is to avoid the call Game.getPlayer()

Then it depends on what you are trying to do.

 

 

ObjectReference Property DweWallSconceSmall01 Auto
ObjectReference Property DweWallSconceSmall01On Auto
ObjectReference Property DweLightFireLamp01 Auto
Actor Property PlayerRef Auto
 
Event OnActivate(ObjectReference akActionRef)
  If akActionRef == PlayerRef
    DweWallSconceSmall01.Disable()
    DweWallSconceSmall01On.Enable()
    DweLightFireLamp01.Enable()
  EndIF
EndEvent
 

 


But I am not really sure about what the problem is.

 

The lights do not "activate"?

It is complex (tedious) to do it for 24 cells?

 

Give me some clues and I will try to help.

Posted

Isn't this where that "Enable state Opposite To Parents" flag for references come in handy?

 

Not too sure, though; haven't dabbled with that.

 

@CPU, when would Game.GetPlayer() be better to use than a player property? Far as I can tell, it never is; the player is persistent by nature, so it doesn't matter if a property is referencing the player, no?

Posted

Isn't this where that "Enable state Opposite To Parents" flag for references come in handy?

 

Not too sure, though; haven't dabbled with that.

 

@CPU, when would Game.GetPlayer() be better to use than a player property? Far as I can tell, it never is; the player is persistent by nature, so it doesn't matter if a property is referencing the player, no?

 

Did a huge amount of profiling of many function.

Get.Player() is about 500 times slower than the equivalent property.

 

Check this: http://www.loverslab.com/blog/232/entry-1086-optimize-your-scripting/

Posted

 

Did a huge amount of profiling of many function.

Get.Player() is about 500 times slower than the equivalent property.

 

Check this: http://www.loverslab.com/blog/232/entry-1086-optimize-your-scripting/

 

 

Oh, don't get me wrong. I've read up on the subject, and I never use Game.GetPlayer(); I've even cracked open a few mods and manually added in PlayerRef properties to the scripts 'n' set 'em up right. Did that with Katixia's Usable Barrels and More Complex Needs.

 

It's just that I've seen a couple people advocating Game.GetPlayer() instead of a PlayerRef property. Most notably, I inquired about Apollodown's frequent use of Game.GetPlayer(), with him responding that he has his reasons. Was just wonderin' if you know of any situation where Game.GetPlayer() is the preferred method.

Posted

 

It's just that I've seen a couple people advocating Game.GetPlayer() instead of a PlayerRef property. Most notably, I inquired about Apollodown's frequent use of Game.GetPlayer(), with him responding that he has his reasons. Was just wonderin' if you know of any situation where Game.GetPlayer() is the preferred method.

 

 

I don't.

I can also say that Game.getPlayer() makes the script to last longer in memory (and so in saves) for some reasons.

Probably the temporary "Actor" that is created when you call this function is not release by the Papyrus VM garbage collector.

But this is only a guess.

Posted

 

I don't.

I can also say that Game.getPlayer() makes the script to last longer in memory (and so in saves) for some reasons.

Probably the temporary "Actor" that is created when you call this function is not release by the Papyrus VM garbage collector.

But this is only a guess.

 

 

Sweet. Might as well go over the rest of me mods and check for any performance drops due to that lil' line. Tah for the info, milawdship.

 

@OP Sorry for hijackin' yer thread. I'll show myself out.

Posted

Lol its fine, basically this is the first script I have tried making and honestly I got it from a tutorial.

Anyway I got 3 properties that I manually linked via CK but I got 24 rooms and each has 3 properties.

I cant seem to be able to add more properties by repeating the first 3 lines and the manual property option confuses me.

 

Anyway what I want is DweLight and Lamp_On to appear when activator is activated and Lamp_Off to consequently go invisible/disabled.

If the player, me, uses the activator again; the traps are again disabled as desired but the Lamp_On and DweLight remain visible instead of being disabled. (basically the lamp stays on)

 

I even have plans to add steam coming out of the various pipes as soon as the activator is activated.

 

Imagine an engine room that you can turn on and off and lots of traps and ambushes are dependent on the activator being activated. If not then everything is turned off. The Dwemer Piston (the thing that pushes you) I also need to find the script in CK that makes it turn on and then link it to Dwemer Button activator to either turn the piston on and off (to unblock the door to final room).

 

I hope you better understand what I want to achieve now.

Posted

Hello.

 

What is the object you are using for this script?

A trigger? A specific Activator?

 

In both cases (and also other cases) you can define your script once for the object definition (the actual trigger, for example.)

Add generic property names.

And then when you do a reference of the object, by putting it in your 24 cells, you can set the properties specific for each cell on the same script.

 

So, something like:

* Define the activator (theGenericActivator)

* Add to it a script (theGenericActivatorScript)

* Put in this script the properties (theLight, theSconce01, theSconce02): Do Not set values for the properties

* Drag the activator in your cell, edit it in the cell (you are editing the reference in this case)

* Set the properties in the script of the reference.

 

Posted

The activator is an existing one. Its the dewmer valve switch.

As for the rooms, they are not in seperate cells but in the same cell. By room i meant different areas of the same cell.

Posted

My advice: duplicate it.

So the code behind can be defined on the main object, and the properties set on the references.

Posted

Alright then.

Works now so perfect. Thanks!

 

Another question so I dont make a dozen.

I have these spear traps but I want to be deployed every 3 seconds instead of being activated only once if player presses a pressure plate/activator.

 

What kind of script should I make so these spears activate every 2 or 3 seconds once the player activates the activator?

Posted

In the code that handles the activator, add a RegisterForSingleUpdate(Utility.randomFloat(2.0, 3.0))

 

And then add:

 

ObjectReference[] Property theSpikes Auto
 
Event OnUpdate()
 
  int num = theSpikes.length
  while num
    num -= 1
    theSpikes[num].activate() ; "<--- just sample, not sure what you mean for 'activate'"
  endWhile
  if (self as Activator).isActive() "<--- just sample, not sure what defined 'active-status' for your activator"
   RegisterForSingleUpdate(Utility.randomFloat(2.0, 3.0))
  endIf
EndEvent

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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