FruityRounds_06 Posted January 6, 2022 Share Posted January 6, 2022 I cannot figure out how to add any kind of speed multiplier or anything to my ability/transformation without the game crashing. And if anyone knows how to make a timer than I would be happy to change it to a timed ability here is the Mod Info and Main Lua: (pls help) modmain.lua Line 90 to end I have the button press working just not the stat increases. modinfo.lua Just the key options. Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/ Share on other sites More sharing options...
FruityRounds_06 Posted January 6, 2022 Author Share Posted January 6, 2022 Well I figured out how to not crash the game but putting inst in the function (function(inst)) but how do I make it work Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1530937 Share on other sites More sharing options...
jekart021 Posted January 6, 2022 Share Posted January 6, 2022 try not inst, but ThePlayer Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531018 Share on other sites More sharing options...
FruityRounds_06 Posted January 7, 2022 Author Share Posted January 7, 2022 8 hours ago, jekart021 said: try not inst, but ThePlayer But without the inst it shows this crash (I tried it with the player) Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531092 Share on other sites More sharing options...
jekart021 Posted January 7, 2022 Share Posted January 7, 2022 yes. but u need use GLOBAL.ThePlayer or local G = GLOBAL and write G.ThePlayer Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531100 Share on other sites More sharing options...
FruityRounds_06 Posted January 7, 2022 Author Share Posted January 7, 2022 (edited) 11 hours ago, jekart021 said: yes. but u need use GLOBAL.ThePlayer or local G = GLOBAL and write G.ThePlayer But then it says hunger is a nil value and if I delete hunger it says the next is a nil value. IDK what nil value means. G.ThePlayer.components.hunger.hungerrate = (10) * TUNING.WILSON_HUNGER_RATE Edited January 7, 2022 by FruityRounds_06 Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531164 Share on other sites More sharing options...
Leonidas IV Posted January 7, 2022 Share Posted January 7, 2022 7 hours ago, FruityRounds_06 said: But then it says hunger is a nil value and if I delete hunger it says the next is a nil value. IDK what nil value means. G.ThePlayer.components.hunger.hungerrate = (10) * TUNING.WILSON_HUNGER_RATE local G = GLOBAL local ThePlayer = G.Theplayer if ThePlayer and ThePlayer.components and ThePlayer.components.hunger and ThePlayer.components.hunger.hungerrate then ThePlayer.components.hunger.hungerrate = 10 * G.TUNING.WILSON_HUNGER_RATE end Try this. Basically nil means the value doesn't exist. In this conditional check, we check that every part of the variable we want to change is not nil, and then we change its value. Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531218 Share on other sites More sharing options...
FruityRounds_06 Posted January 8, 2022 Author Share Posted January 8, 2022 (edited) local MY_BOUND_KEY = GetModConfigData("Abilitykey") local G = GLOBAL local ThePlayer = G.ThePlayer local MyKeyFunction = function (player) if ThePlayer and ThePlayer.components and ThePlayer.components.hunger and ThePlayer.components.hunger.hungerrate then ThePlayer.components.hunger.hungerrate = 10 * G.TUNING.WILSON_HUNGER_RATE end GLOBAL.TheInput:AddKeyDownHandler(MY_BOUND_KEY, MyKeyFunction) When I put this in the if the player, player, player..... it just makes the character not apear in the select menu. Also, the line at the side just keeps on going on [-] l l l l l And so on unless I place a parenthethy Edited January 8, 2022 by FruityRounds_06 Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1531270 Share on other sites More sharing options...
Leonidas IV Posted January 13, 2022 Share Posted January 13, 2022 On 1/8/2022 at 1:54 AM, FruityRounds_06 said: local MyKeyFunction = function (player) On 1/8/2022 at 1:54 AM, FruityRounds_06 said: GLOBAL.TheInput:AddKeyDownHandler(MY_BOUND_KEY, MyKeyFunction) The parameter is not being passed to the function. I have no knowledge about creating key handlers, try looking for a mod that creates one. Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1532469 Share on other sites More sharing options...
Monti18 Posted January 14, 2022 Share Posted January 14, 2022 The problem is that you run a function which needs server components on the client. Each function called by an key handler is run on the client, you first need to make a ModRPC to run a function on the server. Here I fixed it for you: Spoiler --Ability stuff local MY_BOUND_KEY = GetModConfigData("Abilitykey") local function MyKeyFunctionServer(inst) inst.components.hunger.hungerrate = (10) * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 3.5 inst.components.health:StartRegen(4, 8) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "esctemplate_speed_mod", 3.0) inst:AddComponent("worker") inst.components.worker:SetAction(ACTIONS.CHOP, 4) inst.components.worker:SetAction(ACTIONS.MINE, .5) inst.components.worker:SetAction(ACTIONS.DIG, .5) inst.components.worker:SetAction(ACTIONS.HAMMER, .25) --Some kind of timer??? inst:RemoveComponent("worker") inst.components.hunger.hungerrate = (2) * TUNING.WILSON_HUNGER_RATE inst.components.combat.damagemultiplier = 2.5 inst.components.health:StartRegen(0, 100) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "esctemplate_speed_mod", 1.5) --Somehow remove every effect end AddModRPCHandler("name of your mod", "MyKeyFunctionServer", MyKeyFunctionServer) local function MyKeyFunction() SendModRPCToServer(MOD_RPC["name of your mod"]["MyKeyFunctionServer"]) end GLOBAL.TheInput:AddKeyDownHandler(MY_BOUND_KEY, MyKeyFunction) Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1532582 Share on other sites More sharing options...
FruityRounds_06 Posted January 15, 2022 Author Share Posted January 15, 2022 OMG you guys actually responded 1 Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1532983 Share on other sites More sharing options...
FruityRounds_06 Posted January 15, 2022 Author Share Posted January 15, 2022 (edited) IT WORKED Thank you guys, so much for helping me I'll put you guys in the credit. (edit) When I add stuff, it also works thank you guys so much this mod is going to go much further than I ever imagined. Shameless plug if you guys can help again with adding that timer. Edited January 17, 2022 by FruityRounds_06 1 Link to comment https://forums.kleientertainment.com/forums/topic/136748-key-bind-ability-not-working/#findComment-1532995 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