Jump to content

Is it possible in Papyrus to reference a variable with a string identifier?


Recommended Posts

Afaik, you can assign values to the properties within the script without needing to set them in CK via the Property dialog.

 

For example,

 

float Property my_float = 10.5 auto

string Property my_string = "just testing" auto

I just did a quick test and added the above to a script and it compiled, at least, so I think it should work. NB. I use Caprica to compile all my Papyrus scripts, so it might be a compiler-dependent feature?

 

As for the large IF statement, would switch-case statements be useful to you? The Caprica compiler supports switch-case statements.

 

 


Switch

The Switch statement may only be used on an Int or String, and the case values must be literals.

<switch> ::= 'Switch' <expression>               ['Case' (<integer>|<string>)                 <statement>*]*               ['Default'                 <statement>*]             'EndSwitch'
Link to comment
Share on other sites

Ehm.... excuse me... what!? We have switch statements? Shame on me for not knowing, that there is a compiler that can handle this, lol.

 

Oh gosh! And so much more! Wow...

 

Thanks for pointing that out!

Link to comment
Share on other sites

 

Afaik, you can assign values to the properties within the script without needing to set them in CK via the Property dialog.

 

For example,

 

float Property my_float = 10.5 auto

string Property my_string = "just testing" auto

 

I just did a quick test and added the above to a script and it compiled, at least, so I think it should work. NB. I use Caprica to compile all my Papyrus scripts, so it might be a compiler-dependent feature?

 

As for the large IF statement, would switch-case statements be useful to you? The Caprica compiler supports switch-case statements.

 

 

Switch

The Switch statement may only be used on an Int or String, and the case values must be literals.

<switch> ::= 'Switch' <expression>               ['Case' (<integer>|<string>)                 <statement>*]*               ['Default'                 <statement>*]             'EndSwitch'

 

 

Thank you.

 

The settings get populated from XML after load. So, I don't really need to populate them in their declaration like that. The issue is that, from my experience, when you add/change/remove properties on a script, you have to go into the properties panel in CK for it to do some sync with the esp/esm and re-save that.

 

But, maybe Caprica somehow handles that part too? Haven't used it.

 

For Switch, is that creating a real switch statement? Or, is Caprica just using that syntax and then turning it into an If statement for the Papyrus compiler?

Link to comment
Share on other sites

Ehm.... excuse me... what!? We have switch statements? Shame on me for not knowing, that there is a compiler that can handle this, lol.

 

Oh gosh! And so much more! Wow...

 

Thanks for pointing that out!

 

Yeah man, TIL. What the hell. I thought ifelse was Papyrus' way of doing switch/case.

 

Now someone needs to come around and tell us there's push() and pop() in Papyrus.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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