Jump to content

Quick Questions, Quick Answers


Mattiewagg

Recommended Posts

A few things to note:

 

When posting scripts, you may want to enclose them within

[code][/code]

tags, with your script being in between the code (or just click the <> button in the toolbar and paste your script). This retains spaces in scripts and helps with readability.

 

Secondly:

 

This line:

convertGoldValue.setValue((myGoldValue as Float))

Could be this, if you wanted:

convertGoldValue.SetValueInt(myGoldValue as Float)

Though the other method should work just as well.

 

Thirdly:

 

Why does your function have the

Return

part? You only need to return something when it is actually meant to return a value. You can remove that line.

Link to comment
Share on other sites

  • Replies 2.6k
  • Created
  • Last Reply

Top Posters In This Topic

A few things to note:

 

When posting scripts, you may want to enclose them within

[code][/code]

tags, with your script being in between the code (or just click the <> button in the toolbar and paste your script). This retains spaces in scripts and helps with readability.

 

Secondly:

 

This line:

convertGoldValue.setValue((myGoldValue as Float))

Could be this, if you wanted:

convertGoldValue.SetValueInt(myGoldValue as Float)

Though the other method should work just as well.

 

Thirdly:

 

Why does your function have the

Return

part? You only need to return something when it is actually meant to return a value. You can remove that line.

I will be sure to use the <> button next time I post any script/script fragment.

I changed the mentioned line to:

convertGoldValue.SetValueInt(myGoldValue)

since the myGoldValue property is, as mentioned, and integer already.

I'm used to other programming languages, and have always had it drilled into my head that you always put a return, even if it isn't actually returning anything.

Link to comment
Share on other sites

 

A few things to note:

 

When posting scripts, you may want to enclose them within

[code][/code]

tags, with your script being in between the code (or just click the <> button in the toolbar and paste your script). This retains spaces in scripts and helps with readability.

 

Secondly:

 

This line:

convertGoldValue.setValue((myGoldValue as Float))

Could be this, if you wanted:

convertGoldValue.SetValueInt(myGoldValue as Float)

Though the other method should work just as well.

 

Thirdly:

 

Why does your function have the

Return

part? You only need to return something when it is actually meant to return a value. You can remove that line.

I will be sure to use the <> button next time I post any script/script fragment.

I changed the mentioned line to:

convertGoldValue.SetValueInt(myGoldValue)

since the myGoldValue property is, as mentioned, and integer already.

I'm used to other programming languages, and have always had it drilled into my head that you always put a return, even if it isn't actually returning anything.

 

As far as I know, there's no reason to do that for Papyrus, correct me if I'm wrong. I've only worked a bit with other programming language - some Python, a touch of JavaScript. And of course, the barely programming language that was TESScript.

Link to comment
Share on other sites

As far as I know, there's no reason to do that for Papyrus, correct me if I'm wrong. I've only worked a bit with other programming language - some Python, a touch of JavaScript. And of course, the barely programming language that was TESScript.

 

 

I don't know if it's necessary for Papyrus, but assuming from the fact that it compiles without error if I take it out or if I leave it, I assume it doesn't really matter. I've used some C++, Java, and Javascript.

 

But getting back to my problem... What exactly am I doing wrong with these scripts? They compile correctly and, as far as I can tell, should work correctly... but in-game my button never returns a value other than 0 so...

Link to comment
Share on other sites

 

As far as I know, there's no reason to do that for Papyrus, correct me if I'm wrong. I've only worked a bit with other programming language - some Python, a touch of JavaScript. And of course, the barely programming language that was TESScript.

 

 

I don't know if it's necessary for Papyrus, but assuming from the fact that it compiles without error if I take it out or if I leave it, I assume it doesn't really matter. I've used some C++, Java, and Javascript.

 

But getting back to my problem... What exactly am I doing wrong with these scripts? They compile correctly and, as far as I can tell, should work correctly... but in-game my button never returns a value other than 0 so...

 

Oh, yeah, back to that.

 

You have an issue where you never define the GlobalVariable convertGoldValue (as a property) in your activator script. I'm surprised that even compiled. And you should use GetValueInt instead.

 

And fill all your properties.

Link to comment
Share on other sites

 

 

As far as I know, there's no reason to do that for Papyrus, correct me if I'm wrong. I've only worked a bit with other programming language - some Python, a touch of JavaScript. And of course, the barely programming language that was TESScript.

 

 

I don't know if it's necessary for Papyrus, but assuming from the fact that it compiles without error if I take it out or if I leave it, I assume it doesn't really matter. I've used some C++, Java, and Javascript.

 

But getting back to my problem... What exactly am I doing wrong with these scripts? They compile correctly and, as far as I can tell, should work correctly... but in-game my button never returns a value other than 0 so...

 

Oh, yeah, back to that.

 

You have an issue where you never define the GlobalVariable convertGoldValue (as a property) in your activator script. I'm surprised that even compiled. And you should use GetValueInt instead.

 

And fill all your properties.

 

I did define the global variable in the button script... must have pasted my button script before making the changes, my bad. I also changed it to use the GetValueInt() function instead. Still no joy in game... nothing but 0 gets returned still. Maybe the properties aren't filled correctly... going to check that.

Link to comment
Share on other sites

I decided to just make it so the chest itself will tell you the gold value of the items inside on close, instead of pushing a button to get the message. Seems to work fine.

Event OnClose(ObjectReference akActionRef)
     Debug.MessageBox("The items in the chest are worth " + myGoldValue + " gold.")
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...