stars2heaven Posted December 28, 2009 Share Posted December 28, 2009 Im usually very good at figuring out these things myself, I've never been stumped by any scripting function till now. I've read the wiki article on this function a dozen times now and have fiddled with my script for a few hours with no luck. All Im trying to do is set off a series of actions around the player, wait a few seconds until they are finished, then complete the script. Here is what I have right now. It was alot simpler when I started out, and has probably grown a few superfluous things while I was trying to get it to work. Scn di3TriggerCollapseAndCapture short triggered float timer ref target ref mySelf Begin GameMode If ( Player.GetDistance di3CaptureTrigger <= 150 ) && ( triggered == 1 ) Set target to getParentRef Set mySelf to getSelf Target.activate mySelf 1 DisablePlayerControls Set timer to 3 Set triggered to 2 EndIf If ( timer > 0 ) && ( triggered == 3) Set timer to timer - GetSecondsPassed Set triggered to 4 ElseIf ( timer == 0 ) && ( triggered == 4 ) player.RemoveAllItems di3RemovedItemsChest001, 1 SetShowQuestItems 1 Set triggered to 5 Player.MoveToMarker di3ARCellMarker EndIf EndIf End Any help explaining to me how I am supposed to make GetSecondsPassed work correctly here, and in general, would be much appreciated. BTW, the first trigger is set to 1 by another script, just incase anyone wonders about it. I guess I also need to point out whats going wrong. So far, the results of the final ElseIf never occur. I dont know why... Link to comment Share on other sites More sharing options...
Pronam Posted December 28, 2009 Share Posted December 28, 2009 You've got some messup, the base is fine, just not the usage. You set the triggered to 2, so when is that ever used? The next block says == 3,...How is it ever going from 2 to three without anything said to do so?When you're inside the Triggered == 3You said set trigger to 4, so your that block is false from now on, as it is 4.Because of it doesn't Set timer to timer - GetSecondsPassed anymore. meaning it doesn't change the timer.Which in turns means it'll not reach 0. So the simple cure is, set the triggered == 3 to 2 and get rid of the Set triggered to 4 as you'll not need that line.next tot that, if you would put it there it would mean you set triggered to 4 about 2 times more than needed, not that'll do anything but that piece of block will run again and again until it reaches 0 .(if it was correctly then :). )Other than that for secure reasons always put if timer <= 0. That way if it would magically go beneath 0 it'll still run Keep in mind that &&s cost you time and FPS in the long run. As it'll always check both statements. Link to comment Share on other sites More sharing options...
stars2heaven Posted December 28, 2009 Author Share Posted December 28, 2009 Thanks, I hadnt noticed that I messed up the triggered and put 3 instead of 2. But the (triggered == 4) was me trying to prevent that line of script from occuring before the first part does, since timer is always at 0 until it is set to something greater. So If I do as you suggested, and remove the extra condition, that part of the script plays out as soon as the game loads up. I dont want that to happen. I tried reversing this once so that the timer counted up instead of down to avoid that problem. but Im just not understanding how getsecondspassed works so Im not having much luck with it. Thanks for the help, though. I'll keep fiddling with it until I get it to work. Link to comment Share on other sites More sharing options...
stars2heaven Posted December 28, 2009 Author Share Posted December 28, 2009 Ahh! Actually, I got it to work thanks to you. I guess Im just going to have to play around with that function until I understand it better. It really was just those few errors that were holding it back, thanks for pointing them out :) This is what I ended up with Scn di3TriggerCollapseAndCapture short triggered float timer ref target ref mySelf Begin GameMode If ( Player.GetDistance di3CaptureTrigger <= 150 ) && ( triggered == 1 ) set target to getParentRef set mySelf to getSelf target.activate mySelf 1 DisablePlayerControls Set timer to 6 Set triggered to 2 endif If ( timer > 0 ) && ( triggered == 2) set timer to timer - GetSecondsPassed Elseif ( timer <= 0 ) && ( Player.GetDistance di3CaptureTrigger <= 150 ) player.RemoveAllItems di3RemovedItemsChest001, 1 SetShowQuestItems 1 EnablePlayerControls Player.MoveToMarker di3ARCellMarker endif endif end Link to comment Share on other sites More sharing options...
Recommended Posts