Jump to content

Recommended Posts

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. 

 

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 by FruityRounds_06
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.

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 by FruityRounds_06
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.

 

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)

 

 

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 by FruityRounds_06
  • Like 1

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...