Dragold Posted July 17, 2016 Share Posted July 17, 2016 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 More sharing options...
DarkXero Posted July 17, 2016 Share Posted July 17, 2016 inst.components.tool:SetAction(ACTIONS.MYACTION) Link to comment https://forums.kleientertainment.com/forums/topic/68917-uncommon-action-for-item/#findComment-794069 Share on other sites More sharing options...
Dragold Posted July 18, 2016 Author Share Posted July 18, 2016 (edited) 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 July 18, 2016 by Dragold Link to comment https://forums.kleientertainment.com/forums/topic/68917-uncommon-action-for-item/#findComment-794213 Share on other sites More sharing options...
DarkXero Posted July 19, 2016 Share Posted July 19, 2016 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) Link to comment https://forums.kleientertainment.com/forums/topic/68917-uncommon-action-for-item/#findComment-794567 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