How would one get a property to return the time of day?

Post » Mon Jun 18, 2012 9:19 am

Hello, I'm having a bit of a problem with my script. Its been a big hassle, trying to get everything working and compiling, but I've finally started to narrow things down (largely thanks to the discovery of debug notifications). Apparently, the code I'm using to return the time of day (as a rounded integer) isn't working,seeing as its spamming me with notifications that cohCanTransform is false (as expected, since this block of the script is part of an OnUpdate() event), even after 9:00 PM, which means it isn't working for whatever reason. I'm really at a loss for what I should do, all the syntax is correct, the global variable is, to my knowledge right, and I can't see anything that's preventing it from ever returning

    GlobalVariable Property GameHour auto; irrelevant stuff goes here; the event initialization goes here.    int timeOfDay = GameHour.GetValueint(); large amounts of intermittent code goes here.  If TimeOfDay > 20 || TimeOfDay < 6    cohCanTransform == trueelse	    cohCanTransform == falseendifif cohCanTransform == truedebug.notification("cohct is true")elsedebug.notification("cohct is false")endif
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Mon Jun 18, 2012 6:49 am

Just a quick suggestion - try outputting your "timeOfDay" variable in your debug notification.

Cipscis
User avatar
sarah
 
Posts: 3430
Joined: Wed Jul 05, 2006 1:53 pm

Post » Sun Jun 17, 2012 5:11 pm

Ah, didn't think of that one. Trying that now.
User avatar
Ashley Hill
 
Posts: 3516
Joined: Tue Jul 04, 2006 5:27 am

Post » Mon Jun 18, 2012 1:57 am

Aha, here we go. It keeps returning as zero, regardless of the actual time of day. Any idea what's wrong here?
User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Mon Jun 18, 2012 9:16 am

Try returning it as a float, perhaps something's going wrong when it's being cast to an int?

Cipscis
User avatar
Tyler F
 
Posts: 3420
Joined: Mon Aug 27, 2007 8:07 pm

Post » Mon Jun 18, 2012 2:09 am

It's not working unfortunately, however, I've just had an idea: I'll test the other globals to see if somethings wrong with the syntax I've used to import the globals.
User avatar
Sophie Louise Edge
 
Posts: 3461
Joined: Sat Oct 21, 2006 7:09 pm

Post » Mon Jun 18, 2012 6:39 am

And it seems we have a winner. PlayerIsWerewolf is also returning as 0 in the debug notification, for reasons unknown. Obviously I'm calling or definiing the global variables wrong, since PlayerIsWerewolf returns as 1 when console commands are used on this savegame (in which the player is indeed a werewolf.)


said variable was called via this line

GlobalVariable Property PlayerIsWerewolf auto

and referenced in this manner by several variations of this line.

  if ( PlayerIsWerewolf.GetValue() == 1 && cohCanTransform == true ) && IsFirstChange == true && game.getplayer().HasMagicEffect(Werewolf) == 0 
User avatar
sarah simon-rogaume
 
Posts: 3383
Joined: Thu Mar 15, 2007 4:41 am

Post » Mon Jun 18, 2012 1:48 am

Oh, just a sec, isn't the correct type "Global", not "GlobalVariable"?

Cipscis
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Sun Jun 17, 2012 9:13 pm

Let's find out...Though wouldn't it return an error if GlobalVariable wasn't valid?
User avatar
Batricia Alele
 
Posts: 3360
Joined: Mon Jan 22, 2007 8:12 am

Post » Mon Jun 18, 2012 4:49 am

Yeah, that's what I'd thought. It's unfortunate that I don't have access to the Creation Kit at the moment, so I can't check any of this stuff myself.

Cipscis
User avatar
Hot
 
Posts: 3433
Joined: Sat Dec 01, 2007 6:22 pm

Post » Sun Jun 17, 2012 10:08 pm

Actually, GlobalVariable is correct, and it returns an error when you use Global. Thanks for all the help by the way...

Maybe I need to refer to the GlobalVariables by their editor ID or something?
User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Sun Jun 17, 2012 11:49 pm

I think something like this might actually be it; I put the line

MagicEffect Property si0ghjdfguhjdfgojsdhfg9he38ghe9rghe9r8ghj auto

into the script, and it still compiled successfully; obviously it doesn't care if the global variables you're referring to are valid.

except that its not since all the global variable's editor IDs match their description.

