tryObjectEnter does not behave as expected for stackable objects (tested with Custom Chips).
Example:
-- Container is named "foo", Object is named "bar"
function tryObjectEnter(container, object)
print(container.getName()) --Expected: "foo", Actual: "foo"
print(object.getName()) --Expected: "bar", Actual: "foo"
end
This is clearly a bug since it contradicts onObjectEnterContainer():
-- Container is named "foo", Object is named "bar"
function onObjectEnterContainer(container, object)
print(container.getName()) --Expected: "foo", Actual: "foo"
print(object.getName()) --Expected: "bar", Actual: "bar"
end
Of note, tryObjectEnter() seems to work as expected if grouping is attempted by pressing “G”, but has the broken behavior if stacking by picking up and dropping.
This may also be related: https://tabletopsimulator.nolt.io/71
Could we get some new example code?
The example is using tryObjectEnter
, with two parameters. However, that event only takes one parameter. So the provided example code raises an error, object
is expected to be (and is) nil.
Ah, the example code is using the wrong event, here is the corrected code:
-- Global script
-- Container and enteringObject are custom chip stacks
function tryObjectEnterContainer(container, enteringObject)
print("container:" .. container.getName()) --Expected: "foo", Actual: "foo"
print("enteringObject:" .. enteringObject.getName()) --Expected: "bar", Actual: "foo"
return true
end
Also attached is an example save.