Jump to content

Recommended Posts

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)
        end
end)

 

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

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.

no dice

same 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_Z

unfortunately that means i cant use the config for the moment but ill cross that bridge when i give a damn.

Edited by unique kantilope
good news everyone! the solution was to use GLOBAL.KEY_Z

unfortunately 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)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...