Timers and Scripts

Post » Fri May 27, 2011 11:31 pm

Hi folks,


I'm new at trying to write my own scripts for guns and whatnot I've modded into New Vegas, but basing a script on a floating timer and the getsecondspassed function seems to be beyond me.

I'm trying to build a two-tier script, and can't figure out how to word it in the GECK to get the script to loop as opposed to running once-through. Hopefully it's something simple I'm missing.

The script as it stands:

float timer
short wakeup

Begin ScriptEffectStart
modav paralysis 1
if timer < 3
set timer to timer + getsecondspassed
else
Set wakeup to GetRandomPercent
set timer to 0

if wakeup > 50
modav paralysis 0
endif
endif
End

I'm sure there are errors in the way it's written, but the GECK finally allowed me to save that mangled script and so I've been using it as a starting point to actually get the script to work right in-game.

I've linked an ammo to this script, in the hopes that whenever I hit something with it, they'll be immediately paralyzed. Every 3 seconds, the script would roll to see if they woke up from the paralysis.
Are there looping commands I don't know to add? How should I be writing the two 'if' phrases to make sure one follows the other only after the first has been met?
Any advice would be much appreciated.
User avatar
Victoria Vasileva
 
Posts: 3340
Joined: Sat Jul 29, 2006 5:42 pm

Post » Fri May 27, 2011 9:33 pm

A http://geck.gamesas.com/index.php/ScriptEffectStart block only runs once, so it's not very useful for running a timer. The GECK doesn't tell you about this, but if you run your script through my http://www.cipscis.com/fallout/utilities/validator.aspx it will let you know about quite a few errors like that.

I'd recommend using http://geck.gamesas.com/index.php/ScriptEffectElapsedSeconds in a http://geck.gamesas.com/index.php/ScriptEffectUpdate block for running a timer in an effect script.

P.S. Please post your code in code tags, and possibly spoiler tags for longer code, as this makes it much easier to read. For example:
Spoiler
float timershort wakeupBegin ScriptEffectStart	modav paralysis 1	if timer < 3		set timer to timer + getsecondspassed	else		Set wakeup to GetRandomPercent		set timer to 0		if wakeup > 50			modav paralysis 0		endif	endifEnd

Cipscis
User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Fri May 27, 2011 10:08 pm

Thanks for the speedy reply, I'm reading up now on how the scripteffectupdate function works. Your editor works wonders in being able to think through the problem visually.


I've managed an update to this point:
Spoiler
float timer
short wakeup

Begin Scripteffectstart
Modav Paralysis 1
set timer to 0
End

Begin Scripteffectupdate
set timer to timer + scripteffectelapsedseconds
if timer > 3
set wakeup to getrandompercent
if wakeup > 50
modav paralysis 0
else
set timer to 0
endif
endif
End


Interestingly enough, your editor says my syntax is fine, but the GECK isn't letting me save what I copy over.
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Fri May 27, 2011 8:17 pm

My validator hasn't been updated since July, so there might be some changes in New Vegas relevant to your script that it doesn't know about. What error message does it give you when you try to save it?

Also, make sure you have a http://geck.gamesas.com/index.php/Scriptname. The validator won't give an error if one doesn't exist so that it can also be used to validate partial or conceptual scripts, but the GECK won't save a script without one.

Cipscis
User avatar
Penny Wills
 
Posts: 3474
Joined: Wed Sep 27, 2006 6:16 pm


Return to Fallout: New Vegas