senterpat Posted July 9, 2012 Share Posted July 9, 2012 (edited) EDIT: Oops sorry bout the title, through that down before I typed out of frustration and forgot to change it, if a moderator can delete it I'll repost with an appropriate title. So I thought I had a good handle how to use float variables with getsecondspassed, but I can't figure out for the life of me why this script is casting my spell as soon as I sneak, instead of after 10 seconds like how I have it set up. Because I'm trying to make it so that I have to stand still for 10 seconds before the spell is applied, but it applies it immediatly, regardless of whether or not I'm moving. scn myscript float timershort doonce begin gamemode if player.getequipped myweapon && player.issneaking && player.ismoving == 0 && doonce == 0set doonce to 1set timer to 1 if timer < 10 set timer to (timer + getsecondspassed) else player.cios myspell set timer to 0 endifif player.isspelltarget myspell == 0set doonce to 0endifend Edited July 9, 2012 by senterpat Link to comment Share on other sites More sharing options...
rickerhk Posted July 10, 2012 Share Posted July 10, 2012 Some functions only work in the idle manager. I'm not saying IsMoving doesn't work in a script - I don't know - never used it. But it may be always returning zero regardless.Another way to monitor if the player is moving around is checking the player posX, posY, posZ, angle Z and Angle X to make sure they don't change for the required time. More complicated, but it will probably work. All the pos numbers are measured at the player's feet. Link to comment Share on other sites More sharing options...
senterpat Posted July 10, 2012 Author Share Posted July 10, 2012 So I've been trying to use getpos, wrote this script, and it's still not working, I didn't use getang because I only want them to not be moving, they can still look around.This is the script I'm using, reduced down to try and get the effect to work before I expand it. It's still casting the spell whether I'm moving or not. It does remove it when I'm not sneaking or using the weapon like its supposed to, but it shouldnt be casting when I'm moving :( scn myscript short doonce short d1float pos1float pos2float pos3 begin gamemodeif player.getequipped weapnvdetonator && player.issneaking && doonce == 0 set pos1 to player.getpos x set pos2 to player.getpos y set pos3 to player.getpos z set doonce to 1 endif if doonce == 1 && pos1 == player.getpos x && pos2 == player.getpos y && pos3 == player.getpos z player.cios PPTrDemolitionFX1 set d1 to 1 endifendifend And now that I think of it, I have used ismoving in a script before, and that one worked. Link to comment Share on other sites More sharing options...
Cyberlazy Posted July 11, 2012 Share Posted July 11, 2012 If you use getsecondspassed, you should put a call to it in your doonce 'init' code, or I think it will return a huge number on its first call. Link to comment Share on other sites More sharing options...
senterpat Posted July 11, 2012 Author Share Posted July 11, 2012 (edited) So now I seem to not be able to script at all again, because this wont work either, and by all means it should... It's my birthday so you should help me :P I decided to just add things bit by bit to the script, but I can't even get this first part to work.... And I have another script thats written pretty much the same and it works fine...this is an effect script, tied to a perk. I cannot figure out for the life of me why this doesn't work:Scn myscript short doonce begin gamemode if player.issneaking == 0 set doonce to 0 endif if (player.issneaking) player.cios stealthboy set doonce to 1 endif end Edited July 12, 2012 by senterpat Link to comment Share on other sites More sharing options...
rickerhk Posted July 11, 2012 Share Posted July 11, 2012 It's a bit hard to follow a script when it isn't indented and in code tags, but if you know that ismoving works, I would start with this if I was doing it: scn myscript float timer short doonce ;script on a token or weapon begin gamemode if (doonce == 0) if player.getequipped myweapon && player.issneaking && player.ismoving == 0 set doonce to 1 set timer to 10 endif elseif (doonce == 1) if timer > 0 set timer to (timer - getsecondspassed) if player.ismoving == 1 set timer to 10 ;restart the timer return endif else player.cios myspell set doonce to 2 endif elseif (doonce == 2) if player.isspelltarget myspell == 0 set doonce to 0 endif endif END Link to comment Share on other sites More sharing options...
senterpat Posted July 12, 2012 Author Share Posted July 12, 2012 Thank you rickerhk, I appreciate you doing it for me and all, though it's not why I wanted :P, because that's only helpful this one time. (and it feels like cheating) I'd much rather learn it and not have to ask the same question later. Sorry If I'm annoying, but if someone could tell me what I did wrong in my script because as far as I can tell it should cast a stealth boy when I crouch. So If anyone could tell me where the error in that script is I'd be grateful. Sorry about the no indents, I wrote it off my phone. (also, sorry for the dumb question, what are the code tags? I tried to look it up but no explanation on the geck site. Are code tags the ;messages?) Also in all the scripts I've seen on the geck site and in mods they start the timer at 0, and add getsecondspassed, is there a reason you did it your way? Are there times when using -gesecondspassed is preferable to adding it? Unless I'm missing some info the same could be accomplished by setting timer to 0 and adding the getsecondspassed, but correct me if I'm wrong. Link to comment Share on other sites More sharing options...
rickerhk Posted July 12, 2012 Share Posted July 12, 2012 Well, for the effect script, instead of Begin Gamemode, you use Begin ScriptEffectStart http://geck.bethsoft.com/index.php/ScriptEffectStart The functions in a scripteffectstart block, run exactly once. So you don't really need the DoOnce to guard it. I've never used an effect script with a perk, so I don't know much about that - I've used them with actor effects, and used AddSpell to apply them. The issues with your first two scripts are structural. The first script is missing an endif at the end, but if you put one there, the script will only run for one frame: scn myscript float timer short doonce begin gamemode if player.getequipped myweapon && player.issneaking && player.ismoving == 0 && doonce == 0 set doonce to 1 set timer to 1 if timer < 10 set timer to (timer + getsecondspassed) else player.cios myspell set timer to 0 endif if player.isspelltarget myspell == 0 set doonce to 0 endif endif<---missing, but if you add it, script will only run for one frame while DoOnce is 0 end The second script has an extra endif at the end, but the reason the effect is applied right away is because there's no timer to keep it from executing this right away:if doonce == 1 && pos1 == player.getpos x && pos2 == player.getpos y && pos3 == player.getpos zwhich will be true immediately in the same frame that DoOnce is set to 1 Using - getsecondspassed to count down is just preference. Counting up is just as valid. I would count up if it made the script simpler than counting down. Breaking your if statements up makes more efficient code, and helps you compartmentalize it better into sections. By breaking off the DoOnce, I was able to give an example of that. In the tool bar when you are editing a post, the <> is the code snippet thingy. Just highlight your code in the post, and click that button. Link to comment Share on other sites More sharing options...
senterpat Posted July 12, 2012 Author Share Posted July 12, 2012 Thank you for explaining it so well, I wish I could give you kudos again. So let me make sure I have it right, even though I probably won't use getpos unless I was wrong about ismoving, so if i set it up like this if player.someFunction set pos1 to player.getpos X set pos2 to player.getpos Y set pos3 to player.getpos Z set doonce to 1 set timer to 10 set timer to (timer - getsecondspassed) endif if timer == 0 && pos1 == player.getpos X && pos2 == player.getpos Y && pos3 == player.getpos z player.cios myspell else set timer to (timer - getsecondspassed) endif Also I don't think I've given the scripteffectstart a chance at all yet, Mostly because I didn't understand it.Is it safe to assume that anything that is linked to the TES4 website (such as the page you linked) that the information applies to fallout as well? Because that could help a lot...And regarding the scripteffectstart, to clarify, if the script looked like this: begin scripteffectstart if player.issneakingthat it would run only when the player first starts sneaking, and for the script to start again the player would have to stand up, and sneak again. Thanks again for all your time. :D Link to comment Share on other sites More sharing options...
Cyberlazy Posted July 12, 2012 Share Posted July 12, 2012 starting to look good.Yea TES4 info is typicaly valid for FONV, unless the FONV geck page says otherwise. I wrote modfusion for FONV using mainly TES4 file documents, they are 90% the same. You also have 'set timer to (timer - getsecondspassed)' in that script twice.You should have something like: if (doonce == 1) set timer to (timer - getsecondspassed) dostuff else if (doonce == 0) getsecondspassed set timer to 10 set doonce to 1 endif Note: I don't think 'else if' works properly (it seems to act like endif/if), meaing if you swap doonce == 0 and 1's positions both blocks will get called in the same execution. Also note how I call getsecondspassed once for no reason other then to initilize it, and setup timer in doonce == 0 Link to comment Share on other sites More sharing options...
Recommended Posts