Jump to content

Script that increments integer every hour


Recommended Posts

Posted

Can you show me an example script that increments a integer every hour?

 

I want to make an ability that checks every hour if the main character is wearing 4 items with each having a unique keyword. If the resulting check is true then it should increment the skill value by 1.

 

+ can you recommend any good function documentation for papyrus so that I can read on what functions are available?

Posted

Actor proeprty PlayerRef Auto
Keyword Property kw Auto



function start()
 RegisterForSingleUpdate(1.0)
endFunction

Event OnUpdate()
  if playerRef.WornHasKeyword(kw)
    int h = playerRef.getAV("Health")
    playerRef.Positions[num].setAV("Health", h + 1)  endIf
  RegisterForSingleUpdate(3600.0) ; "One hour real time."
EndEvent
Posted
...

Thanks. Now I can't compile the script:

Scriptname tir_rubberSkill   
{manages and advances all bonus skills when wearing only rubber (gloves, boots,catsuit and gasmask)}

Actor property PlayerRef Auto
Keyword Property kw Auto

int h = 0

function start()
 RegisterForSingleUpdate(1.0)
endFunction

Event OnUpdate()
  if (playerRef.WornHasKeyword(tir_MaterialRubber) ) ;&& playerRef.WornHasKeyword(kw) && playerRef.WornHasKeyword(kw) && playerRef.WornHasKeyword(kw)
    h = h+1 
    Debug.MessageBox("LVL up") endIf
  RegisterForSingleUpdate(3600.0) ; "One hour real time."
EndEvent

Here's my compilation output:

Starting 1 compile threads for 1 files...
Compiling "tir_rubberSkill"...
C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\tir_rubberSkill.psc(16,31): required (...)+ loop did not match anything at input 'endIf'
No output generated for tir_rubberSkill.psc, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on tir_rubberSkill.psc
[Finished in 0.6s] 

I'm new to papyrus.

Posted

Just a missing "EndIf"

 

 

Scriptname tir_rubberSkill   
{manages and advances all bonus skills when wearing only rubber (gloves, boots,catsuit and gasmask)}


Actor property PlayerRef Auto
Keyword Property kw Auto


int h = 0


function start()
 RegisterForSingleUpdate(1.0)
endFunction


Event OnUpdate()
  if (playerRef.WornHasKeyword(tir_MaterialRubber) ) ;&& playerRef.WornHasKeyword(kw) && playerRef.WornHasKeyword(kw) && playerRef.WornHasKeyword(kw)
    h += 1 
    Debug.MessageBox("LVL up") endIf
  EndIf
  RegisterForSingleUpdate(3600.0) ; "One hour real time."
EndEvent

 

Posted

 

Just a missing "EndIf"

 

 

Thanks. Now I'm getting this:

Starting 1 compile threads for 1 files...
Compiling "tir_rubberSkill"...
C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\tir_rubberSkill.psc(13,1): RegisterForSingleUpdate is not a function or does not exist
C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\tir_rubberSkill.psc(18,31): variable tir_MaterialRubber is undefined
C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\tir_rubberSkill.psc(22,2): RegisterForSingleUpdate is not a function or does not exist
No output generated for tir_rubberSkill.psc, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on tir_rubberSkill.psc
[Finished in 1.1s]

I already have extracted all the source scripts from the base game in my data folder. 

Posted

You script extends nothing. So the basic functions cannot be used.

 

Were this script is supposed to run? A Magic Effect? And Actor? A Quest?

 

It should be defined something like this:

Scriptname tir_rubberSkill extends Quest

Then you are using a Keyword object "tir_MaterialRubber" but you did not defined the property.

 

Add something like:

keyword Property tir_MaterialRubber Auto

and remember toset up he property to the keyword you want.

 

Let me know.

Posted

 

Let me know.

 

I don't know which script I need to extend. I want to assign the script to an ability or quest .

 

Can extends quest be used as an ability and vice versa?. I want the script to be able to check for the "tir_MaterialRubber" keyword.

 

Don't know if I can directly input the keyword as a function parameter, or have to use a variable as a proxy.

 

Can you explain what "Keyword Property tir_MaterialRubber Auto" actually does? 

C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\tir_rubberSkill.psc(12,0): the return type of function start in the empty state on script tir_rubberskill do not match the parent script quest
Posted

You should know when this function will be called.

 

Right now I do not have enough information to give you help.

 

About the error you posted, it is because a same name function already exists in the object you are extending.

And the object you are extending has some States defined. 

So you need to provide the function for all states.

 

Can you send or post here the full script you are trying to implement, please?

Posted

You should know when this function will be called.

 

Right now I do not have enough information to give you help.

 

About the error you posted, it is because a same name function already exists in the object you are extending.

And the object you are extending has some States defined. 

So you need to provide the function for all states.

 

Can you send or post here the full script you are trying to implement, please?

I want to create a quest that reduces the rubber penalties as time passes by while the player is wearing them.

 

The player receives four abilities that impose penalties (reduced stamina and stamina regen) when the player is wearing an item with the keyword (mask,gloves,boots,catsuit).

 

The integer RubberSkill is increased by 1 every hour If wearing all 4 items.

 

If RubberSkill hits a certain value the quest should update to the next stage and replace the old skills with new ones that have reduced penalties and a new text description (it is easier to breathe in the mask) to signify the change.

 

After the most advanced skills are unlocked the counter should still keep increasing, but after reaching the next stage an erotic scene should play the next time the player is outside of combat.

 

 

I have the quest and abilities prepared in the creation kit but I can't get a handle on the scripting. Don't know what to extend and how to assign the quest stage trigger (rubberskill is certain value).

 

My naive expectation was that I could fit all of this in a single script that I could then reuse and easily modify later.

Posted

Hi.

 

You can have a single script to handle the normal cases, but for sure you need some other scripts here and there to use the functions of your main script.

 

Send me what you have for your mod, I will have a look, and propose to you some structure for your scripts.

 

K.R.,

Archived

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

  • Recently Browsing   0 members

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