Orvid / Caprica

A compiler for the Papyrus scripting language used by the Creation Engine.
MIT License
84 stars 15 forks source link

Script Wide Variables issue #4

Closed KarmaPenny closed 8 years ago

KarmaPenny commented 8 years ago

It appears that using script wide variables causes the script to not function. It compiles without error but when called in game will not perform any action.

You can actually de-compile a working vanilla script that contains a script wide variable then recompile it without making any changes and it will no longer function.

Here is an example that compiles but does not function

const ScriptName Broken extends ObjectReference

;-- Script Wide Variables ---------------------------------------
int test = 0

Function OnInit()
    test = 5
    Debug.Notification("This text never appears")
EndFunction

Remove the script wide variable and suddenly it does work

const ScriptName Broken extends ObjectReference

Function OnInit()
    Debug.Notification("This text does appears")
EndFunction
Orvid commented 8 years ago

Do you have the specific script you were encountering this issue in? There should be no issues with it, but you are using a const on the ScriptName value, which I don't actually know the use of at the moment.

SilverIce commented 8 years ago

Maybe const means immutable script instance? Then it's not weird as test = 5 attempts to modify it, but I doubt that the code should be compile-able

KarmaPenny commented 8 years ago

I'll create an example mod for you when I get a chance. On Feb 25, 2016 8:24 PM, "SilverIce" notifications@github.com wrote:

Maybe const means immutable script instance? Then it's not weird as test = 5 attempts to modify it, but I doubt if the code should be compile-able

— Reply to this email directly or view it on GitHub https://github.com/Orvid/Caprica/issues/4#issuecomment-189070361.

KarmaPenny commented 8 years ago

Going to be out of town this weekend so probably won't be until next week On Feb 25, 2016 9:33 PM, "Cole Robinette" robinette.31@gmail.com wrote:

I'll create an example mod for you when I get a chance. On Feb 25, 2016 8:24 PM, "SilverIce" notifications@github.com wrote:

Maybe const means immutable script instance? Then it's not weird as test = 5 attempts to modify it, but I doubt if the code should be compile-able

— Reply to this email directly or view it on GitHub https://github.com/Orvid/Caprica/issues/4#issuecomment-189070361.

KarmaPenny commented 8 years ago

Hmm actually I just tried things without that const flag and it appears to be working. Sorry about that. The const flag came from one of the vanilla scripts I copied and I didn't notice it at all. On Feb 25, 2016 9:43 PM, "Cole Robinette" robinette.31@gmail.com wrote:

Going to be out of town this weekend so probably won't be until next week On Feb 25, 2016 9:33 PM, "Cole Robinette" robinette.31@gmail.com wrote:

I'll create an example mod for you when I get a chance. On Feb 25, 2016 8:24 PM, "SilverIce" notifications@github.com wrote:

Maybe const means immutable script instance? Then it's not weird as test = 5 attempts to modify it, but I doubt if the code should be compile-able

— Reply to this email directly or view it on GitHub https://github.com/Orvid/Caprica/issues/4#issuecomment-189070361.

Orvid commented 8 years ago

Well, if I was letting you compile without errors then that's an issue, I'll check and see what adding that as an error does.

Orvid commented 8 years ago

Trying to do this will now produce an error when you try to assign to a value on a const script.