Skip to content

Instantly share code, notes, and snippets.

@lassemt
Last active April 20, 2022 22:06
Show Gist options
  • Save lassemt/7b6833cfa2dc0bb0e643c52cb7d6b5a2 to your computer and use it in GitHub Desktop.
Save lassemt/7b6833cfa2dc0bb0e643c52cb7d6b5a2 to your computer and use it in GitHub Desktop.
const Scene = require('Scene');
//
// Old way
//
const obj = Scene.root.find('2dText0');
// Do stuff to the object in global scope
//
// New way
//
Scene.root.findFirst('2dText0').then(obj => {
// Object is ready
// you can update the object signals etc here.
});
const D = require('Diagnostics');
const Patches = require('Patches');
//
// RECVIEVING SIGNALS FROM PATCHES
//
//
// Old way
//
const onTap = Patches.getPulseValue('tap');
onTap.subscribe(evt => {
D.log('tap')
});
//
// New way
//
Patches.outputs.getPulse('tap').then(signal => {
signal.subscribe(evt => {
D.log('tap');
});
});
//
// SENDING SIGNALS TO PATCHES
//
//
// Old way
//
Patches.setStringValue('timeNow', new Date().toString());
//
// New way
//
// Note how the new method returns a promise. Not sure what
// it can be used for though,
Patches.inputs.setString('timeNow', new Date().toString()).then(() => {
D.log('Signal is set?');
});
// So this could be enough for this
Patches.inputs.setString('timeNow', new Date().toString());
@Miuzard
Copy link

Miuzard commented Apr 8, 2020

i wanna ask more about increase speed with script when score more than 10 .. help me bro

@newcolor-studio
Copy link

please help me .. i have problem with my score script ..

score dont wanna show up ???? : (

( This API is deprecated, please upgrade to the newest SDK version. Message: Please use findFirst or findAll instead
@ )
i use this script

const number = Scene.root.find("number");
var score = Patches.getScalarValue("score");
number.text = score.toString();

how to cange to new SDK ..

thank u sir

This worked for me!

const Scene = require('Scene');
const Patches = require('Patches');

Scene.root.findFirst('BlinkCountText').then(BlinkCountText => {
Patches.outputs.getScalar('BlinkCountValue').then(BlinkCountValue => {
BlinkCountText.text = BlinkCountValue.toString();
});
});

Scene.root.findFirst('TimerCountText').then(TimerCountText => {
Patches.outputs.getScalar('TimerCountValue').then(TimerCountValue => {
TimerCountText.text = "10";
TimerCountText.text = TimerCountValue.toString();
});
});

@Demien2020
Copy link

Hi,How can I update the new code of my filter?
Now I've solved it with a tap but I'd like to change the text for each picker again.
I had linked a different dynamic text for each picker of the native ui with code old.
I have problems with canvas and rectangles.
Do you have any feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment