unique kantilope Posted December 6, 2015 Share Posted December 6, 2015 alrighty, so im working on my first character and i want to have a toggle-mode that is controlled by a key press (z by default). i've been repurposing alot of code from other mods and thats been going fine, but i was only able to find an example of using a key-press as a trigger from a DST mod, and the character im working on is for DS. the character works fine when i comment out the following lines in the modmain: GLOBAL.TheInput:AddKeyDownHandler(GetModConfigData("key_burned"), function() --triggered if character == "amonon" and GetPlayer().IsBurning==true then NormalStats(inst) elseif character == "amonon" then TurnBurning(inst) endend) i can also just comment out the first and last lines thereof. so i at least know where the problem comes from. i think. however, when i try to just run the whole thing, the game crashes on attempt to implement the mod, and i get this: http://i.imgur.com/bAszv0r.png Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/ Share on other sites More sharing options...
Arkathorn Posted December 6, 2015 Share Posted December 6, 2015 Perhaps "key_burned" is not a defined key? Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/#findComment-693495 Share on other sites More sharing options...
unique kantilope Posted December 6, 2015 Author Share Posted December 6, 2015 sorry should've mentioned, i have a config that sets "key_burned" in the modinfo, which by all accounts appears to be running fine. but if there were a way to directly replace: GetModConfigData("key_burned") with just "Z" or 122 or something so that i could test it, that would be lovely. but i don't know exactly how, though i have tried. Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/#findComment-693507 Share on other sites More sharing options...
pickleplayer Posted December 6, 2015 Share Posted December 6, 2015 Try KEY_Z Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/#findComment-693580 Share on other sites More sharing options...
unique kantilope Posted December 7, 2015 Author Share Posted December 7, 2015 (edited) no dicesame exact crash message when using: GetModConfigData("key_burned") KEY_Z Z no error message, but nothing happens when z is pressed in-game: 122 "Z" good news everyone! the solution was to use GLOBAL.KEY_Zunfortunately that means i cant use the config for the moment but ill cross that bridge when i give a damn. Edited December 7, 2015 by unique kantilope Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/#findComment-693828 Share on other sites More sharing options...
Kzisor Posted December 8, 2015 Share Posted December 8, 2015 good news everyone! the solution was to use GLOBAL.KEY_Zunfortunately that means i cant use the config for the moment but ill cross that bridge when i give a damn. When getting mod configuration settings its good practice to create a local variable for setting usage with an 'or' statement because mod configuration settings could return 'nil'.local key = GetModConfigData("key_burned") or GLOBAL.KEY_ZGLOBAL.TheInput:AddKeyDownHandler(key, function() --triggered if character == "amonon" and GetPlayer().IsBurning==true then NormalStats(inst) elseif character == "amonon" then TurnBurning(inst) endend) Link to comment https://forums.kleientertainment.com/forums/topic/60259-need-help-with-addkeydownhandler/#findComment-694820 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now