Jump to content

IsKeyPressed seems to not be working/detecting the key


schlick99x

Recommended Posts

I only recently (last Thurs. to be precise) got a copy of FO3 for PC, (been playing forever on consoles) and since have been playing with the GECK, and lately I've been researching existing mods for creative inspiration. I finally decided to download and install Fellout mod, and it works great...dark and great...very dark...

Anyway, I also downloaded a standalone NVG add-on (appologies for not remembering the author off the top of my head), but it didn't work. Through trial and (a lot of) error, I believe the problem is/was the new textures not loading. I admit I tested this by attaching the NVG script and ench forms to a generic biker goggles object. Worked like a charm...turned on NVG effect upon equipping goggles, and turned it off when unequipped.

Well I just couldn't leave well enough alone, so I tried (after seeing many mods) to make some armor with a key-press toggle NVG mode, and for hours I have been scouring the interweb (not a typo, lol) for an API for the GECK and/or FOSE to avail. the best function I could find is "Is KeyPressed" which sound like exactly what I need, however no matter how simple or complex a structure I nest the function in, IT WON'T %@ING WORK! I have yet to detect a key press. After just a couple lines to check if iskeypressed showmessage didn't even work, I finally stopped here:

 

- Script -

 

scn DevArmorNVGToggleNScript

 

int isnvgon

 

Begin OnEquip

Set isnvgon to 0

End

 

Begin GameMode

 

; OnUnequip

if isnvgon == 1 && player.GetEquipped DevArmorNVGHelmetOutcast == 0

rimod DevNightVisionISFX

Set isnvgon to 0

 

; OnEquip (turned on for testing purposes)

elseif isnvgon == 0 && player.GetEquipped DevArmorNVGHelmetOutcast == 1

imod DevNightVisionISFX ; Default - rimod

Set isnvgon to 1 ; Default - 0

endif

 

if IsKeyPressed 49 != 0 && player.GetEquipped DevArmorNVGHelmetOutcast == 1

rimod DevNightVisionISFX

Set isnvgon to 0

 

elseif IsKeyPressed 49 != 0 && player.GetEquipped DevArmorNVGHelmetOutcast == 0

imod DevNightVisionISFX

Set isnvgon to 1

endif

 

End

 

- End Script -

 

If anybody can look through this and tell me I'm stupid cuz I'm using IsKeyPressed wrong (and hopefully explain how to use it correctly or suggest and alternative) I will feel better than not knowing anything now.

 

For the record -

Everything from 'Begin OnEquip...' to '...endif; if Is KeyPress...' was ripped line for line from previously mentioned NVG add-on. I only changed variable name from iEquipped to isnvgon to try to more clearly reflect my usage, and minimize corruption of the one part that works. "imod" and"rimod" statements are/were ripped from his/her script as well.

I am checking IsKeyPressed and Player.GetEquipped to make sure nvg mode cannot/will not be activated with toggle unless armor is equipped. (Also, I plan to use isnvgon variable to help calculate Electron Cell usage for batteries once I get this toggle mess sorted.) 49 is "N" right?

 

I am areally hoping for a solution to get the "Press 'N' to toggle NVG mode" working, but am fully open to efficiency/optimization/organization improvement suggestions or whatever. If you feel better thrashing me for not knowing everything about everyhing that's fine, too. If it helps you feel better, I'm glad I could help!

 

Thanks in advance for any/all help! While the tools have been out for a while, they are still new to me and I am hoping a few of you experienced modders will remember when you too were once "noobs" and needed a little bit of advice now and then...lol.

Edited by schlick99x
Link to comment
Share on other sites

Hi prensa,

 

Funny you mention that, as it was this article from cipscis that led me use FOSE, just to (attempt to) use IsKeyPressed. I tried with and without the isPressed variable block and nothing works. However...

 

Now that I have had a few hours sleep, and a few hours tinkering today, I am beginning to believe that NONE of the FOSE scripts work. I am running everything (game and mod tools) from custom folder in windows 7 (nothing in the stock 'windows-dominated' programs folder) and using shortcut to "fose_loader.exe -editor" to launch GECK. Finally, I use FOMM to load 'stock' .esm's w/ all DLC first, then Fellout w/ all DLC, and then my custom .esp file last.

 

I think IsKeyPressed is the first actual FOSE function I've tried to use. The scripts compile and save as normal, but when I try to use the feature in-game (i.e press the 'N' key) nothing happens (I tried w/ helmet equipped and unequipped as well as on the ground). I also noticed that adding the extra IsKeyPressed checks to the end of the essentially unchanged and (previously) functional OnEquip/Unequip blocks causes the whole script to at least appear to never run/function at all.

 

