Problem setting Uservars in RiveScript|casper|casperklein@gmx.de|1263917138|casperklein|xx|0|85.214.100.150|Hello,<br /><br />It would be very nice if anyone could me..<br /><br />My Problem is: I want to save the bots &quot;brain&quot;.<br /><br />I want to do this by the following steps:<br /><br />my $brain = $rs-&gt;getUservars().<br />Save $brain via Dumper class to a file<br />Next time I start the bot, read the saved file and do:<br />$rs-&gt;setUservar()<br /><br />Here is a code snippet:<br /><br />[code]<br /> &nbsp; &nbsp; &nbsp; &nbsp;my $brain = $rs-&gt;getUservars($target);<br /> &nbsp; &nbsp; &nbsp; &nbsp;$rs-&gt;setUservar($target, $brain );<br />[/code]<br /><br />This fails. I receive the following error message: <br /><br />[b]Odd number of elements in hash assignment at /usr/local/share/perl/5.10.0/RiveScript.pm line 1475.[/b]<br /><br />Can someone give me a hint to make this thing work. Getting the uservars, saving them and loading them are no problem. But when it comes to $rs-&gt;setUservar() it fails.<br /><br />Thanks in advance for any help.<br /><br />Greets<br /><br />Casper||||
Re: Problem setting Uservars in RiveScript|Kirsle|casey@cuvou.net|1264042731|Kirsle|xx|0|69.232.60.104|setUservar is only for setting one variable at a time.<br /><br />In my bots I always used getUservars($user) to get the vars for one user, and then to reinsert them I just did a foreach loop over the keys of the hashref.<br /><br />A function to import uservars en masse may be nice to have though. I'll put it on my to-do list. ;) ||||
