Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local isSpaceshipOnTop = false
- function onObjectDrop(colorName, object)
- --use the objects description field to store the guid, helps during dev when guid changes:
- --local spaceshipGuid = self.getDescription()
- -- hard coded guid:
- local spaceshipGuid = "aaaaaa"
- local objects = Physics.cast({
- origin = self.getPosition(),
- direction = vector(0, 10, 0),
- type = 1,
- debug = true
- })
- isSpaceshipOnTop = false
- for _, obj in ipairs(objects) do
- if obj.hit_object.guid == spaceshipGuid then
- isSpaceshipOnTop = true
- end
- end
- end
- -- test function to periodically check if the spacehip is on top of the object, runs every 2 seconds
- function DoThing()
- if isSpaceshipOnTop then
- print("Spaceship is on top")
- else
- print("No Spaceship found")
- end
- end
- Wait.time(DoThing, 2, -1)
Advertisement
Add Comment
Please, Sign In to add comment