javascript list handling bug

Simulated dice for role playing games
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Sunspark
Posts: 13
Joined: Sat Jan 12, 2013 5:17 am
IQ Test: Orange
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

javascript list handling bug

Post by Sunspark » Wed Feb 06, 2013 5:09 pm

dicenomicon 3.1.1 on iPad, iOS 5.1.1

Code: Select all

<function id="LISTTOSTRING" language="javascript">
function LISTTOSTRING(arrDieTypes) {
	'use strict';
	return typeof arrDieTypes;
}
</function>
<formula>
	@TYPES <- (4,6).
	@ROLLED <- (2,6).
	length(@ROLLED) + @LISTTOSTRING(@ROLLED, @TYPES)
</formula>
// returns '2 object' - ie @ROLLED is a list, and a list as far as Dicenomicon is concerned.
<formula>
	@TYPES <- (4,6).
	@ROLLED <- (2,6).
	length(@ROLLED) + @LISTTOSTRING(@ROLLED)
</formula>
// returns '2 number' - ie @ROLLED is a number as far as javascript is concerned, and a list as far as Dicenomicon is concerned..
<formula>
	@ROLLED <- (2,6).
	length(@ROLLED) + @LISTTOSTRING(@ROLLED)
</formula>
// returns '2 number' - ie @ROLLED is a number as far as javascript is concerned, and a list as far as Dicenomicon is concerned..
I'm not sure exactly what is happening, but it looks like if a list is the only argument passed to a function in javascript, the first element of the list is the value which arrives, not the list itself.

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest