SimpleButtons

V 1.2 mod for Tabletop Playground

0
Downloads today
278
Downloads total
0
Comments

description

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.

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") })

https://pastebin.com/raw/7cpqSBQU

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.


For developers:

If you wish to use this script in your own package, I recommend using the published node package rather than copying the file.

You can find binaries/installers for node here: https://nodejs.org/en/

This script's module name is @salami-ttp/simplybuttons

Once you have the binaries installed or already have them, go into your package's Scripts folder and open a command prompt/terminal window there.

You can install the package by typing npm install @salami-ttp/simplybuttons

You can then use the module in your package scripts like so: require("@salami-ttp/simplybuttons")

See global.js for example usage of the module.

Credits

  • 27 Jul 19:48
    Version 1.2

    Removed workaround for weird garbage collection issue, fixed/improved docs, published as node package @salami-ttp/simplybuttons



Files


27.02 2020
Modhoster user rating
no rating Votes

Empfehlungsrate

-/-      
noch nicht genug Stimmen

Do you think this mod should be featured?

Mod abonnieren
Abonniere SimpleButtons
Der Mod wird automatisch beim nächsten Start von Tabletop Playground installiert.
Tabletop Playground
upload_86564_modfile.4.zip
284 KB 278

0 Comments for SimpleButtons

You have to log in for writing comments.
You can also sign up for free, id you don't have an account yet - it only takes 5 minutes.

No comments yet.

Write the first comment...

      }