Script help - changing timescale from a script

Post » Wed Jun 20, 2012 8:16 am

Hello.

I'm trying to change to pace of timeflow from a handy little item in-game, instead of having to do it from the console with "set timescale to". I cannot quite get it to work properly, the message pops up, but as far as I can tell, there is no change. Here is what I have so far:

Scriptname aaTimeScript extends ObjectReferenceGlobalVariable property myTimeScale autoMessage property aaTimeMsg autoEvent OnActivate(ObjectReference akActivator)	  int ibutton = aaTimeMsg.Show()	If ibutton == 0   			ElseIf ibutton == 1			myTimeScale.Setvalue(30)				  		ElseIf ibutton == 2			myTimeScale.Setvalue(20)				ElseIf ibutton == 3			myTimeScale.Setvalue(10)					  		ElseIf ibutton == 4			myTimeScale.Setvalue(5)		ElseIf ibutton == 5			Return	EndIfendEvent

The GlobalVariable myTimeScale I have set pointing to TimeScale in properties.
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Wed Jun 20, 2012 12:29 pm

ScriptName aaTimeScript extends ObjectReferenceGlobalVariable Property TimeScale AutoMessage Property aaTimeMsg autoEvent OnActivate(ObjectReference akActivator)	Int iButton = aaTimeMsg.Show()	If (iButton == 0) ; TimeScale != 30		TimeScale.SetValue(30)	ElseIf (iButton == 2) ; TimeScale != 20		TimeScale.SetValue(20)	ElseIf (iButton == 3) ; TimeScale != 10		TimeScale.SetvValue(10)	ElseIf (iButton == 4) ; TimeScale != 5		TimeScale.SetValue(5)	EndIfEndEvent
The first button is 0 rather than 1 and the property won't autofill unless its name matches the existing global, TimeScale, exactly. Also, I'd add the conditions (the commented stuff) to your MessageBox buttons accordingly so only applicable buttons show.

You could do this all with an inventory item...
ScriptName TimeArmorScript extends ObjectReferenceArmor Property TimeARMO AutoGlobalVariable Property TimeScale AutoMessage Property aaTimeMsg AutoEvent OnEquipped(Actor akActor)	If akActor == Game.GetPlayer()		Game.GetPlayer().UnequipItem(TimeARMO, False, True)		Menu()	EndIf	EndEvent;=================================Function Menu()	Int iButton = 0	Int bMessage = 1	While bMessage		If (iButton != -1)			iButton = aaTimeMsg.Show()			If iButton == 0)				TimeScale.SetValue(30)				Debug.Notification("TimeScale set to 30")			ElseIf (iButton == 2)				TimeScale.SetValue(20)				Debug.Notification("TimeScale set to 20 (Default)")			ElseIf (iButton == 3)				TimeScale.SetvValue(10)				Debug.Notification("TimeScale set to 10")			ElseIf (iButton == 4)				TimeScale.SetValue(5)				Debug.Notification("TimeScale set to 5")			ElseIf (iButton == 5) ; Done				bMessage = 0			EndIf		EndIf	EndIf	EndFunction
^fix'd
User avatar
Yama Pi
 
Posts: 3384
Joined: Wed Apr 18, 2007 3:51 am

Post » Wed Jun 20, 2012 5:00 pm

IMO, you should rename MyTimeScale to just TimeScale, you bind to it anyway, no reason not to. Unless, of course you want to add that layer of indirection and possible confusion.
Also http://en.wikipedia.org/wiki/Hungarian_notation is redundant in a statically typed language, unless you want to differentiate scopes.

Well, if the message pops up, just verify via console: show timescale. Then you either know if it is working, or if you have a problem with your iButton checks.
User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am

Post » Wed Jun 20, 2012 5:59 am

Thanks, I'll try that.
User avatar
Jason King
 
Posts: 3382
Joined: Tue Jul 17, 2007 2:05 pm

Post » Wed Jun 20, 2012 3:32 pm

Yep, you were on the money. Button 2 ended up as button 1 and, well you know :)

Anyway, it works. A little more tweaking and it's good to go (Confirmation message, maybe a sound...) Thanks a lot for the help.
User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Post » Wed Jun 20, 2012 10:17 am

Like the sound of an inventory item, cheers. Wonder what kind of item it could be put onto though, pity there's no hourglass misc item like there was in Oblivion.
User avatar
Marine Arrègle
 
Posts: 3423
Joined: Sat Mar 24, 2007 5:19 am

Post » Wed Jun 20, 2012 7:07 am

Maybe Meshes\Clutter\Blackreach\BlackreachSun01.NIF

Could've sworn I'd seen a sundial somewhere...
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am

Post » Wed Jun 20, 2012 5:55 pm

Hmm, yes that could do to extract that one, I've seen it. It might be a good idea to go through the Dwemer objects.
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Wed Jun 20, 2012 5:09 pm

JustinOther, is there a way to capture that value before editing it? I have a similar idea using a console command to add a function to a game item but ideally the original value needs to be captured first so it can go back to it once the item is unequipped. [ A5m0d3us, sorry I don't mean to hijack your thread ]
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Wed Jun 20, 2012 9:02 am

Set a fPreviousValue var to its current value before altering it, then set it to fPreviousValue in an OnUnequipped() event.
User avatar
Danny Blight
 
Posts: 3400
Joined: Wed Jun 27, 2007 11:30 am

Post » Wed Jun 20, 2012 1:42 pm

But that var could be any number of variations depending on the player.
User avatar
casey macmillan
 
Posts: 3474
Joined: Fri Feb 09, 2007 7:37 pm

Post » Wed Jun 20, 2012 5:15 pm

Then initialize the var at whatever the default is.
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am


Return to V - Skyrim