Hello all,
I am really new to RPG Maker MZ and was wondering if you guys have any great resources on javascript for script events involving external resource grabbing. This is not for plugin creation, but for adding more functionality in a particular event. This event will draw data using an asynchronous fetch call. The code I have created so far looks like so:
Currently, the code works when I test the event, but in the play tests, the game will skip over the display message part (Console output shows that the file is fetched properly). Is there a better way to approach this? Thank you!!
I am really new to RPG Maker MZ and was wondering if you guys have any great resources on javascript for script events involving external resource grabbing. This is not for plugin creation, but for adding more functionality in a particular event. This event will draw data using an asynchronous fetch call. The code I have created so far looks like so:
let msg = "not apple";
async function getJSONData() {
try {
$gameMessage.newPage();
$gameMessage.setFaceImage('Actor1', 0);
$gameMessage.add('Ok, I am in the function...');
const response = await fetch('https://dummyjson.com/products');
const data = await response.json();
//return data;
// Do something with the JSON data
msg = data["products"][0].brand;
player.setMoveSpeed(4);
$gameMessage.newPage();
$gameMessage.setFaceImage('Actor1', 0);
$gameMessage.add('The fetch command says ' + msg + " but I don't know what that even means");
} catch (error) {
console.error('Error:', error);
}
}
$gameMessage.setFaceImage('Actor1', 0);
$gameMessage.add('Trying to grab from database...');
player = $gamePlayer;
player.setMoveSpeed(0);
getJSONData();
Currently, the code works when I test the event, but in the play tests, the game will skip over the display message part (Console output shows that the file is fetched properly). Is there a better way to approach this? Thank you!!