Tabletop Playground

Simply Buttons for Tabletop Playground

Released (updated ago). Ranked 25 of 58 with 19 (0 today) downloads

Created by salamitr (mod ID: 86564)

thumbnail.2.jpg

Simply Buttons! A simple script I made to compensate for the fact that there is no built-in way to easily create user-interactable buttons with little hassle. These could be fancier, especially if we could set models and such through scripting(could also doing it by cheekily swapping different objects I guess)

However, these are.. Simply Buttons.

Open the chat window to see output from buttons.

Click the green button enough times and it might do something cool!


The intended usage for this script is for you to have an object you want to turn into a button already made and ready, and then using makeButton or makeButtonByID to turn said object into a button. This will allow the button in question to have its own script and functionality, although you can't override the onGrab/onReleased functions for it to work properly.

Example Usage:

var buttons = require("simplybuttons")
// Require without adding script to your package folder (Still needs to be downloaded, just grabs the script from the downloaded modio folder)
// var buttons = require("../.modio/mods/86564/Scripts/simplybuttons.js")
// require script and directly use functions with makeButton/makeButtonByID
// const {makeButton, makeButtonByID} = require("simplybuttons")

// Make a button with only the uid; Equivalent to getting an object with world.getObjectById("UID_HERE") and passing it to makeButton
// Will print "button grabbed" when pressing the button, and "button released" when letting go. Second function is unneeded for a basic toggle button.
buttons.makeButtonByID("UID_HERE", function(gameObject, player) { console.log("button pressed") }, function() { console.log("button released") })

// Make a button with a reference to a GameObject. Will print "button grabbed" when pressing the button, and "button released" when letting go. Second function is unneeded for a basic toggle button.
buttons.makeButton(refObject, function(gameObject, player) { console.log("button pressed") }, function() { console.log("button released") })

Pastebin.com

The callbacks will allow you to run functionality when the button is pressed/released. The second callback is unneeded if you just want it to set a variable. You can also just take the simple functionality from lockEventGrab & lockEvenRelease to add to your own object and it'll work fine for preventing people from picking something up.

To see more examples of the script in action and how to use it, load the package game state "start" in the editor.

Releases

FilenameSizeVersionAddedOptions
upload_86564_modfile.1.zip292.67kb1.0.1

upload_86564_modfile.zip292.25kb1.0

Comments

Join the community or sign in with your gaming account to join the conversation: