Load resources, JSON, etc. with XMLHttpRequest

globophobe

Villager
Member
Joined
Nov 26, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
I've been tasked with making an educational RPG. I need to have a quiz in the battles. I put event pages in troops to show messages, and choices at the start of each turn. This is great :) 


Next, I need to load quiz data, which is JSON, from a server, as well as sound and picture files. Reading through forum posts, and MV's source code, it seems that resources are loaded with XMLHttpRequest. It seems like it would be enough to get the JSON response, and split the key/values into MV's variables, i.e. var 1 = question; 2 = sound file; 3 = picture; 4 = answer; 5 = distractor, etc. Buffer the question, so vars 6 ~ 10 are the next question. And after the user makes a choice send their response to the server, shifts vars 6 ~ 10 to vars 1 ~ 5, and load another question, etc.


Ideally, the sound and picture files will be exported from the server to MV, and via Python inserted directly into MV's JSON files. My questions are, "Does this make any sense?" and "Are there any issues to be aware of with loading MV with remote resources?"


Also, "What other resources/tutorials do you suggest to help creating plugins?"


So far, I've found:


https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/edit#gid=0


and plugins such as:


https://github.com/triacontane/PluginDevelopment/tree/master/js/plugins


to be good guides.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
An XMLHttpRequest is the way to go with loading files, especially from a remote server. You might have to set the server up to allow cross-origin requests, or it may throw a hissy fit over a page that's not hosted on the server trying to get something from it.


Also, with JSON, when you parse the response, it will give you a JS object that you can just access different data members of, so you don't need to have a large number of variables that you use interchangeably, you can just use 2 that hold objects with all the necessary data inside.
 

globophobe

Villager
Member
Joined
Nov 26, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Thank you. This post, although not specifically about MV, gave me what I needed to know.




As for potential problems with loading MV with remote resources, I just wondered what would happen to the rendering cycle if a resource was delayed. But... there's an easy way to find out.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top