Jump to content

EXTREMELY SIMPLE PAPYRUS QUESTION


drmmrdude22

Recommended Posts

Hi everyone! I was hoping someone out there may be kind enough to give me a pointer on why Papyrus HATES what I'm trying to do. Now, I'm relatively new to programming, but if you talk slow I'm pretty sure I can keep up. What I'm attempting to start off doing is simply create a function that adds 2 integers (floats, eventually), and return that value. Then, I want to take the return of that value, and assign it to another value.

 

Scriptname Trials extends ObjectReference

 

int Function AddTwo(int a, int b) global

return a + b

endFunction

 

int x = AddTwo(2,2)

 

Bonus points if you can help me figure out how to do this with using the RandomFloat() function.

 

I truly appreciate it guys! Happy Modding!

Link to comment
Share on other sites

Hi,

From what I see this function makes the sum of the values ​​of a + b and names it "AddTwo".

So everytime you want the sum of a+b you ave only to use the function AddTwo.

int Function AddTwo(int a, int b) global
return a + b
endFunction

 

Is the same as in C++

 

I'm relative new to Papyrus me too but this string seems wrong.

int x = AddTwo(2,2)

 

I would have previously define the Integer:

Int a = 2

Int b = 2

 

int Function AddTwo(int a, int b) global

return a + b

endFunction

 

Int x = AddTwo

 

 

I hope to have help you

Link to comment
Share on other sites

I'm relative new to Papyrus me too but this string seems wrong.

int x = AddTwo(2,2)

 

Nope, it's perfectly correct. What is wrong is that this statement cannot be called outside of an event block or function :tongue: .

 

Scriptname Trials extends ObjectReference

int Function AddTwo(int a, int b) global
    return a + b
endFunction

Event OnInit()
   int x = AddTwo(2,2) 
   debug.trace("The answer is " + x)
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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