{"id":1365,"date":"2018-10-25T20:36:06","date_gmt":"2018-10-25T20:36:06","guid":{"rendered":"https:\/\/lab.florianschwarz.net\/PennController\/?post_type=yada_wiki&#038;p=1365"},"modified":"2018-10-30T16:22:06","modified_gmt":"2018-10-30T16:22:06","slug":"zzz-standard-setvar","status":"publish","type":"yada_wiki","link":"https:\/\/lab.florianschwarz.net\/PennController\/wiki\/zzz-standard-setvar\/","title":{"rendered":"standard.setVar"},"content":{"rendered":"<p class='command-format'><code>getElement(id).setVar( varName )<\/code> <em>(since beta 0.3)<\/em><\/p>\n<p>Stores the current value of the element in the Var element named <em>varName<\/em> (if it exists).<\/p>\n<p>What the current value corresponds to is specific to each element type:<\/p>\n<ul>\n<li>For <strong>Audio<\/strong> elements, it corresponds to the timestamp of the end of the last playback so far (0 if never played back or playback never eneded).<\/li>\n<li>For <strong>Button<\/strong> elements, it corresponds to the timestamp of the last click so far (0 if never clicked).<\/li>\n<li>For <strong>Canvas<\/strong> elements, it corresponds to the number of elements it currently contains.<\/li>\n<li>For <strong>Function<\/strong> elements, it corresponds to the value returned by the function.<\/li>\n<li>For <strong>Html<\/strong> elements, it corresponds to whether the element is completely filled.<\/li>\n<li>For <strong>Image<\/strong> elements, it corresponds to whether the image is currently being displayed.<\/li>\n<li>For <strong>Key<\/strong> elements, it corresponds to the last key that was pressed so far (empty string if no key has been pressed so far).<\/li>\n<li>For <strong>Scale<\/strong> elements, it corresponds to the value of the last option that was selected (<code>NaN<\/code> if no option has been selected so far).<\/li>\n<li>For <strong>Selector<\/strong> elements, it corresponds to the last element that was selected (<code>null<\/code> if no element has been selected so far).<\/li>\n<li>For <strong>Text<\/strong> elements, it corresponds to the current text.<\/li>\n<li>For <strong>TextInput<\/strong> elements, it corresponds to the text that is currently in the input box.<\/li>\n<li>For <strong>Timer<\/strong> elements, it corresponds to whether the timer has elapsed.<\/li>\n<li>For <strong>Tooltip<\/strong> elements, it corresponds to whether the tooltip has been validated.<\/li>\n<li>For <strong>Var<\/strong> elements, it corresponds to the element&#8217;s value.<\/li>\n<li>For <strong>Video<\/strong> elements, it corresponds to the timestamp of the end of the last playback so far (0 if never played back or playback never eneded).<\/li>\n<li>For <strong>VoiceRecorder<\/strong> elements, it corresponds to the last recording (<code>undefined<\/code> if no recording so far).<\/li>\n<li>For <strong>Youtube<\/strong> elements, it corresponds to whether the video has been played.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<p>[js highlight=&#8221;1,7,11&#8243; try=&#8221;true&#8221;]<br \/>\nnewVar(&#8220;name&#8221;)<br \/>\n,<br \/>\nnewTextInput(&#8220;nameInput&#8221;, &#8220;What is your name?&#8221;)<br \/>\n    .settings.once()<br \/>\n    .print()<br \/>\n    .wait()<br \/>\n    .setVar(&#8220;name&#8221;)<br \/>\n,<br \/>\nnewText(&#8220;helloname&#8221;)<br \/>\n    .settings.before( newText(&#8220;hello&#8221;, &#8220;Hello&nbsp;&#8220;) )<br \/>\n    .settings.text( getVar(&#8220;name&#8221;) )<br \/>\n    .print()<br \/>\n[\/js]<\/p>\n<p>Creates a Var element named <em>name<\/em> and adds a text box in which to enter a name. When the return\/enter key is pressed while editing the input box, it disables the box and stores its value in the Var element named <em>name<\/em>. Then it prints a text reading <em>Hello name<\/em>, where <em>name<\/em> corresponds to the value of the Var element.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"wiki_cats":[11,16,17,18,13,5,4,19,20,21,22,23,24,34,25,26,28,27,29,30,31,12],"wiki_tags":[],"class_list":["post-1365","yada_wiki","type-yada_wiki","status-publish","hentry","wiki_cats-action-command","wiki_cats-audio-element","wiki_cats-button-element","wiki_cats-canvas-element","wiki_cats-command","wiki_cats-documentation","wiki_cats-element","wiki_cats-function-element","wiki_cats-html-element","wiki_cats-image-element","wiki_cats-key-element","wiki_cats-scale-element","wiki_cats-selector-element","wiki_cats-standard-elements","wiki_cats-text-element","wiki_cats-textinput-element","wiki_cats-timer-element","wiki_cats-tooltip-element","wiki_cats-var-element","wiki_cats-video-element","wiki_cats-voicerecorder-element","wiki_cats-youtube-element-element"],"_links":{"self":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki"}],"about":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/types\/yada_wiki"}],"author":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/comments?post=1365"}],"version-history":[{"count":5,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1365\/revisions"}],"predecessor-version":[{"id":1584,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1365\/revisions\/1584"}],"wp:attachment":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/media?parent=1365"}],"wp:term":[{"taxonomy":"wiki_cats","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_cats?post=1365"},{"taxonomy":"wiki_tags","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_tags?post=1365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}