Jump to content

Recommended Posts

I'm trying to make new hand item witch custom action.

In my modutil.lua I have code like:

AddAction("MYACTION", "Do Act", function(act)
   	--DO SOMETHING
end)

In myitem.lua added:

inst:AddComponent("tool")
inst:SetAction(ACTIONS.MYACTION)

Obviously doesn't work, game crashes ("attempt to call SetAction nil value"), but i have no idea how to add action to "tool" or go around problem.

Link to comment
https://forums.kleientertainment.com/forums/topic/68917-uncommon-action-for-item/
Share on other sites

Your solution causes another problem: invalid tool action.

I foud that actions are saved in TOOLACTIONS variable in constats.lua but when im trying do add my action by TOOLACTIONS["MYACTION"] = true in modmain.lua game crashes. Btw. I can't see why. My log.txt is always empty, even if I had like 20 crashes so far with info like "check your log.txt".

 

I had to copy my addaction code from modutil.lua to modmain.lua becouse of ""actions" nil value". modutil.lua is a big lie. Game don't see it. So wy some people writes about using modutil.lua?

Edited by Dragold
19 hours ago, Dragold said:

So wy some people writes about using modutil.lua?

They say use, as in, read it and use the functions it provides to use in the mod environment.

You can use AddAction in modmain because in modutil you can read

env.AddAction = function( id, str, fn )

and other classic ones like

env.AddComponentPostInit = function(component, fn)

and

env.AddPrefabPostInit = function(prefab, fn)

 

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