XHXIAIEIN's Forum Posts

  • CookingMatchIngredientsJSON-2.c3p

    you are no longer using an array to store ingredient data, there is no need to sort, just compare the Loop name and the amount.

    {
    	"Recipe": {
    		"TomatoEggSoup": {
    			"Ingredients": {
    				"Egg": 2,
    				"Tomato": 2,
    				"Water": 10
    			}
    		}
    	},
    	"Play": {
    		"Ingredients": {
    			"Egg": 2
    		}
    	}
    }
    
    const dataInst = runtime.objects.JSON.getFirstInstance();
    const data = dataInst.getJsonDataCopy();
    const recipes = data.Recipe;
    const playIngredients = data.Play.Ingredients;
    
    let result = "none";
    
    for (const recipeName in recipes) {
     const recipeIngredients = recipes[recipeName].Ingredients;
     if (Object.entries(recipeIngredients).every(([ingredient, amount]) =>
     playIngredients[ingredient] === amount)) {
     result = recipeName;
     break;
     }
    }
    
    runtime.setReturnValue(result);
    
  • CookingMatchIngredientsJSON

    I changed the structure of the recipe.

    {
    	"Recipe": {
    		"TomatoEggSoup": {
    			"Ingredients": [
    				"Egg",
    				"Tomato",
    				"Water"
    			]
    		}
    	},
    	"Play": {
    		"Ingredients": []
    	}
    }
    

    I use a JavaScript to match it. If a recipe is matched, return the key name. else or returns None. This name will correspond to your animation name.

    const dataInst = runtime.objects.JSON.getFirstInstance();
    const data = dataInst.getJsonDataCopy();
    const recipes = data.Recipe;
    const playIngredients = data.Play.Ingredients.sort().join(",");
    
    let result = "none";
    
    for (const recipeName in recipes) {
     const recipeIngredients = recipes[recipeName].Ingredients.sort().join(",");
     if (playIngredients === recipeIngredients) {
     result = recipeName;
     break;
     }
    }
    
    runtime.setReturnValue(result);
    
  • Since you already have a Json content to store the recipe.

    it might be like this:

    {
     "Pancake": { "id": 1, "ingredients": ["flour", "sugar", "milk", "egg"] },
     "Butter Cookies": { "id": 2, "ingredients": ["flour", "butter", "sugar"] },
     "Muffin": { "id": 3, "ingredients": ["flour", "sugar", "milk", "butter", "egg"] },
     "Cake": { "id": 4, "ingredients": ["flour", "sugar", "milk", "butter", "baking powder"] },
     "Cream Frosting": { "id": 5, "ingredients": ["sugar", "butter", "milk"] }
    }
    

    or like this:

    [
     {"id": 1, "name": "Pancake", "ingredients": ["flour", "sugar", "milk", "egg"]},
     {"id": 2, "name": "Butter Cookies", "ingredients": ["flour", "butter", "sugar"]},
     {"id": 3, "name": "Muffin", "ingredients": ["flour", "sugar", "milk", "butter", "egg"]},
     {"id": 4, "name": "Cake", "ingredients": ["flour", "sugar", "milk", "butter", "baking powder"]},
     {"id": 5, "name": "Cream Frosting", "ingredients": ["sugar", "butter", "milk"]}
    ]
    

    Or You can also join them into strings instead of using arrays.

    "ingredients": "flour,sugar,milk,egg"
    

    Then, a core processing step is to sort the materials and the recipes, so that players can add materials in any order and then match them with the recipes.

    "ingredients": ["flour", "sugar", "milk", "egg"]
    
    // sort
    ['egg', 'flour', 'milk', 'sugar'] 
    

    Then prepare a JSON to store the materials added by the player, and finally compare whether the two contents are the same.

  • TomLaura_D I find tutorials is full of spam posts, is it possible to clean them up regularly?

    I think some kind of content review mechanism should be added to convert some posts that are not related to tutorials into unpublished posts, so as to ensure the quality of the tutorial page.

    construct.net/en/tutorials/page-2

    Tagged:

  • ChatGPT doesn't understand what C3 does and will just say things that look correct but are not the same as what they actually do.

    ArrayCard.c3p

    ---

    if you want to import some card data, you can create an Array file and then load it into the Array object through AJAX.

    Uused for reference them as the card original database.

    In the game, you can have a other Array to manage the "current card", which stores the card ID. it determines the cards that player can currently use.

    If you want to exchange, that is, replace the IDs of these cards.

  • Can you upload your files?

    Do you know what tokenat actually does?

    tokenat("apples|oranges|bananas", 0, "|")

    returns apples.

    tokenat("apples|oranges|bananas", 1, "|")

    returns oranges.

  • As the screenshot prompts, the parameters of tokenat expression are filled in in the wrong.

    The correct usage is:

    tokenat(src, index, separator)

    tokenat(cardData, 0, "|")

  • It looks like this is the effect of some of your computer accessibility software.

  • Score-Array-LocalStorage.c3p

    You need to use LocalStorage Set item action instead of using Array Download action

  • I made a example: JSON_Additem.c3p

  • if using NW.js Export, you can uncheck the Window frame options

    And Add a NW.JS object to Set the Window size

    However, Currently no support for set borderless mode at runtime, may need to post a request.

    -

    docs.nwjs.io/en/latest/References/Manifest%20Format

  • I have one more question about this:

    issue-Tween-CustomAction

    I want to save the part of set mesh in a custom action. But if I use this custom action that will be used when the Tween is playing, it will produce different results.

  • I Modified R0J0hound's example but using Tween to control

    MeshPopupAnimation.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I recommend using an invisible "target" helper sprite , and having your mask object move to the target's location.

    oosyrag Thank you! I'll try again

    but here's another idea to do the masking with distort meshes and it just works with any angle.

    R0J0hound This is magic! Really cooooool! It works perfectly!