I made a script call
But i've been getting a type null error once in a while. cannot read property 'id' of null.
What im trying to achieve is i have a different file name from the item ID. but i want them to appear based on the element position so i used the index.
EDIT : cause of error
new working code
JavaScript:
$gameVariables.mypool = [1,2,3,4]; // database item ID
$gameVariables.cardpic = ["000","001","002","003"]; // file name in folder
var index = Math.randomInt($gameVariables.mypool.length);
$gameVariables.setValue(57, $dataItems[index].id);
$gameVariables.setValue(58, $gameVariables.cardpic[index]);
$gameScreen.showPicture(99, $gameVariables.value(58), 0, 200, 200, 100, 100, 255, 0);
But i've been getting a type null error once in a while. cannot read property 'id' of null.
What im trying to achieve is i have a different file name from the item ID. but i want them to appear based on the element position so i used the index.
EDIT : cause of error
JavaScript:
$gameVariables.setValue(57, $dataItems[index].id);
new working code
JavaScript:
$gameVariables.mypool = [1,2,3,4]; // item ID
$gameVariables.cardpic = ["001","002","003","004"]; // filename in folder
var index = Math.randomInt($gameVariables.mypool.length); // random number based on size of array
$gameVariables.setValue(57, $gameVariables.mypool[index]); // store in var ID 57 the value of nth element of array
$gameVariables.setValue(58, $gameVariables.cardpic[index]); // store in var ID 58 the value of nth element of array