Almost forgot...I have "Games for Windows" version of FO3: GOTY with latest? (downloaded a few days ago) 1.7 patch. After more net research, this seems to be a possible point of concern seeing as how windows goes to great lengths to 'protect' the 'integrity' of the vanilla game...however anything created by or using the GECK alone works fine.

 

========

 

Meanwhile, I tried to work around this by creating an invisible, yet playable, token to assign to a hotkey while armor is equipped, but I cannot find a GECK-alone compliant script function to assign equipped item to one of the "1-8" hotkey slots(It seems there should be some way to access these keys in particular, since they are core game feautres). I fear this is only achievable through FOSE though, which seems to be unable/unwilling to play nice with windows (or vice versa).

Link to comment
Share on other sites

schlick99x - Hello!

 

Why don't you take a peak at Alexscorpions_animated_NV_goggles:

 

http://fallout3.nexusmods.com/mods/12841

 

They are using somthing simillar with an FOSE key detect, sometimes the best way to learn is to see how others have done it. :)

 

Also, I know it's obvious but I thought I'd better check, you are running Fallout 3 with FOSE?

 

Unless started with FOSE, either through FOMM or the FOSE icon or redirecting the Fallout icon, FOSE won't work in game.

 

Sorry I couldn't help more.

 

Prensa

Link to comment
Share on other sites

Thank you very much prensa for your timely and helpful responses. I fear the comment I left under the post heading has been realized (something about blatant misuse...) After loading FOMM, I was going to File>launch FO3. It would seem I was/am supposed to press "Launch FOSE" button on right side...[HUGE two-handed face palm] This leads to generic windows crash referred to in numerous posts on numerous forums.

 

From what I gather the general consensus is:

 

A: FO3 must be patched to 1.7 to play nice w/ FOSE

B: Retail GOTY + FOSE = crash

 

So, it would seem I have a few options based on this information:

 

A: Buy "old" version and start over

B: Stick to GECK native scripts

C: Move on to NV and/or Skyrim

 

I think in the long run it will be quicker and simpler to get up to speed by restarting w/ NV, especially since the expanded crafting and ammo systems are already incorporated.

Link to comment
Share on other sites

Thanks blove, your success story led me to continue digging, and I am happy to say I am finally up-and-running! My (now simplified) toggle script works...mostly, I think I need to add a short delay timer to bypass IsKeyPressed being triggered upon release of the key as well as the initial press, but otherwise it kinda fits into the theme of old worn gear that the 'switch' is "going bad', which is why the intermittent behavior (sometimes it turns on right away, sometimes it flickers on then off immediately, pressing the button a few times generally works...just like a switch that is going bad :)

 

What I did:

A. Uninstalled EVERYTHING...FO3, DLC, GECK, FOSE, FOMM, everything...completely clean (I kept my *.esp, though)

B. Went to Start>Control Panel>Programs>Programs and Features and on left sidebar is option to "Turn Windows features on or off", clicked it

Took a few seconds to load, but once "Windows Features" window opened, I opened "Microsoft .NET Framework x.x.x" folder and checked both boxes inside

Then I went down a little farther to "Tablet PC Components" and UN-checked it ( I read about an issue solved with this, plus this is my desktop, w/o a touch screen, so no need for Tablet functionality anyways, really)

Finally, I hit OK and was welcomed with a nice warm "Windows must restart..." message...OK...restart

C. Upon restart I loaded setup.exe from disc 1 (GOTY ver.), and let it do simple/normal/basic whatever install...NOT custom (yes this installed to Program Files <x86>)

D. After a test run to make sure the vanilla game loaded and ran, I did the same with the DLC disc

E. Once full game and DLC were loaded and working (still crashed to blue screen the first launch...I believe this is a graphics issue that is resolved on 2nd launch) I installed GECK, immediately followed by 1.5 patch for GECK

F. Once GECK was installed and 'test-fired', I unpacked and installed FOSE, which Windows won't let me add "-editor" to fose_loader.exe in the Target field in Properties (obscure error message), but loads fine from

command prompt...seems odd, but at least it works one way

G. Finally, FOMM unpacked and installed, and I nearly passed out when "Launch FOSE" button actually LAUNCHED the game instead of CRASHING the game!!!

 

AS stated above a simple set of nested if statements to check for key press, and on/off state variable for nvg effect and, while still 'buggy', the concept is basically sound! SWEET!! Now I can continue the quest that is evolving from this armor experiment...that pesky Enclave seems to have deserted an underground research facility overrun by death claws, some of which had already been fitted with an experimental cloaking system...few things scarier (and harder to survive) in the Capital Wasteland than being stalked by (nearly) invisible death claws through unfamiliar territory!

 

Thanks again to both of you, prensa and blove, for politely helping me in the right direction!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...