Jump to content

Help OnKeyDown Function


OvadWolfeye

Recommended Posts

Howdy Folks I need help understanding the OnKeyDown function better. Does it only pick up on the initial keystroke or can it pick up on the key being held down? I made a little script so that a piece of armor could be equipped only if I am holding the v key down, here is where it is now.

 

 

scn OnKeyDownHelpScript

short key

Begin GameMode

if OnKeyDown 47 == 1
set key to 1
elseif OnKeyDown 47 == 0
set key to 0
endif
If key == 1
player.equipitemsilent Item
elseif key == 0
player.unequipitemsilent Item
endif
End
I want the item to only be equipped while holding the v key down.
in testing when v is pressed I know the item is equipped because I added an enchantment on it, and see the special effect take place but the armor doesn't stay equipped. Could someone help me understand this function better, or help me determine the correct path toward correcting my ignorance?
Y'all have a goodun now
Link to comment
Share on other sites

As I did mentioned in the other thread, Make sure that it is a key that are not used by other mods as they will conflict if you make it public, just as a FYI, nothing else... ;) The number of keys are extremely limited....

Link to comment
Share on other sites

mixxa77 Thanks you for that information, never did I find a page on a function that is so comprehensive which teaches me, that I will need to do even more research. I read OBSE documentation the IsKeyPressed3 made mention to IsKeyPressed2 but honestly I couldn't comprehend it. I am noob though to all this technically I believe myself to be top end of noob status and entering my tinkering phase( I still giggle like and anime school girl when I get things to work or figure out a function though). Thanks you for your replies very much it, even though it seems a simple thing for many this is hard for me and your reply make me encouraged to strive past my own limits.

 

Pellape You have single handedly saved Hundreds, if not Millions of people headaches when I become the worlds greatest Modder. You humbled me for honestly there was never a thought to conflicts with other folks mods. My big hope is that this thought process can be incorporated into all my modding so it will become second nature, Many Thanks for bringing this thought to my mind while I am getting started in modding.

 

