Jump to content

[LE] I need help to make a script


Recommended Posts

Create a script on the book as follows:

 

GlobalVariable Property YourGlobalName Auto
Bool bIsRead = False

Event OnRead()
   If ! bIsRead
      YourGlobalName.SetValue(YourValue)
      bIsRead = true
   EndIf
EndEvent
Edited by B1gBadDaddy
Link to comment
Share on other sites

Create a script on the book as follows:

 

GlobalVariable Property YourGlobalName Auto
Bool bIsRead = False

Event OnRead()
   If ! bIsRead
      YourGlobalName.SetValue(YourValue)
      bIsRead = true
   EndIf
EndEvent

 

I actually have a problem with this...

I made a similar mod (about a spell) and the variable "bIsRead" is tricky, here's why (this might not be true for this code!!!):

Whenever the script stops running, the value of "bIsRead" is lost because it's a local variable.

I have tried doing this as an ActiveMagicEffect though, so it might be different for ObjectReference.

My suggestion is you implement this script but add a notification to pop up right below the line

YourGlobalName.SetValue(YourValue) 

After that, try to open and close the book multiple times (with different intervals) and see if the notification pops up only on the first try.

If not - you'll need another global variable instead.

 

Just wanted to make a small point just in case :D

Link to comment
Share on other sites

I make This:

 

Scriptname AprenderReceita extends ObjectReference

 

GlobalVariable Property Receita Auto

Float Property Aprender Auto

Bool bIsRead = False

 

Event OnRead()

If ! bIsRead

Receita.SetValue(Aprender)

bIsRead = true

EndIf

EndEvent

 

But "Receita" don't recive "Aprender"

Edited by Michaellok
Link to comment
Share on other sites

I make This:

 

Scriptname AprenderReceita extends ObjectReference

 

GlobalVariable Property Receita Auto

Float Property Aprender Auto

Bool bIsRead = False

 

Event OnRead()

If ! bIsRead

Receita.SetValue(Aprender)

bIsRead = true

EndIf

EndEvent

 

But "Receita" don't recive "Aprender"

Are the properties set in the CK section for the properties on the script? Is the reference of the book you're trying to read a new one or one already spawned in the save? Note only new spawns of the object will have the script. Spawns that exist prior to loading the mod which adds the script will not have it. Lastly do you get any errors in the papyrus log?

Link to comment
Share on other sites

 

Create a script on the book as follows:

Â

GlobalVariable Property YourGlobalName Auto
Bool bIsRead = False

Event OnRead()
   If ! bIsRead
      YourGlobalName.SetValue(YourValue)
      bIsRead = true
   EndIf
EndEvent
Â

I actually have a problem with this...

I made a similar mod (about a spell) and the variable "bIsRead" is tricky, here's why (this might not be true for this code!!!):

Whenever the script stops running, the value of "bIsRead" is lost because it's a local variable.

I have tried doing this as an ActiveMagicEffect though, so it might be different for ObjectReference.

My suggestion is you implement this script but add a notification to pop up right below the lineÂ

YourGlobalName.SetValue(YourValue)Â 
After that, try to open and close the book multiple times (with different intervals) and see if the notification pops up only on the first try.

If not - you'll need another global variable instead.

Â

Just wanted to make a small point just in case :D

With object references the variable will stick around forever unless it's reset by something else. Magic effects are different :)

Link to comment
Share on other sites

Even if the variable is lost it doesn't matter. It will just set the global again to the value it already has, this happening only the first time you read it after it was reseted. How many times is the player going to read the book? This scenario is not really a problem.

 

I'm not 100% sure but if the object isn't a persistent reference I don't think the variable will stick forever. But as said above it doesn't matter.

Edited by FrankFamily
Link to comment
Share on other sites

 

I make This:

 

Scriptname AprenderReceita extends ObjectReference

 

GlobalVariable Property Receita Auto

Float Property Aprender Auto

Bool bIsRead = False

 

Event OnRead()

If ! bIsRead

Receita.SetValue(Aprender)

bIsRead = true

EndIf

EndEvent

 

But "Receita" don't recive "Aprender"

Are the properties set in the CK section for the properties on the script? Is the reference of the book you're trying to read a new one or one already spawned in the save? Note only new spawns of the object will have the script. Spawns that exist prior to loading the mod which adds the script will not have it. Lastly do you get any errors in the papyrus log?

I spawned a book using the console, but the script din't work.

Edited by Michaellok
Link to comment
Share on other sites

  • Recently Browsing   0 members

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