How do you compare with a Global Variable?

Post » Wed Jun 20, 2012 12:36 am

So, I have these global variables that are set through a small fragment in dialogue to a value of 0-3. I need a script to decide basically, what is the value of that number. Problem is, I can't seem to compare global variables to numbers...even though globals are numbers. Here is my script.

Scriptname PKRoseLevel extends Actor GlobalVariable Property PKMoveSlotNum  Auto SPELL Property Absorb  Auto SPELL Property MegaDrain  Auto SPELL Property Growth  Auto SPELL Property StunSpore  Auto SPELL Property PoisonSting  Auto SPELL Property MoveSlot1  Auto SPELL Property MoveSlot2 Auto SPELL Property MoveSlot3  Auto SPELL Property MoveSlot4  Auto ;This decides what move should be learned by the pokemon based upon the current level of the ;player.Spell Function newMove()   if Game.GetPlayer().GetLevel() == 4	  return Growth   endIf   if Game.GetPlayer().GetLevel() == 7	  return PoisonSting   endIf   if Game.GetPlayer().GetLevel() == 10	  return StunSpore   endIf   if Game.GetPlayer().GetLevel() == 13	  return MegaDrain   endIfendFunction;This next code decides, based upon what dialogue choice the player has chosen (each corresponding ;to a spell slot) which has set a global variable to a value of 0-3. These comparisons are the problem.Spell Function oldMove()   if PKMoveSlotNum == 0	  return MoveSlot1   endIf   if PKMoveSlotNum == 1	  return MoveSlot2   endIf   if PKMoveSlotNum == 2	  return MoveSlot3   endIf   if PKMoveSlotNum == 3	  return MoveSlot4   endIfendFunction;This actually handles forgetting the move chosen by the player (unless it is an empty slot) and adding ;the new move. It also updates the scripts properties to have the moveslots filled correctly.Function LearnMove()   if(oldMove() != None)	  self.RemoveSpell(oldMove())   EndIf      self.AddSpell(newMove())   if PKMoveSlotNum == 0	 MoveSlot1 = newMove()   endIf   if PKMoveSlotNum == 1	 MoveSlot2 = newMove()   endIf   if PKMoveSlotNum == 2	  MoveSlot3 = newMove()   endIf   if PKMoveSlotNum == 3	  MoveSlot4 = newMove()   endIfEndFunction


and I get this error over and over again


c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(37,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(40,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(43,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(46,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(56,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(59,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PKRoseLevel.psc(62,20): cannot compare a globalvariable to a int (cast missing or types unrelated)
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temelated)p\PKRoseLevel.psc(65,20): cannot compare a globalvariable to a int (cast missing or types unr

Anyone know how to change my syntax or whatever so make this do what I'm trying to do?
User avatar
Joey Avelar
 
Posts: 3370
Joined: Sat Aug 11, 2007 11:11 am

Post » Tue Jun 19, 2012 10:28 pm

Instead of:
if PKMoveSlotNum == 0

just use:
if PKMoveSlotNum.GetValue() == 0


Global variables need SetValue(x), GetValue() functions to change or retreive their values.
And also make sure you properly assigned your globalvariable in Properties Window!
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Wed Jun 20, 2012 7:02 am

Instead of:
if PKMoveSlotNum == 0

just use:
if PKMoveSlotNum.GetValue() == 0


Global variables need SetValue(x), GetValue() functions to change or retreive their values.
And also make sure you properly assigned your globalvariable in Properties Window!

Thanks, I knew that I'm just being dumb today.
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm


Return to V - Skyrim