Scripter
Acid Bubbles updated Scripter with a new update entry:

Scripter v1.1.2

- Fix Math.max and min not working (now supports either a list of values or an array) (thanks @notgivingitout for the report)
- Support underscores in variable and function names (thanks @notgivingitout for the report)
- Report errors in callbacks (on update, on float param value changed, etc.) and Stop listening to callbacks when one fails (scripter callbacks) (thanks @jaked for the contribution)
- String literal support in property names (thanks @jaked...

Read the rest of this update entry...
 
First of all, thank you very very much for this great plugin!
I assume there aren't many people who'll use it, since it requires coding.
But for people who can code this is gold!!!

A small issue: the following function outputs "A {value}", but not "B {value}" when called.
Code:
function xyz(value)
{
    console.log("A "+value);
    
     setTimeout(() => {
         console.log("B "+value);
         }, 1000);
}
Is there anything I'm doing wrong?
 
@Virt-a-Dict setTimeout receives seconds instead of milliseconds :D I'll fix that to match JavaScript. There seems to also be an issue with scoping, I'll check that too.

@Mutatta I gave some complete examples in the docs, and if you use the plugin you also have complete examples. But if you have no idea how to write JavaScript, I'd start with the basics first :)
 
@Virt-a-Dict setTimeout receives seconds instead of milliseconds :D I'll fix that to match JavaScript. There seems to also be an issue with scoping, I'll check that too.
I suspected that it might be seconds, so I tried that out and it didn't work either.
So, there is probably a scope issue as well.

Thank you for checking it!
 
Yeah I did not implement closures correctly when you invoke the function outside of the callback... I'm wondering whether I should support it since it can also affect performance.

In the meantime you can always declare the variable in the outer scope, that will avoid having that value cleared when exiting ABC, but then you'll have a single value for this.
 
Acid Bubbles updated Scripter with a new update entry:

Scripter v1.1.3

- Support string escaping (\n, \t)
- Fix setTimeout receiving seconds instead of ms
- Fix crash using scene.getAtoms()
- Fix crash with storable.getAllParamNames, stringChooserParam.choices
- Fix crash in code input in some circumstances when pressing home
-Crash on unsupported string templates (``)
-Fix reverse selections crashing the code editor when using Tab
- Fix doc errors (thanks Harry15)
- Change the license to CC BY-ND

Read the rest of this update entry...
 
Acid Bubbles updated Scripter with a new update entry:

Scripter v1.2.0

- New File System API (fs.readSceneFileSync(), fs.writeSceneFileSync(), fs.unlinkSceneFileSync()) - This allows for machine and scene-specific files.
- JSON.parse and JSON.stringify (only flat, string-only objects)
- Ternary operators (condition ? true : false)
- Support isNaN
- Breaking change: .val now really calls .val instead of .valNoCallback, triggering onChange
- Added .valNoCallback on all storables
- Fix !value only working with booleans
- Fix Scripter not attached to storables...

Read the rest of this update entry...
 
Well Scripter _is_ a scripting tool, so.... but in the docs I added examples to make it easier to get started (under Tutorials). But if you want something easier, check LogicBricks by MacGruber, it's very powerful too and all using the UI.
 
By way of example, for anyone interested, if you want to get refs to some plugins to build some cross-plugin communications, then this works (see below). I use it to keep VamMoan in sync with other relevant plugins. So much easier than other methods (imo).

JavaScript:
import { scripter, scene } from "vam-scripter";


// Get triggers from another atom
const person = scene.getAtom("Person");
const personItems = person.getStorableIds();
var vamMoan;
var cumAssist;
var penisController;


for (let i = 0; i < personItems.length; i++) {
    if(personItems[i].startsWith("plugin") && personItems[i].contains("VAMMoan")){
        vamMoan = personItems[i];
    }
    if(personItems[i].startsWith("plugin") && personItems[i].contains("CumAssist")){
        cumAssist = personItems[i];
    }
    if(personItems[i].startsWith("plugin") && personItems[i].contains("PenisController")){
        penisController = personItems[i];
    }
}

const penis = person.getStorable(penisController);
var penisintensity  = penis.getFloatParam("Intensity");
 
@Acid Bubbles I'm really happy with the scripter tool. It's awesome. So far I have created two things. A script which shows me the transitions between animations (very useful for debugging ugly transitions) and a stroboscope effect.

But here is my question: how can I start and stop the running of a script using a UI Button or some VAM Trigger?

I
want to be able to turn on and off the stroboscope. Here is my stroboscope:


JavaScript:
import { scene, scripter } from "vam-scripter";

var bpm = scene
.getAtom("UIText#CurrentBPMValue")
.getStorable("plugin#0_JayJayWon.VUML")
.getFloatParam("vFLOAT1Result")
.val;

var frequency = 1000*60/bpm;
var on_time = 100.0;

var intensity = scene.getAtom("StrobeLight").getStorable("Light").getFloatParam("intensity");

function light_flash_on() {
  intensity.val = 1.0;
  setTimeout(light_flash_off, on_time);
}

function light_flash_off() {
    intensity.val = 0.0;
    setTimeout(light_flash_on, frequency - on_time);
}

light_flash_on();
 
@pinosante i would instead declare a storable bool in scripter. When onChange is set to true you setTimeout. When in the callback the storable val is false, you stop calling the next setTimeout.

The script isn't really "running", it's just invoked from callbacks.
 
@pinosante i would instead declare a storable bool in scripter. When onChange is set to true you setTimeout. When in the callback the storable val is false, you stop calling the next setTimeout.

The script isn't really "running", it's just invoked from callbacks.
Thanks, this worked! This is my updated the code, for the curious people out there. I added a toggle in the Vam UI which is continually checked to see if it's turned on or off.


JavaScript:
import { scene, scripter } from "vam-scripter";

var bpm = scene
    .getAtom("UIText#CurrentBPMValue")
    .getStorable("plugin#0_JayJayWon.VUML")
    .getFloatParam("vFLOAT1Result")
    .val;

var frequency = 1000 * 60 / bpm;
var on_time = 100.0;
var intensity = scene.getAtom("StrobeLight").getStorable("Light").getFloatParam("intensity");

let stroboscope_enabled = scripter.declareBoolParam({
    name: "Stroboscope_Enabled_Flag",
    default: false,
    onChange: value => {
        if (value) {
            light_flash_on();
        }
    }
});

function light_flash_on() {
    intensity.val = 1.0;
    setTimeout(light_flash_off, on_time);
}

function light_flash_off() {
    if (stroboscope_enabled.val) {
        intensity.val = 0.0;
        setTimeout(light_flash_on, frequency - on_time);
    } else {
        intensity.val = 0.0; // or any default off intensity
    }
}

scripter.onUpdate(function() {
    stroboscope_enabled.val = scene
        .getAtom("UIToggle#Stroboscope")
        .getStorable("Trigger")
        .getBoolParam("value").val;

});
 
@Acid Bubbles I am having a lot of fun with your script. I'm making a little mini game. I have one question:


Is it possible to read a file with lines of text, into a list in the scripter? That would make it much easier to maintain and translate a simple game.

Thanks for your wonderful scripter. It's really cool.
 
Last edited:
Thanks, I read that before asking my question. So the thing is: it reads the whole file into a single string variable. I'd like to parse the content line for line, and store it in a list. I don't think that's doable right now. But you told me on the discord that you were adding the .split method to your to-do list, so I'll just wait until that's finished and then I'm all set! :). Thanks.
 
This is a great plugin!

Is it possible to Trigger Actions like load clothing presets or trigger state in MacGruber's state machine?

I've been able to do this by calling MacGruber's Relay plugin which defines the action and can be called with `invokeAction`, but it would be good if the `invokeAction` could do this directly by taking extra arguments like `presetFilePath` or `stringValue`.

If this can already be done please let me know.
 
Back
Top Bottom