NEWS
[Gelöst] Taster 2x drücken soll Aktion auslösen
-
Kommt denn auch keine debug Ausgabe? Ist das Script gestartet?
Enrico
-
Ich hätte eine Idee, wie das mit Blockly zu machen wäre. Schön wäre es noch, wenn du mal die Ojekte zu deinem Taster als Screenshot zeigst, dann wissen wir, was du genau brauchst. Hier mal ein Anfang:
Doppeldruck.JPG `
Danke für diesen Lösungsvorschlag!
Ein Problem ist mir aufgefallen:
die Variable "etwas" hat anfangs den Wert undefiniert und weder das erste noch das zweite falls greift.
Ich bin Blockly-Anfänger und habe das erste falls etwas gleich 0 in ein ungleich 1 geändert, weil ich nicht weiß wie man Variablen sauber initialisiert und wie lange sie den Wert behalten.
Viele Grüße
Marco
-
Ich bin Blockly-Anfänger und habe das erste falls etwas gleich 0 in ein ungleich 1 geändert, weil ich nicht weiß wie man Variablen sauber initialisiert und wie lange sie den Wert behalten. `
Hallo stan23
Alles was außerhalb eines Triggers ist, wird einmalig bei Scriptstart ausgeführt.
Also einfach oberhalb des Triggers ein "setze var auf Initialwert."
In Deinem Fall also '0'
Grüße
-
Danke rantanplan!
Hier ist für alle anderen der Export mit Initialisierung:

! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="comment" id="9%#,LtcJ3[Ypi9yjAt" x="362" y="37"><field name="COMMENT">Initialisierung</field>
<next><block type="variables_set" id="c1)uP|+u2k[GC!CBPH.h"><field name="VAR">etwas</field>
<value name="VALUE"><block type="math_number" id="@KwpbL?u2uRu5GAjQjh"><field name="NUM">0</field></block></value> <next><block type="comment" id="4Y}Kw8:h34T}fh.0I1"><field name="COMMENT">Triggern Tastendruck</field> <next><block type="on" id="cvy,j;|02hJ7hB?kzD]"><field name="OID">Object ID</field>
<field name="CONDITION">ne</field><statement name="STATEMENT"><block type="comment" id="8]kap%V4jkWKe.)Hfjp|"><field name="COMMENT">prüfen ob schon einmal gedrückt wurde</field> <next><block type="controls_if" id="|7MIg5b@eQM??L3KZZ2c"><mutation elseif="1"></mutation> <value name="IF0"><block type="logic_compare" id="KZE7mDRq|lPUbM2xqrOW"><field name="OP">EQ</field> <value name="A"><block type="variables_get" id="?8{/u%f5gwHmHp)/RRW9"><field name="VAR">etwas</field></block></value> <value name="B"><block type="math_number" id="BiB:5{|jJ@Hh9%t7I{ck"><field name="NUM">0</field></block></value></block></value> <statement name="DO0"><block type="comment" id="t{sAcn]5:PmHIbj,mChB"><field name="COMMENT">Aktion für einmal drücken</field> <next><block type="variables_set" id="ujIw#@I^r8riK1m@?)J%"><field name="VAR">etwas</field> <value name="VALUE"><block type="math_number" id="^f0*cO_P;kU|HvVp_v1y"><field name="NUM">1</field></block></value> <next><block type="timeouts_settimeout" id="BdTjcghIRtQ~:b|kH!Q:"><field name="NAME">timeout</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field> <statement name="STATEMENT"><block type="control" id="Uto+c93`ezXp7gWkvZw9"><mutation delay_input="false"></mutation> <field name="OID">Object ID</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="alUpOB[Ao-P]=fvRsU+m"><field name="BOOL">TRUE</field></block></value> <next><block type="variables_set" id="K?qL*xhPR*tnXvnjfDW_"><field name="VAR">etwas</field> <value name="VALUE"><block type="math_number" id="l_QR0q9%5+k.PM]/t{,A"><field name="NUM">0</field></block></value></block></next></block></statement></block></next></block></next></block></statement> <value name="IF1"><block type="logic_compare" id="(ma!2n%7ndNCg(1r*5qG"><field name="OP">EQ</field> <value name="A"><block type="variables_get" id="30kogsu9Y68pi0rLVu@A"><field name="VAR">etwas</field></block></value> <value name="B"><block type="math_number" id="FOxDr~PfX[refd6{Ns]y"><field name="NUM">1</field></block></value></block></value> <statement name="DO1"><block type="comment" id="H`KOFQf3a1dXYk*,a?MO"><field name="COMMENT">Aktion für zweimal drücken</field> <next><block type="timeouts_cleartimeout" id="b2;!bI;:W4TwsYczawuX"><field name="NAME">timeout</field> <next><block type="control" id="(w@%~O4uF}6T{?@njwFY"><mutation delay_input="false"></mutation> <field name="OID">Object ID</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="`mCTfxW{Lk9SQYLUBOJc"><field name="BOOL">TRUE</field></block></value> <next><block type="variables_set" id="%/Eu_bU1i%Upj);,-slc"><field name="VAR">etwas</field> <value name="VALUE"><block type="math_number" id="x`QR:feS=%`~21J@z~U/"><field name="NUM">0</field></block></value></block></next></block></next></block></next></block></statement></block></next></block></statement></block></next></block></next></block></next></block></xml>! ````
EDIT: die richtige Variable initialisiert.
-
Ein Problem ist mir aufgefallen:
die Variable "etwas" hat anfangs den Wert undefiniert und weder das erste noch das zweite falls greift.
Ich bin Blockly-Anfänger und habe das erste falls etwas gleich 0 in ein ungleich 1 geändert, weil ich nicht weiß wie man Variablen sauber initialisiert und wie lange sie den Wert behalten. `
Das habe ich selbst erst vor ein paar Tagen gelernt, dass man diese Variablen "initialisieren" muss. :D
Enrico
-
Hier ist für alle anderen der Export mit Initialisierung: `
Du musst aber die Variable "etwas" und nicht "value" initialisieren. -
Hallo zusammen,
ich habe mir erlaubt das Skript noch mit einem dritten Druck und einer true/false Überprüfung zu erweitern.
Vll kann es ja jemand brauchen:
Hier der Export
! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="comment" id="9%#,LtcJ3[Ypi9yjAt" x="362" y="37"><field name="COMMENT">Initialisierung</field>
<next><block type="variables_set" id="c1)uP|+u2k[GC!CBPH.h"><field name="VAR">DruckZähler</field>
<value name="VALUE"><block type="math_number" id="@KwpbL?u2uRu5GAjQjh"><field name="NUM">0</field></block></value> <next><block type="comment" id="4Y}Kw8:h34T}fh.0I1"><field name="COMMENT">Triggern Tastendruck</field> <next><block type="on" id="cvy,j;|02hJ7hB?kzD]"><field name="OID">hm-rpc.0.NEQ1318448.1.PRESS_SHORT</field>
<field name="CONDITION">any</field><statement name="STATEMENT"><block type="comment" id="8]kap%V4jkWKe.)Hfjp|"><field name="COMMENT">prüfen ob schon einmal gedrückt wurde</field> <next><block type="controls_if" id="|7MIg5b@eQM??L3KZZ2c"><mutation elseif="2"></mutation> <value name="IF0"><block type="logic_compare" id="KZE7mDRq|lPUbM2xqrOW"><field name="OP">EQ</field> <value name="A"><block type="variables_get" id="?8{/u%f5gwHmHp)/RRW9"><field name="VAR">DruckZähler</field></block></value> <value name="B"><block type="math_number" id="BiB:5{|jJ@Hh9%t7I{ck"><field name="NUM">0</field></block></value></block></value> <statement name="DO0"><block type="comment" id="d,z^]GT+I0Vl/6zYlbM;"><field name="COMMENT">true false Prüfung</field> <next><block type="controls_if" id="=)Pt:^v(4@S)NyCrX3Q_"><mutation elseif="1"></mutation> <value name="IF0"><block type="logic_compare" id=",Rfjv~}N:oTtub/2_T5m"><field name="OP">EQ</field> <value name="A"><block type="get_value" id="vjqhi=F)[Y.7UAU1s%@R"><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck1</field></block></value> <value name="B"><block type="logic_boolean" id="oSDSt@gO8B,~7Ux`HWWU"><field name="BOOL">FALSE</field></block></value></block></value> <statement name="DO0"><block type="comment" id="t{sAcn]5:PmHIbj,mChB"><field name="COMMENT">Aktion für einmal drücken AN</field> <next><block type="variables_set" id="ujIw#@I^r8riK1m@?)J%"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="^f0*cO_P;kU|HvVp_v1y"><field name="NUM">1</field></block></value> <next><block type="timeouts_settimeout" id="BdTjcghIRtQ~:b|kH!Q:"><field name="NAME">timeout1AN</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field> <statement name="STATEMENT"><block type="control" id="Uto+c93`ezXp7gWkvZw9"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck1</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="alUpOB[Ao-P]=fvRsU+m"><field name="BOOL">TRUE</field></block></value> <next><block type="variables_set" id="K?qL*xhPR*tnXvnjfDW_"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="l_QR0q9%5+k.PM]/t{,A"><field name="NUM">0</field></block></value></block></next></block></statement></block></next></block></next></block></statement> <value name="IF1"><block type="logic_compare" id="eSvTTR;;7tOw[Y8eAJ/Z"><field name="OP">EQ</field> <value name="A"><block type="get_value" id="qj8e#2MA;G^E#z3k)_!_"><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck1</field></block></value> <value name="B"><block type="logic_boolean" id=")UJ3-ocJ(;%*Kw,g1ISZ"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO1"><block type="comment" id="3_DgqEBjo*e(QiTry2d3"><field name="COMMENT">Aktion für einmal drücken AUS</field> <next><block type="variables_set" id="!h!a4}Z/l1PlqakPtTik"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="Z94)~7E~iZCrGbuK@.Bj"><field name="NUM">1</field></block></value> <next><block type="timeouts_settimeout" id="()qzCp8Bnm@*jV3OP]2c"><field name="NAME">timeout1AUS</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field> <statement name="STATEMENT"><block type="control" id="pJp(828_C/,{#EKU+NnC"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck1</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="1-owk8DLLP(Xne:.9_oG"><field name="BOOL">FALSE</field></block></value> <next><block type="variables_set" id="MFH!{;{FHE9]M7(Tf?gO"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="z6yfI|(y/FaP3evk)%Aj"><field name="NUM">0</field></block></value></block></next></block></statement></block></next></block></next></block></statement></block></next></block></statement> <value name="IF1"><block type="logic_compare" id="(ma!2n%7ndNCg(1r*5qG"><field name="OP">EQ</field> <value name="A"><block type="variables_get" id="30kogsu9Y68pi0rLVu@A"><field name="VAR">DruckZähler</field></block></value> <value name="B"><block type="math_number" id="FOxDr~PfX[refd6{Ns]y"><field name="NUM">1</field></block></value></block></value> <statement name="DO1"><block type="controls_if" id="u3_*(93=0}!Zy_Stz6i+"><mutation elseif="1"></mutation> <value name="IF0"><block type="logic_compare" id="ve:]G8/fz~!6iOF`;e{5"><field name="OP">EQ</field> <value name="A"><block type="get_value" id="Co,U6Vvi[3x8MD5]?omj"><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck2</field></block></value> <value name="B"><block type="logic_boolean" id="7[QEf+x`9[[CZj){xy,V"><field name="BOOL">FALSE</field></block></value></block></value> <statement name="DO0"><block type="comment" id="H`KOFQf3a1dXYk*,a?MO"><field name="COMMENT">Aktion für zweimal drücken AN</field> <next><block type="variables_set" id="TH8--J0vG3^u{CfPFMwY"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="5)7GD%*A~GDpq@a[^g-8"><field name="NUM">2</field></block></value> <next><block type="timeouts_cleartimeout" id="{E+u;wOs/@HBWAhTi7zC"><field name="NAME">timeout1AN</field> <next><block type="timeouts_cleartimeout" id="k,I*j8|v!W7TYfd+Z^i5"><field name="NAME">timeout1AUS</field> <next><block type="timeouts_settimeout" id="[jZVj?oHs7O(6;7@LgU+"><field name="NAME">timeout2AN</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field> <statement name="STATEMENT"><block type="control" id="G=Wg-%IX,87Uay-I{||X"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck2</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="A9@V.KKaUjyDlj;S64%1"><field name="BOOL">TRUE</field></block></value> <next><block type="variables_set" id="Ga*dp|5[T/YG=AmKt@7y"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="Px^Hqm=k,)Ehn6L+]R9b"><field name="NUM">0</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></next></block></statement> <value name="IF1"><block type="logic_compare" id="JiLBFe-;z#cr?grp=UEV"><field name="OP">EQ</field> <value name="A"><block type="get_value" id=":NN2aYkCkjj1fAQgchLS"><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck2</field></block></value> <value name="B"><block type="logic_boolean" id="aM=@Ph-?].xJ1G)V~+uy"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO1"><block type="comment" id="c~PDw-@!u2a3cv;.:KP?"><field name="COMMENT">Aktion für zweimal drücken AUS</field> <next><block type="variables_set" id="N}Wd?Q2`Q*Gto]+6O[E1"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="U#2EvHXc(39p!V~xx!P?"><field name="NUM">2</field></block></value> <next><block type="timeouts_cleartimeout" id="S1(-#lfhP^RhMuKqgRG0"><field name="NAME">timeout1AN</field> <next><block type="timeouts_cleartimeout" id="H*%=2dpTeCYWj.2|p_v:"><field name="NAME">timeout1AUS</field> <next><block type="timeouts_settimeout" id="^[5bZB^~:4IG#2JJ.fl7"><field name="NAME">timeout2AUS</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field> <statement name="STATEMENT"><block type="control" id="T=.a#{)ZQvJ^lIfi6%-M"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck2</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="M`W:ndj=~,**yXI~;=N%"><field name="BOOL">FALSE</field></block></value> <next><block type="variables_set" id=";WrPZGQ,gRrJPfG1`?7l"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="::rs0.q]IKC0dxk?WM;}"><field name="NUM">0</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></next></block></statement></block></statement> <value name="IF2"><block type="logic_compare" id="!y[u~pT{c/W:M7w67WnC"><field name="OP">EQ</field> <value name="A"><block type="variables_get" id="1}z)f3|=]pzL#3ZaIC]2"><field name="VAR">DruckZähler</field></block></value> <value name="B"><block type="math_number" id="1Yx+yff0uF_[}KOynT?P"><field name="NUM">2</field></block></value></block></value> <statement name="DO2"><block type="controls_if" id="M,Qb;lYH~r#2}p6_Z6Kt"><mutation elseif="1"></mutation> <value name="IF0"><block type="logic_compare" id="D-ris0p9MUR9Ydg_t*pU"><field name="OP">EQ</field> <value name="A"><block type="get_value" id=":mIijzNYm2A9-uoHs-CZ"><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck3</field></block></value> <value name="B"><block type="logic_boolean" id="_qL0v~`ZSgMMTgU=SD_u"><field name="BOOL">FALSE</field></block></value></block></value> <statement name="DO0"><block type="comment" id=";1P,#/XkKAx;/)/{4:MQ"><field name="COMMENT">Aktion für dreimal drücken AN</field> <next><block type="timeouts_cleartimeout" id="Bh%(eF!@-,gNODH=_PIs"><field name="NAME">timeout1AN</field> <next><block type="timeouts_cleartimeout" id="h_[:9;OS;{l).0xq1fWT"><field name="NAME">timeout1AUS</field> <next><block type="timeouts_cleartimeout" id="B%@r;w4}22pIDws)!;de"><field name="NAME">timeout2AN</field> <next><block type="timeouts_cleartimeout" id="I.Z.;Bo#Qfwuk]o%k7d~"><field name="NAME">timeout2AUS</field> <next><block type="control" id="ajs4o}e^-KjuVmR:L}#S"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck3</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="6lS]BhOk%DE(5wI_YPHG"><field name="BOOL">TRUE</field></block></value> <next><block type="variables_set" id="u}O`YJLJq2xZxCxxgc,;"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="p)dA1s@;koPJ~/s]%C=D"><field name="NUM">0</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement> <value name="IF1"><block type="logic_compare" id=")4R!hd:%ScB%W)L+hBq3"><field name="OP">EQ</field> <value name="A"><block type="get_value" id="}#}Z-yu}N[Y_,kw+a9U="><field name="ATTR">val</field> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck3</field></block></value> <value name="B"><block type="logic_boolean" id="JfO^SY#+40nhL]ozlejI"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO1"><block type="comment" id="vB.H9u=P{kQ(mshj4fRz"><field name="COMMENT">Aktion für dreimal drücken AN</field> <next><block type="timeouts_cleartimeout" id="mCHW186_+vE/~#P=ZBWM"><field name="NAME">timeout1AN</field> <next><block type="timeouts_cleartimeout" id="1@4w#;0sJ=UDj9h7=kT1"><field name="NAME">timeout1AUS</field> <next><block type="timeouts_cleartimeout" id="UQqPuSMuMZF1%a`uboO+"><field name="NAME">timeout2AN</field> <next><block type="timeouts_cleartimeout" id="0Ivl!0GYp)9-a9s/=HVV"><field name="NAME">timeout2AUS</field> <next><block type="control" id=".Ee6V7z3o.1qkB|AfFHq"><mutation delay_input="false"></mutation> <field name="OID">javascript.0.Eigene_Variablen.Mehrfachdruck.TestDruck3</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"><block type="logic_boolean" id="3jT,x#Q]F%-1h}tGwlj,"><field name="BOOL">FALSE</field></block></value> <next><block type="variables_set" id="#fh1NQv-GBO[{8s9/F)V"><field name="VAR">DruckZähler</field> <value name="VALUE"><block type="math_number" id="bThjr]VTdwHX?DIWQYdp"><field name="NUM">0</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></statement></block></next></block></statement></block></next></block></next></block></next></block></xml>! ````
3950_mehrfachdruck.png
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden