Search code examples
luatabletop-simulator

How to set onCollisionEnter on a object?


I'm using Atom get script my TTS mod. In my game I have a bag with GUID ed743f I have a Global file that calls my #include Shard/shard file. In that file I have #include diceroller in my diceRoller.ttslua file I have this code:

diceRoller = getObjectFromGUID("ed743f")
  print(diceRoller, 'roller')

function onCollisionEnter()
  print('dice entered')
end

The print works so the file is included correctly but how do "connect" the onCollisionEnter function with the correct object (diceRoller)? Because now when I put a die in the bag nothing happens.


Solution

  • @Piglet is correct by saying onCollisionEnter(...) does not work in Global. What I did was right click the object (bag) in Tabletop Simulator and hit "Scripting editor". This opens the script file for that object. Then in that file I made a require reference require("somefolder/somefile"). The root of the path is:

    C:\Users*****\Documents\Tabletop Simulator

    So now I can use onCollisionEnter(...) because the script is not Global but object bound.