Jump to content

Recommended Posts

 For the first time I started making components, they are for canned foods that I have modded along with a can opener.
 As I was explained, there should be two components. "can" and "canopener", which I made. I am not sure if the can part is working, becauuse I can't get past an issue on the canopener component. I always receive the following:

[00:01:00]: [string "scripts/entityscript.lua"]:54: attempt to index field '?' (a boolean value)
LUA ERROR stack traceback:
    scripts/entityscript.lua:54 in (upvalue) LoadComponent (Lua) <50-58>
    scripts/entityscript.lua:518 in (method) AddComponent (Lua) <512-534>
    ../mods/Kings and Gods/scripts/prefabs/canopener.lua:29 in (field) fn (Lua) <6-35>
    scripts/mainfunctions.lua:146 in () ? (Lua) <135-177>

I am not sure what I am doing wrong, as much as I got some references, I am having a hard time figuring out how to set it right.

this is what I did in the modmain.
 

local Action = GLOBAL.Action
local ActionHandler = GLOBAL.ActionHandler 

AddAction("CANOPEN", "Canopen", function(act)
		if act.target.components.canopen then
			act.target.components.canopener:Canopen(act.doer)
		return true
		end
	end)

	AddStategraphActionHandler("wilson", ActionHandler(GLOBAL.ACTIONS.CANOPEN, "dolongaction"))
	
	AddStategraphActionHandler("wilson_client", ActionHandler(GLOBAL.ACTIONS.CANOPEN, "dolongaction"))

AddComponentAction("INVENTORY", "canopener", function(inst, doer, actions, right)
		  if doer and right and doer:HasTag("canned") and
                not (doer.replica.inventory:GetActiveItem() == inst and
                    doer.replica.rider ~= nil and
                    doer.replica.rider:IsRiding()) then
                table.insert(actions, ACTIONS.CANOPEN)
            end
	end)

Any help or pointer would be really appreciated

 

EDIT: it no longer crashes the game, but now the action is simply not working, at least it is one less issue, still not fully solved though.

Edited by halfrose
19 hours ago, Mobbstar said:

Debugprints will help:

print("this message appears in the logs')

print("reveal values like so", inst, inst.components.can.open)

thanks for the tip, I will print all over it to see where it is simply not going

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