Redstone Pen

Redstone Pen

6M Downloads

The .FO suffix works like .FE, but is not listed in documentation

Aerotactics opened this issue ยท 5 comments

commented

I realized just a bit ago I had a typo in my code, where I wanted the Falling Edge of a pulse. I typed .FO, and the code still ran as expected.

image

commented

Hi, which version/modloader are you using, for better bug searching ;)

The behaviour I expect here is:

  • V is 15 for comparator override 0 or 1 on Red.
  • Redstone output of Red is the comparator override on Red >= 2 (the .FO should be ignored).
  • Down is 15 when comparator override 0 or 1 on Red (V>0) , and one tick after that.

IIRC I do not mark a parse error if the suffixes are not explicitly .fe, .re, .co, I think that's the problem here.

The java code handling the edge detection symbols in the RLC code is here. So, edge detection should work for ".FE" and ".RE":

// Edge detection
expressions_.symbols.forEach((esym)->{
if(!esym.contains(".")) return;
final boolean isrising = esym.endsWith(".re");
if(isrising || esym.endsWith(".fe")) {
final Map<String, Integer> syms = symbols();
final String symref = esym.substring(0, esym.length()-3);
if(!syms.containsKey(symref) && (!Defs.PORT_NAMES.contains(symref))) return;
final String symlast = "."+esym+".d";
final int q1 = (syms.getOrDefault(symref,0)>0) ? 15:0;
boolean edge = false;
if(syms.containsKey(symlast)) {
final int q0 = (syms.getOrDefault(symlast,0)>0) ? 15:0;
edge = (isrising) ? ((q0<=0) && (q1>0)) : ((q0>0) && (q1<=0));
}
symbol(esym, edge ? 15 : 0);
symbol(symlast, q1);
}
});
for(int i=0; i<Defs.PORT_NAMES.size(); ++i ) {
int port_mask = 0xf<<(4*i);
if((intr_redges & port_mask) != 0) symbol(Defs.PORT_NAMES.get(i)+".re", 15);
if((intr_fedges & port_mask) != 0) symbol(Defs.PORT_NAMES.get(i)+".fe", 15);
}

commented
commented

Sorry for not including it originally. I agree adding a syntax error would help with the confusion.

Mod version: 1.11.34 Fabric

I believe you are correct, the .FO should be ignored, however try this code in an empty RPC:

D = !R.FO

I put a redstone lamp under it. IF the .FO is ignored completely, then adding power to R should turn it off and on (as it does with D = !R), but D stays on instead. (This might be a different bug)

Edit: OK yeah, I misunderstood the bug. "D = !R.FO" is acting like "D = 15". I expect that if a suffix is ignored, the code should still process normally, or the syntax error should say the whole line will be ignored.

commented

Oky, will be fixed in v1.11.35, added parse error indication for unknown symbol suffixes:

image

commented

Oky, version v1.21-1.11.35 is up on curse and modrinth. Let's close this one. Cheer's,-