XHXIAIEIN's Recent Forum Activity

  • solved. Thank you Ashley and dop2000

    I put the code if someone needs in the future.

    Paste directly as Function:

    {"is-c3-clipboard-data":true,"type":"events","items":[{"functionName":"Compare","functionDescription":"","functionCategory":"","functionReturnType":"string","functionIsAsync":false,"functionParameters":[{"name":"source","type":"string","initialValue":"","comment":""}],"eventType":"function-block","conditions":[],"actions":[],"children":[{"eventType":"variable","name":"R","type":"string","initialValue":"(\\w+)\\s*?([<>!=]+)?\\s*?(\\d+|\\w+|[?<=\"].*?[?=\"]|[?<='].*?[?='])\\s*?","comment":"","isStatic":false,"isConstant":true},{"eventType":"variable","name":"operator","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"operand1","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"operand2","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"Result","type":"number","initialValue":"-1","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"operand1","value":"trim(RegexMatchAt(source, R, \"\", 1))"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"operator","value":"trim(RegexMatchAt(source, R, \"\", 2))"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"operand2","value":"trim(RegexMatchAt(source, R, \"\", 3))"}}],"children":[{"eventType":"comment","text":"Number"},{"eventType":"block","conditions":[{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"str(float(operand1))","comparison":0,"second-value":"operand1"}},{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"str(float(operand2))","comparison":0,"second-value":"operand2"}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"operand1","value":"float(operand1)"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"operand2","value":"float(operand2)"}}],"children":[{"eventType":"block","conditions":[{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\">\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) > float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"<\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) < float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) = float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"==\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) = float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\">=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) >= float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"<=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) <= float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"!=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) <> float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"<>\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"float(operand1) <> float(operand2)"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"-1"}}]}]},{"eventType":"comment","text":"String"},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"operand1 = operand2"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"==\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"operand1 = operand2"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"!=\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"operand1 <> operand2"}}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"},{"id":"compare-eventvar","objectClass":"System","parameters":{"variable":"operator","comparison":0,"value":"\"<>\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"Result","value":"operand1 <> operand2"}}]}]}]},{"eventType":"block","conditions":[],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"operand1 & \" \" & operator & \" \"& operand2 & \" // \" & (Result = 1 ? \"True\" : \"False\")"}}]}]}]}
    

    very simple to use.

    Functions.compare("5>=10")
    

    -----

    -----

    history:

    I'm designing a dialog system, that include a syntax for conditional branching.

    If it all is a string, they are all correct

    dictionary.Get("name") = "aaa"
    dictionary.Get("layout") != "Level"
    

    But once they are numbers, they are compared in dictionary order.

    "5" >= "10" // True. 5>1 (but is actually False)
    "5"<="40" // False. 5<=4 (but is actually True)
    

    How do I distinguish between numbers and strings in a string?

    I originally thought of the system condition 'Is value type', but it didn't work the way I thought it would, because if a string is passed in, it still be a string.

    Here is a quick sample:

    cdn.discordapp.com/attachments/253490735268102144/974243238829490246/ask_how_to_compare_using_string.c3p

  • You can use regular expressions \{(\S+)\} to replace string variables.

    1. Save variable in dictionary

    2. Get the value in the dictionary by key in the string.

    	Hi, {name}. You Have {gold} gold!
    

    ---

    (need 'Dictionary' object types)

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"variable","name":"REGEX_VARIABLE","type":"string","initialValue":"\\{(\\S+)\\}","comment":"{gold}","isStatic":true,"isConstant":true},{"functionName":"ParseFormat","functionDescription":"","functionCategory":"","functionReturnType":"string","functionIsAsync":false,"functionParameters":[{"name":"source","type":"string","initialValue":"","comment":""}],"eventType":"function-block","conditions":[],"actions":[],"children":[{"eventType":"variable","name":"parseText","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[{"id":"test-regex","objectClass":"System","parameters":{"string":"source","regex":"REGEX_VARIABLE","flags":"\"\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"source"}}],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"\"","start-index":"0","end-index":"RegexMatchCount(source, REGEX_VARIABLE, \"g\") - 1"}}],"actions":[],"children":[{"eventType":"variable","name":"MatchKey","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"MatchValue","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchKey","value":"RegexMatchAt(source, REGEX_VARIABLE, \"g\", loopindex)"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchValue","value":"Dictionary.Get(mid(MatchKey, 1, len(MatchKey)-2))"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"RegexReplace(ParseText, REGEX_VARIABLE, \"\", MatchValue)"}}]}]},{"eventType":"block","conditions":[],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"parseText"}}]}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"source"}}]}]}]}
    
  • you can check this:

    cdn.discordapp.com/attachments/225550155531812865/966974946746191932/RegexMatchVariable.c3p

    ---

    Sorry, English is not my native language, but you can roughly understand the idea from here:

    ( need 'Dictionary' object type)

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"variable","name":"REGEX_VARIABLE","type":"string","initialValue":"\\{(\\S+)\\}","comment":"{gold}","isStatic":true,"isConstant":true},{"functionName":"ParseFormat","functionDescription":"","functionCategory":"","functionReturnType":"string","functionIsAsync":false,"functionParameters":[{"name":"source","type":"string","initialValue":"","comment":""}],"eventType":"function-block","conditions":[],"actions":[],"children":[{"eventType":"variable","name":"parseText","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[{"id":"test-regex","objectClass":"System","parameters":{"string":"source","regex":"REGEX_VARIABLE","flags":"\"\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"source"}}],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"\"","start-index":"0","end-index":"RegexMatchCount(source, REGEX_VARIABLE, \"g\") - 1"}}],"actions":[],"children":[{"eventType":"variable","name":"MatchKey","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"MatchValue","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchKey","value":"RegexMatchAt(source, REGEX_VARIABLE, \"g\", loopindex)"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchValue","value":"Dictionary.Get(mid(MatchKey, 1, len(MatchKey)-2))"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"RegexReplace(ParseText, REGEX_VARIABLE, \"\", MatchValue)"}}]}]},{"eventType":"block","conditions":[],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"parseText"}}]}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"source"}}]}]}]}
    

    ---

    It uses regular expressions to match.

    	Hi, {name}! You Have {gold} G!
    

    Use RegexMatchCount to find how many variables need to be replaced in this string. it is 2

    	RegexMatchCount(source, "\{(\S+)\}", "g")
    

    and then use a loop to through it. 0 ~ 1

    	For "" from 0 to RegexMatchCount(source, REGEX_VARIABLE, "g") - 1
    

    and then Use RegexMatchAt to replace the variable. it is '{name}' and '{gold}'.

    	MatchKey = RegexMatchAt(source, REGEX_VARIABLE, "g", loopindex)
    

    and then Use mid(text, index, count) extract content.

    	mid(MatchKey , 1, len(MatchKey)-2)
    
    	MatchValue = Dictionary.Get(mid(MatchKey, 1, len(MatchKey)-2))
    

    and then Use RegexReplace to replace the Dictionary value.

  • It is recommended to collect the games currently available on Steam and display them on the Showcase page. This helps us to know how a game made with Construct works and what it can be.

    TomAshleyLaura_D

    image Game Developer Link
    There Is No Game Draw Me A Pixel https://store.steampowered.com/app/1241700
    The Next Penelope Aurelien Regard https://store.steampowered.com/app/332250
    Klang Tinimations https://store.steampowered.com/app/412660
    Klang 2 Tinimations https://store.steampowered.com/app/1111600
    Mighty Goose Blastmode https://store.steampowered.com/app/1299360
    Astral Ascent Hibernian Workshop https://store.steampowered.com/app/1280930
    Gardener's Path Viridino Studios https://store.steampowered.com/app/1775750
    Creature Keeper Fervir Games https://store.steampowered.com/app/1826710
    Voyage Venturous https://store.steampowered.com/app/1051950
    10mg: Sealed Estate Salman Shurie https://store.steampowered.com/app/1435480
    Story Arcana Cyomo https://store.steampowered.com/app/1374920
    Creature Keeper Fervir Games https://store.steampowered.com/app/1826710
    qomp Stuffed Wombat https://store.steampowered.com/app/1066900
    10mg: Always Down Stuffed Wombat https://store.steampowered.com/app/1101800
    Gutwhale Stuffed Wombat https://store.steampowered.com/app/1267810
    Nongunz: Doppelganger Edition Brainwash Gang https://store.steampowered.com/app/1304780
    Un_Pas_Fragile Un Pas Fragile Team https://store.steampowered.com/app/1093520
    RunningDead PotionC https://store.steampowered.com/app/1008830
    Sun Wukong VS Robot Bitca https://store.steampowered.com/app/584220
    Blind Blade II Aven https://store.steampowered.com/app/1273290
    Montaro JCKSLAP https://store.steampowered.com/app/495890
    Duck Souls Viridino Studios https://store.steampowered.com/app/917290
    Rabisco Viridino Studios https://store.steampowered.com/app/1125860
    Pinkman Viridino Studios https://store.steampowered.com/app/516480
    Hypnospace Outlaw Tendershoot https://store.steampowered.com/app/844590
    Puppy Cross DIMANCHE CORP. https://store.steampowered.com/app/1183500
    Sheepy: A Short Adventure MrSuicideSheep https://store.steampowered.com/app/1568400
    Honey Rose: Underdog Fighter Extraordinaire Pehesse https://store.steampowered.com/app/523680
    Rhythmy InsaneHawk https://store.steampowered.com/app/1001970
    Brute MGFM https://store.steampowered.com/app/451630
    Indecision Bilge Kaan https://store.steampowered.com/app/720030
    Terry Poorflyer lukaszkups.net https://store.steampowered.com/app/1935130/Terry_Poorflyer/
    stikir Bilge Kaan https://store.steampowered.com/app/952200
    Joel Mayer's Purgatory Joel Mayer Productions https://store.steampowered.com/app/1137480
    Buissons Tambouille https://store.steampowered.com/app/1151930
    Flat Trip Dmitriy Mamaev https://store.steampowered.com/app/918740
    Universe For Sale Tmesis Studio https://store.steampowered.com/app/1627840/

    Of course, there are many more, I'm sure Laura_D can add more, and also there are also many on itch.

    Author website
    Stuffed Wombat https://stuffedwombat.itch.io
    LootBndt https://lootbndt.itch.io/
    Over boy https://overboy.itch.io/
    Vimlark https://vimlark.itch.io/
    MGFM https://mgfm.itch.io/
    Salman_Shh https://salmanshh.itch.io/
    TackerTacker https://tackertacker.itch.io/
    Piranha305 https://piranha305.itch.io/
    FoozleCC https://foozlecc.itch.io/
    Shawn Bowers! https://shawnbowers.itch.io/
    niceden https://nicedengames.itch.io/
    Shepherd Games https://shepherdgames.itch.io/
    Roberto Romao https://roberto-romao.itch.io/
    Ludipe https://ludipe.itch.io/
    FobTi interactive https://fobti.itch.io/
    Samuele Sciacca https://samuelesciacca.itch.io/
  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • I try to display a simple UI using html-element. It's from here (https://codepen.io/kathykato/pen/MoZJom), but I don't know how to make the js to work. can't seem to access dom.

    c3p:

    cdn.discordapp.com/attachments/253490735268102144/956033501193470012/ask-html-element.c3p

    Tagged:

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