NaimaR Posted July 26, 2012 Share Posted July 26, 2012 (edited) I'm having some problems making my scripts work for a mod I'm working on.The scripts in question are as follows:ScriptName Healing begin GameMode if GetKeyPress == 35 if player.getav radiation > 4 if player.hasperk PerkX == 1 player.restoreav health 10 player.restoreav radiation 5 printc "heal1" endif if player.hasperk PerkY == 1 player.restoreav health 20 player.restoreav radiation 5 printc "heal2" endif endif endif endThe idea, here, is that: if the player is pressing the 'H' key, AND has more than 5 radiation damage AND has perk X, then restore X health. If player has perk Y instead, heal Y health.Currently, I can't convince GECK to accept and save this script, so I probably did something very wrong.I would like to make it a toggle effect, meaning, it would heal X damage per second while also draining 5 Radiation damage per second. StartCannibal Player Float healthrestore Float Starv Float Thirst set healthrestore to ((player.getav endurance * 10) + 10) + player.getlevel set Starv to (player.getav endurance * 7) + player.getav survival set Thirst to player.getav endurance * 10 player.restoreav health healthrestore player.restoreav dehydration Thirst player.restoreav hunger StarvThe purpose here is to restore an amount of health/hunger/thirst relative to the player's progression into the game(thus the player.getlevel and player survival references).This script is accepted and saved by GECK, yet it has no actual effect in the game when triggered. This is the first time I'm trying to dabble in scripts and programming, the above scripts have been assembled by finding similar scripts through google, reverse-engineering already existing scripts and partly from advice from this forum as well.I am using NVSE and starting up GECK with an NVSE loader. I'm launching my game with NVSE through FOMM. Any assistance and solutions would be much appreciated. :) Edited August 2, 2012 by NaimaR Link to comment Share on other sites More sharing options...
rickerhk Posted July 26, 2012 Share Posted July 26, 2012 With GetKeyPress you have to specify the index of the key that you want to capture short iKey set ikey to GetKeypress 0 if (ikey == 35) ;Do stuff http://fose.silverlock.org/fose_command_doc.html#GetKeyPresshttp://cs.elderscrolls.com/index.php/GetKeyPress Link to comment Share on other sites More sharing options...
NaimaR Posted July 28, 2012 Author Share Posted July 28, 2012 Thank you, I will try that. :) In the meanwhile, I was hoping that someone could help me with my second script? Link to comment Share on other sites More sharing options...
rickerhk Posted July 29, 2012 Share Posted July 29, 2012 How is the script triggered? There's no gamemode or menumode or onactivate block. Hopefully it isn't a result script because you should not declare variables in any kind of result script. Link to comment Share on other sites More sharing options...
NaimaR Posted July 29, 2012 Author Share Posted July 29, 2012 It is triggered via 'StartCannibal Player'. Link to comment Share on other sites More sharing options...
rickerhk Posted July 29, 2012 Share Posted July 29, 2012 What I mean - is the script on a quest, an object, or are you trying to modify the perk result script? Link to comment Share on other sites More sharing options...
NaimaR Posted July 29, 2012 Author Share Posted July 29, 2012 It's on an object, I guess.It's a spinoff of the vanilla Cannibal feat. Link to comment Share on other sites More sharing options...
NaimaR Posted July 30, 2012 Author Share Posted July 30, 2012 (edited) ScriptName Healing begin GameMode short iKey set ikey to GetKeypress 0 if (iKey == 35) if (player.getav radiationrads > 4) if (player.hasperk PerkX == 1) player.restoreav Health 10 player.restoreav RadiationRads 5 printc "test heal1" endif if (player.hasperk PerkY == 1) player.restoreav Health 20 player.restoreav RadiationRads 5 printc "test heal2" endif endif endif endI finally convinced GECK to accept my script, but it doesn't seem to be triggered when pressing keycode 35(H) ingame. :(A thought just came to me... Do I need to activate this script somehow?Currently it's just lying in the Scripts folder in GECK, but is that enough? Edited July 30, 2012 by NaimaR Link to comment Share on other sites More sharing options...
rickerhk Posted July 31, 2012 Share Posted July 31, 2012 A script needs to be attached to a quest, object, or an effect, or it never runs. A script on an object only runs when you are loaded in the same cell that the object is in, or if the object is an item in the player inventory. a script attached to a quest that is running, will always execute regardless of where the player is loaded. Gamemode scripts are normally attached to quests or objects. If you want to use a quest script to capture keystrokes, you could set the quest delay to .033, because a quest script defaults to once every 5 seconds, which is too slow to catch keystrokes. An object script runs every frame when it is in the loaded cell. So your script could run 30-60 times a second. Which brings up another thing - have a timer or some logic to set a delay after the key is hit, so that multiple key presses aren't registered. ScriptName Healing short iKey float fTimer begin GameMode if fTimer > 0 set fTimer to fTimer - GetSecondsPassed return else set ikey to GetKeypress 0 if (ikey == -1 || iKey == 65535) ;no key has been hit return endif if (iKey == 35) if (player.getav radiationrads > 4) set fTimer to .25 ; example - 1/4 second if (player.hasperk PerkX == 1) player.restoreav Health 10 player.restoreav RadiationRads 5 printc "test heal1" endif if (player.hasperk PerkY == 1) player.restoreav Health 20 player.restoreav RadiationRads 5 printc "test heal2" endif endif endif endif end Link to comment Share on other sites More sharing options...
Recommended Posts