XHXIAIEIN's Recent Forum Activity

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

XHXIAIEIN's avatar

XHXIAIEIN

Member since 26 Mar, 2016

Twitter
XHXIAIEIN has 11 followers

Trophy Case

  • 8-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • RTFM Read the fabulous manual
  • x46
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x10
    Lightning Draw First person to up-vote a new Construct 3 release
  • x9
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

20/44
How to earn trophies