QQuix You must be congratulated on that upload of yours, I have always wanted something like that and is one reason I got into scripting. I will be downloading and look forward to testing it out ( and adjusting it to my wants and needs :cool: . I have been reading Oblivion: Ini Settings - The Unofficial Elder Scrolls Pages (UESP) I am attempting to assimilate the data. but it seems beyond my current level. I am really interested in the mouse button options for personal mod but do not understand it much. I want to use the 03 and 04 to use my fourth and filth mouse buttons It says I have to use a eight digit hex code now this is where it is beyond my current level, this is the example for Block to a mouse button. Block=003802FF I see the 02 that indicates right-click. But there is not posted on that page that I saw an reference to the 0038 portion or the FF. To my understanding they gave the breakdown as XXXXYYZZ it said XXXX is keyboard YY mouse button and ZZ is joystick. so is0038 referencing a particular key on a keyboard and FF a particular button on a joystick? I find it very interesting but mostly confusing I never messed with Hex beyond converting it to decimal nd vice versus.

 

 

So what i thought about was why not use two buttons so I made this:

 

scn OvadHelmetScript
Begin GameMode
if OnKeyDown 47
player.equipitemsilent OvadVisor
elseif OnKeyDown 48
player.unequipitemsilent OvadVisor
endif
End
Then I saw the replies, and figured I better change it since I want a simple toggle like crouching for my stealth boots mod, and save keys working toward Pellape's comment and came up with a simple loop for using same key and changed it to this:
scn OvadHelmetScript
short Toggle
Begin GameMode
If Toggle == 0
if OnKeyDown 47
player.equipitemsilent OvadVisor
set Toggle to 1
elseif Toggle == 1
OnKeyDown 47
player.unequipitemsilent OvadVisor
Set toggle to 0
endif
End
Edited by CountryRoberts
Link to comment
Share on other sites

My ultimate thought towards this is making my ranger mod, I made the boots as a first step My thoughts are to toward immersion as well, for instance not all rangers are like Aragorn with special abilities, yet Rangers come from a variety of races and locations so mine will be geared toward a Quest on the person becoming a ranger kinda like The Complete Ranger Mod, but geared more toward what I envision a normal human needing to become a Ranger and so its all item based. This particular one is for the Helmet and its really based on Ears and eyes. Rangers have wonderful vision and often better than average hearing. The concept is having a toggle to start detect life, it acts like a mental thought (for the immersion aspect) I want to strain my ears to pick up where this sound is coming from. Does that make since?

 

What really want is to figure out the cast function for use for this mod and other so I do not need a trinket to preform the spell effect. I could use IsKeyPressed function to cast a particular spell on my character breaking the need to hotkey a million spells which breaks my immersion, and saves me from having to always need make two items like the way my stealth boots work.

 

Ultimately I am attempting to get playing the game more immersive and have spells cast on my character while playing that fits this, like the boots that cast chameleon only while crouching seems more immersive, like I am actively attempting to be quiet versus I have tech gear like Predator. This particular one will be base on the timer of standing still. in game if you stand still long enough a camera change occurs and I want to base this off that but a bit shorter, so I have my ranger gear that if equipped has a similar timer but instead of a camera change it casts detect life. What do yall think about this.

Edited by CountryRoberts
Link to comment
Share on other sites

As for the bindings, you understood it correctly:

XXXX is keyboard, YY mouse button and ZZ is joystick.

FF means no none/no assignment

 

If you look in your Oblivion INI file you will find a line saying:

Block=003801FF

0038 is the hex code for the keyboard LEFT-ALT key – Check the table on the WIKI pages mixxa linked.

01 is the right mouse button

FF means no joystick assignment

In other words, you can Block either by pressing LEFT-ALT or right clicking. Cannot Block with the joystick.

 

If you want to Block with, say, key ‘B’, you change that line to Block=003001FF (Hex 30 for key B).

 

Or, if you want to block with your fourth mouse button, change it to Block=003803FF (although there is a note saying this does not work. I do not know why. I've never changed those settings myself. May need some trial and error.).

 

Link to comment
Share on other sites

As for the bindings, you understood it correctly:

XXXX is keyboard, YY mouse button and ZZ is joystick.

FF means no none/no assignment

 

If you look in your Oblivion INI file you will find a line saying:

Block=003801FF

0038 is the hex code for the keyboard LEFT-ALT key – Check the table on the WIKI pages mixxa linked.

01 is the right mouse button

FF means no joystick assignment

In other words, you can Block either by pressing LEFT-ALT or right clicking. Cannot Block with the joystick.

 

If you want to Block with, say, key ‘B’, you change that line to Block=003001FF (Hex 30 for key B).

 

Or, if you want to block with your fourth mouse button, change it to Block=003803FF (although there is a note saying this does not work. I do not know why. I've never changed those settings myself. May need some trial and error.).

 

So I would have to pick something like block or cast etc. to change something to the 4th and 5th mouse button in the ini file gotcha I think, an example to change block to my 4th mouse button only would be to open ini find block=line and change it to Block=FFFF03FF. You got me curious so I tried to change run mapping to test mouse buttons changed it to Run=002A03FF

Always Run=003A04FF

It didn't seem to work. It is interesting and I might have a use for this. If I can get it working correctly, would it be ok if I do use this feature in my mods to incorporate some from your The Collector to have the keybindings only work under certain conditions(like the number keys only work if Collector scroll is open) to minimize other mod interferences?

 

By the way The Collector rocks, I think I will attempt to learn from that and your many other mods(geeking out, geeking out .... oh my I am geeking out)

Edited by CountryRoberts
Link to comment
Share on other sites

Feel free to use whatever you want from those mods. I am happy when they are used.

 

As for the INI files. that is standard. The one in ...\My Games\Oblivion is the one used by the game.

 

The one I the Oblivion install folder is a backup, I guess. If memory serves, if you delete the one in the ...\My Games\Oblivion, the game will rebuild it based on the original one.

 

Make sure you restore the INI in the Oblivion install folder to the original values.

And, of course, it is always best practices to make a fall back copy before you change the INI file (or any file, for that matter).

 

And, no. I do not think it is a good idea to release a mod that requires INI changes. You cannot publish your INI file and ask users to replace theirs, because advanced users will have changes of their own already in place. On the other hand, you should not ask users to change their INI files because, although it seems a simple procedure, a number of them will mess it up and make your life miserable.

 

Better stick to trapping the action on the run via script. Notice the functions IsControlPressed and OnControlDown that allow you to catch, say, a Cast no matter which physical mean the user uses to start it, keyboard, mouse, joystick or telepathy.

 

By the way, check the List of Functions WIKI page. I used to have it open all the time when I was working on my mods.

 

 

 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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