-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Issue type:
- 🐛 Bug
Short description:
Script references fail to update until removed and re-added to the system manually or using automation
Steps to reproduce the problem:
Simple example:
let x = 0;
function test() {return ++x;}A variable card is referencing the test function, another applies it and is placed within the redstone writer and display panel. While I'm not sure of the display panel's refresh rate, the redstone writer should be updating once a tick, yet the number only increases when the variable is removed and placed back (and skipping multiple times at that!). It does also update when a cable is added to the system, however, as I'm using transient storage it also resets x to 0 (expected)

Complex Example:
let p_buttons = Array(12).fill(false);
let code = Array(6).fill(0);
let out = false;
function code_out(buttons) {
// check button updates
for (let i=0; i<12; i++) {
const b = buttons[i];
if (!p_buttons[i] && b) {
button(i);
}
}
p_buttons = buttons
return out;
}
let ofs = 0;
function button(i) {
// handle button pressed
let pos = code.indexOf(0);
if (i===11) {verify();}
if (i===10) {
if (pos>0) {code[pos-1] = 0;}
else {code[5] = 0; ofs = 0;}
}
if (i<=9) {
if (pos===-1) {pos=ofs++;}
code[pos] = i+1;
}
}
function verify() {
// verify code entered
out = ''+code === '10,1,2,3,4,5';
code = Array(6).fill(0);
}
function get_code() {
return code;
}I'll refrain from getting into the details here, but the gist is that code_out(buttons) is run every tick by a redstone writer, taking input from a number of redstone readers, this works fine, it also updates the code transient variable as it runs, however, when I then make a variable card referencing code directly or the get_code() function and apply it, it fails to update when placed in a display, delayor, proxy, or used otherwise for ouput (such as getting individual numbers from the list and redstone writing them)
I have found a work-around for myself for this issue, by proxying the variable to be used for output and to be passed in and out of a size 1 delayer via automation (hopper upgrade barrel) as the act of adding and removing it from a machine/display/writer seems to update the reference/output
Expected behaviour:
Variables update dynamically like they do everywhere else
Versions:
- ID: 1.27.3
- Scripting: 1.0.14
- Minecraft: 1.20.1
- Mod loader version: Forge 47.4.0
Metadata
Metadata
Assignees
Type
Projects
Status