https://github.com/AlexMog/Onset-MogInteractiveObjects
Let your players interact easily with your world objects !
https://github.com/AlexMog/Onset-MogInteractiveObjects
Last synced: 7 days ago
JSON representation
Let your players interact easily with your world objects !
- Host: GitHub
- URL: https://github.com/AlexMog/Onset-MogInteractiveObjects
- Owner: AlexMog
- License: mit
- Created: 2020-04-11T18:06:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-15T19:07:12.000Z (about 5 years ago)
- Last Synced: 2024-11-12T15:43:19.583Z (6 months ago)
- Language: Lua
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-onset - MogInteractiveObjects - Create objects in your world and let them be interactive! (Packages and Plugins / Libraries)
README
# Mog Interactive Objects
Create objects in your world and let them be interactive !# Usage
```lua
local MogInteractiveObjects = ImportPackage("moginteractiveobjects")
local objectId = CreateObject(1408, x, y, z, h)
MogInteractiveObjects.RegisterInteractiveObject(5, objectId)AddEvent("InteractiveObjectInteract", function(player, objectType, _objectId)
if objectType == 5 and objectId == _objectId then
AddPlayerChat(player, "Interacted with object "..objectId.." !")
end
end)
```# Available functions
```lua
--- Registers an Object as a player interactive object
--- @param objectType number Supported values: 2 (player), 3 (vehicle), 4 (npc), 5 (object), 8 (door)
--- @param objectId number The ID of the object to set as interactive (depends on the objectType)
--- @return boolean True if the object was correctly registered
MogInteractiveObjects.RegisterInteractiveObject(objectType, objectId)
--- Unregister an interactive object
--- @param objectType number Supported values: 2 (player), 3 (vehicle), 4 (npc), 5 (object), 8 (door)
--- @param objectId number The ID of the object to unregister
--- @return boolean False if the object was not registered as an interactive object
MogInteractiveObjects.UnregisterInteractiveObject(objectType, objectId)
--- Start raycast collisions from the player's head and using the camera's rotation values
--- @param maxDistance number The max distance (in centimeters) to check. BE CAREFUL, big values can result in high CPU time !!
--- @return table see https://dev.playonset.com/wiki/LineTrace 's return value
MogInteractiveObjects.PlayerLookRaycast(maxDistance)
```