How do I load project file using AJAX depending on variable

0 favourites
  • 9 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey everybody !

    I'm trying to load a project XML file (which mean it's imported in Files folder in contruct 2) using AJAX.

    But here's what make me stuck : the name of the file i load depends on the parameter i give to the function which make the AJAX request, by doing so i can't use the AJAX:Request Project File built in function since it require to choose the file before.

    The XML file is supposed to contain dialogs, to load appropriate one when interacting with an NPC i got a few variable to sort my files :

    ? NPC.Name

    ? NPC.ActiveQuest

    ? NPC.ActiveQuestStatus

    The function is : SpeakWith( NPC.Name, NPC.ActiveQuest, NPC.ActiveQuestStatus )

    If i want to load the XML for the NPC "NPCtest", with ActiveQuest to "TestQuest" and ActiveQuestStatus to "starting", the file name willl be :

    ? "NPCtest TestQuest starting.xml"

    ? (Function.Param(0) &" "& Function.Param(1) &" "& Function.Param(2) &".xml")

    I'm looking for a way to use AJAX to request such a file using those parameters.

    I tested lots of URLs and read lots of post but still havn't found something that work.

    I can post the .capx if needed.

    Thanks for any help !

  • This should work: nest the XML data as values in a dictionary with keys attached that correspond to the strings you want to match, and load that data into a C2 dictionary on start. It wouldn't be too hard to write a little C2 app that could nest the data for you

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah i like the idea, i'm testing it right now.

  • Well i got almost same problem that when using AJAX, how do i load a dicitonary saved on local disk or in project files ?

  • Oh sure that's a doddle: in the AJAX 'On Completed' condition, use the Dictionary's 'Load from JSON' action, using AJAX.LastData

  • I believe you misunderstood my start problem, to load my file using AJAX, i need a URL to access the file because the Request Project File built in function won't let me use a string with function parameter to access my file.

    Here's my problem, what's the URL leading to the project files in preview and in exported version ?

  • I found a way using NWjs, thanks anyway !

  • Be aware that reliance on NWJS means your game won't be compatible with non-desktops.

    I believe I understood your problem, and that my solution is viable for it if you require browser/mobile compatibility.

  • I believe that if you use "Request URL', URL can be the (exact) name of a project file (in a string).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)