Magistross's Forum Posts

  • I'm not sure I understood exactly what you were trying to do, but here's my take.

    drive.google.com/file/d/1Om-Qr8qDfzjRqzDde0NpOvgG-iIgliSp/view

    I load the array from the JSON, and pick 4 pairs of x-index 0 and 2 from the 653 possibilities. I load x-index 0 as "word" and x-index 2 as "meaning". Those get shuffled randomly, left side for "word", right side for "meaning". You have to match each "word" with its "meaning" to get points.

    Note that you can't create multiple permutation tables at once, so I had to store some in arrays (namely, slots for "word" and slots for "meaning").

  • It seems you are using height for your expanding axis, so in that case, you should be using the permutation table value on the Y axis.

    Also, shuffling the permutation table as soon as it is created is pointless, as it is already randomized on creation.

    Keep in mind that using AdvancedRandom.Permutation(0) will always give you the first index. You should probably be using a variable (instead of 0) to keep track of which permutation you are currently using.

    If you share your c3p with a broad description of what you are trying to do, I might be able to help you further.

  • AdvancedRandom.Permutation(0) gives you your first random index. So let's say you need to get values from an array, you'd use something like Array.At(AdvancedRandom.Permutation(0), 0).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you want to pick more than 1 element in a list of n elements with no repetition, you should think of a permutations table. The "Advanced Random" plugin makes it very easy to implement such a thing.

    If you have 6 matching pairs, you create a permutation table of length 6 starting at 0. It will create an array of values from 0 to 5 in a random order (basically, your indexes). You can then use AdvancedRandom.Permutation(0) to get the first random number, AdvancedRandom.Permutation(1) for the second, etc. assuring no repeating number.

    You can then use these values to index either your dictionary or array, depending on what you ended using.

  • A few things:

    1. First, the text object must be white for this to work.
    2. Second, the colorRgb value assignment must use proper array syntax, brackets instead of parentheses.
    3. Finally, you should use values between 0 and 1 in your array, so red is [1,0,0].
  • > The path you are using is not correct

    >

    > JSON2.get(".recipes" & loopindex) probably will work

    > It depends on the content of your json file though.

    Interesting. Thank you for pointing that out. Does this mean that the parent "JSON part" (like the parent header) must have a "." before it? I thought it didn't need that, since it is at the very top.

    No, your path is correct, but returns an object like I mentionned earlier, and you can't use "Get" to retrieve its content. Top level absolute path never begins with ".", you only ever begin your path with "." when you are working with relative paths, like in a "for each" or by using the "Set path" action.

  • I would use permutation tables built with the AdvancedRandom plugin. One table per "matrix", with width*height (and a maximum of Globals.Destroy_Max) permutations.

    Here's a copy of your project file modified with my suggestion.

    drive.google.com/file/d/1u65oIXb1i1r-2E1awDpd3AOxyhon4cLY/view

  • Your syntax seems slightly off and I think you need to at least define one attribute of the ::-webkit-scrollbar pseudo element for the other one to kick in.

    #myIncorrectList::-webkit-scrollbar {display: inherit;} #myIncorrectList::-webkit-scrollbar-thumb { background: #d23737; border: 4px none #99a30a; border-radius: 20px; }

  • It seems Chrome's web worker stack size is smaller than the main thread. Judging by the fact that sometimes it work, sometimes it doesn't, you are probably barely over the limit. So depending on the RNG, your recursive function Road_Destroy might cause a stack overflow.

    I suggest rewriting the function in an iterative manner (using a while). Less function calls means less overhead added to the call stack.

    Also, this particular function sometimes do nothing if the RNG select the same road twice or more, wasting numerous operations. It might not be noticeable in CPU time, but it probably explain why the recursive function sometimes caused the exception. It could be rewritten so it only select "undeleted" road every time.

  • I see. I am trying to replicate chunks of what you did in my project to understand what you've done and wrap my head around it but I am failing quite a bit. So one thing I am doing is the below:

    The Get expression of the JSON object can only return string or numeric values. The expression you written actually returns an object and C3 can't deal with that so it defaults to 0. You can however use GetAsBeautifiedString or GetAsCompactString to get objects in JSON format.

    Would you say in that case, XML would work better?

    It's pretty much the same I would say. Altough XPath is probably easier, it has the same caveats in terms of iterating. If you use "for each node" for a particular XPath, you can't use "stop loop" and that's a bummer.

    Personally, I'm partial to JSON, simply for that fact that I find it more concise.

    Would you say it would be less of a headache if I try to write this one thing (searching for the correct component) in JS and attach it as a script instead?

    Indeed, if you feel confortable with scripting, you could replicate what I did in a much less convulated manner.

    The JSON plugins expose an API that makes it easier to do interactions between event sheets and scripts, if you go that way.

    construct.net/make-games/manuals/construct-3/scripting/scripting-reference/plugin-interfaces/json

  • Here are some answers to your questions :

    1- This function only returns the index of a specific recipe name inside the JSON. It's useful to build the JSON Path to other properties of a given recipe, namely the components and the quantity needed.

    2- That's precisely it. The "stop loop" system action cannot stop loops other than system loops. It's useful to stop iterating through the JSON if you already found what you wanted. It can optimize speed a bit, given a much bigger JSON file and components list. However it also has the drawback of making the syntax a little bit harder to read and write.

    3- loopindex("components") means the loopindex of the "components" system loop. However, it is not needed since there is only one active loop at that point. I used nested loops at first, but changed it afterward. I could have removed the ("components") part and used JSON.Get("recipes." & recipeIndex & ".components." & loopindex & ".name") instead. For the first component of the first recipe, it translates to "recipes.0.components.0.name" and returns "Wormwood". The same statement would be written "recipes[0].components[0].name" in normal javascript. C3 use a peculiar syntax to access an array's items.

    4- That's right. I could have used an "else event" and used 2 actions instead of one but a ternary operator was more concise and still readable. C3 format for the ternary operator is indeed the same as C# or Javascript.

  • Feeling this was right up my alley I took a stab at it using the provided recipes JSON exemple.

    I use an array to store the currently owned components. "Crafting" recipes in this exemple simply remove the components, but in real use case you'd add it to your inventory of course !

    drive.google.com/file/d/1F1jzwfNWpln8CbLtyPz5jnK6pyh9uwJm/view

  • I'm trying to generate random numbers that don't repeat

    Construct 3 introduced the Advanced Random plugin that can do exactly that. Using a permutation table, it should be really easy to do.

    Example :

    Result :

  • The manual section pertaining to Dictionary and project files could indeed use a bit a of an addendum on how to load and use project files in dictionaries and the likes.

    When you use project files, your first reflex should be to add the AJAX object immediately. That's the only vanilla way of using said files to load stuff.

    Documentation on AJAX object : construct.net/make-games/manuals/construct-3/plugin-reference/ajax

    Basically, you use the "request project file" action, and when the request is completed, you can load the expression AJAX.LastData inside your dictionary.

  • It has to use a tilemap, but the tilemap itself can be hidden. When you build your world, you'd have to sync the tilemap with each sprite placed, and you can use a simple binary tilemap to do so (empty tile for passable terrain and filled tile for obstacle).