javascript list handling bug

Simulated dice for role playing games
Post Reply
Sunspark
Posts: 13
Joined: Sat Jan 12, 2013 5:17 am
IQ Test: Orange

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

Who is online

Users browsing this forum: No registered users and 2 guests