[Papyrus] Unable to getset Global Variables?

Post » Mon Jun 18, 2012 12:12 am

Are Global Variables broken/bugged? They fail to return anything but 0.000 when fed to a messageBox. I've done .getValue/.setValue as well and still got 0.000. The last straw was when I did "float whatever = AkaviriEffect.mod(5)" and it displayed as 0.000 in the message box, despite it being directly set.

Context: This script is attached to a Magic Effect (Enchantment in this case) and is called whenever the weapon strikes another Actor.

This is the script I'm using: http://pastebin.com/f1QCjP1L
User avatar
brandon frier
 
Posts: 3422
Joined: Wed Oct 17, 2007 8:47 pm

Post » Mon Jun 18, 2012 4:43 am

I'm having the same problem man. If that's the case, then I guess Call of Hircine is dead...

UNLESS!!!!

Maybe the script needs to have the Global Variable Extension instead of the quest extension.
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Mon Jun 18, 2012 10:39 am

Maybe the script needs to have the Global Variable Extension instead of the quest extension.
I don't think that's the case. Can you even attach scripts to global variables?

If you want to attach your script to a quest, then it needs to have "Quest" as one of its ancestors.

Cipscis
User avatar
-__^
 
Posts: 3420
Joined: Mon Nov 20, 2006 4:48 pm

Post » Mon Jun 18, 2012 5:45 am

ScriptName YourScript extends WhateverGlobalVariable Property SomeGlobal AutoEvent SomeEvent()	If (SomeGlobal.GetValue() == 1)		SomeGlobal.SetValue(0)	Else;If (SomeGlobal.GetValue() == 0)		SomeGlobal.SetValue(1)	EndIfEndEvent
User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm

Post » Mon Jun 18, 2012 2:33 pm

Global Variable extends from Form, however, so it should be callable from anywhere as all scripts (in some capacity) extend from Form I thought.

Example of Global Variable being get'd and set'd

That's very strange. If it works there, why wouldn't it work here? I'm doing the same thing, just inside a state by comparison?

Maybe it's because I'm trying to call it on a weapon enchantment and maybe global variable registration/modification is slower than 1/sec?
User avatar
Elizabeth Lysons
 
Posts: 3474
Joined: Fri Feb 02, 2007 7:16 am

Post » Mon Jun 18, 2012 12:50 am

I don't think that's the case. Can you even attach scripts to global variables?

If you want to attach your script to a quest, then it needs to have "Quest" as one of its ancestors.

Cipscis


Nope, but there actually is a GlobalVariableScript extension or something like that, specifically for managing global variables, read about it in the wiki, but didn't try it yet, since RegisterForUpdate doesn't work in form scripts.
User avatar
Karen anwyn Green
 
Posts: 3448
Joined: Thu Jun 15, 2006 4:26 pm

Post » Mon Jun 18, 2012 8:26 am

@Justin: I commented out the majority of my code and replaced it with this:


AkaviriCount.Mod(5)
messageBox(AkaviriCount.GetValue())

Why doesn't that return anything but 0? If your code is correct then mine should be messageBoxing 5,10,15,etc as I hit people. It instead only displays 0.
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am


Return to V - Skyrim