Someone please tell me this isn't a glitch that Bethesda was too lazy to fix? Has anyone else made a script which successfully references global variables that aren't always zero?


Of course, something to note is that the commands for retrieving global variables are part of the GlobalVariable script extension...I really, really, really hope that its possible to use those commands in a quest script...
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm

Post » Mon Jun 18, 2012 1:26 am

Oh, have you not been assigning the property's value in the Creation Kit? For things like globals, you need to set the property to point to the correct value in the dialogue window of the form to which the script is attached.

I think I've heard that using the editorID for the property's name will default its value to whatever has that editorID, but I haven't tested this myself.

Cipscis
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Sun Jun 17, 2012 5:10 pm

I didn't realize I had to do that...

:0

And here I thought I needed to

import GlobalVariable
import Actor

and all the other script extension categories
User avatar
Roberta Obrien
 
Posts: 3499
Joined: Tue Oct 23, 2007 1:43 pm

Post » Mon Jun 18, 2012 6:45 am

Damnit, no use, still returns as zero...what the hell am I missing...


For reference, here's the script in full.


scriptname cohTransformTiming extends Quest{Controls the Timing for transformation.};calling properties, spells, globals, and importing the maths.		import Math	float property cohGetMoonPhase auto	float property cohPhaseDay auto	bool property cohCanTransform auto	bool property cohbmvar auto	bool property IsFirstChange auto	Spell property WerewolfChange auto	GlobalVariable Property GameHour auto	GlobalVariable Property GameDaysPassed auto	GlobalVariable Property PlayerIsWerewolf auto	GlobalVariable Property PlayerWerewolfShiftbacktime auto	MagicEffect Property WerewolfChangeEffect auto	; The script should run once every in game minute in this state, otherwise the flavor texts could be desychronized.Event OnInit()RegisterForUpdate(1)EndEvent	Event OnUpdate(); Determining Moon Phase Below...Not yet implimented.	int timeOfDay = GameHour.GetValueint()	int DaysPassed = GameDaysPassed.GetValueint(); Ignore PhaseDay, not functioning in this iteration of the script.;/List of moon phases returned by cohGetMoonPhase.0 = full moon1 = 3/4 waning2 = half waning3 = 1/4 waning4 = new moon5 = 1/4 waxing6 = half waxing7 = 3/4 waxing/;;Not sure what cohPhaseDay should return, though one is an adequete placeholder.debug.Notification(PlayerIsWerewolf.GetValue())	If TimeOfDay >= 20 || TimeOfDay < 6	cohCanTransform == trueelse		cohCanTransform == falseendif; Hell, it's morphing time!			if ( PlayerIsWerewolf.GetValue() == 1 && cohCanTransform == true ) && IsFirstChange == true && game.getplayer().HasMagicEffect(WerewolfChangeEffect) == 0	debug.notification("The player can transform!!!")	PlayerWerewolfShiftbacktime.SetValue(10000)	WerewolfChange.Cast(Game.GetPlayer(), Game.GetPlayer())	Utility.WaitGameTime ( 0.05 )	Debug.Notification ("Generic Flavor Text")		elseif PlayerIsWerewolf.GetValue() == 1 && cohCanTransform == true && IsFirstChange == false && game.getplayer().HasMagicEffect(WerewolfChangeEffect) == 0	PlayerWerewolfShiftbacktime.SetValue(10000)	WerewolfChange.Cast(Game.GetPlayer(), Game.GetPlayer())	Utility.WaitGameTime ( 0.05 )	Debug.MessageBox ("First Post Transform Flavor Text")	elseif PlayerIsWerewolf.GetValue() == 1 && game.getplayer().HasMagicEffect(WerewolfChangeEffect) == 1 && cohCanTransform == false	PlayerWerewolfShiftbacktime.SetValue(1)endifEndEvent

all the global variable properties are set to reference the appropriate variable, I just don't know what to do now.

Could it be the fault of the "oninit" event?

I actually think it might be just that...

In my theory the script, since its not linked to the quest by a papyrus fragment that registers it form activation rather than putting an oninit event in the source script; since the properties are stored in the quest, things don't work as intended.


Alternatively, do I need to figure out QuestStage fragments (http://www.creationkit.com/Quest_Stage_Fragments)? Or do I just need to set kmyQuest to reference my script? So many questions.
User avatar
Theodore Walling
 
Posts: 3420
Joined: Sat Jun 02, 2007 12:48 pm


Return to V - Skyrim