input variable javascript|tungstene|tungstene@free.fr|1364670167|tungstene|xx|0|88.167.184.18|how can i define a javascript variable with riscript ?<br />exemple : <br /><br />&gt; object recvariable javascript<br /><br />   alert(age);<br /><br />&lt; object<br /><br /><br />+ rec age *<br />- i do &lt;set age=&lt;star&gt;&gt; &lt;call&gt; recvariable &lt;/call&gt; <br /><br />this dont work i can't input the age variable in javascript. How can i do ? It's possible ?<br />Thx<br /><br />||1364680870|tungstene|
Re: input variable javascript|Kirsle|casey@cuvou.net|1364701595|Kirsle|xx|0|76.168.196.14|JS objects get two variables: rs and args. rs is the RiveScript instance that called the object.<br /><br />You can therefore call rs.getUservar() etc. to get variables about the user. The trick is figuring out which user we're talking about.<br /><br />[code]+ rec age *<br />- i do &lt;set age=&lt;star&gt;&gt; &lt;call&gt;recvariable &lt;id&gt;&lt;/call&gt;<br /><br />&gt; object recvariable javascript<br /> &nbsp; var id = args[0];<br /> &nbsp; var age = rs.getUservar(id, &quot;age&quot;);<br /> &nbsp; alert(age);<br />&lt; object[/code]<br /><br />Something like that should work.||||
Re: input variable javascript|tungstene|tungstene@free.fr|1364718488|tungstene|xx|0|88.167.184.18|So lot of thx for this. <br /><br />But i have an other question. In this exemple my id is &quot;soandso&quot; (online or on localhost)<br /><br />If many people talk to the bot online (web) wath'append ? how can attribut one id for one user ?<br /><br />thx||||
Re: input variable javascript|Kirsle|casey@cuvou.net|1364722230|Kirsle|xx|0|76.168.196.14|Ah, forgot for a second that this was the JavaScript version. ;) User IDs aren't that important here, everyone is prolly gonna have the same one. IDs come more in handy if you use the JS version for Node.JS or something where multiple different users will be interacting with the same code and you'd wanna keep their info separate.<br /><br />So you could just hard-code the ID to &quot;soandso&quot; ;)||||
Re: input variable javascript|tungstene|tungstene@free.fr|1364732083|tungstene|xx|0|88.167.184.18|ok, thx.<br />I think it's possible to give an unique id for itch user in javascript with the cookies. I'll go to cherche in this way.||||
