XHXIAIEIN's Recent Forum Activity

  • Or

  • You can use it in expressions:

    Functions.functionname(parameter)
  • Set the text to

    Get [color=red]150[/color] points of strength
  • You can check this example #open=wall-walking

    A WarpObjectMask effect is used here.

    When this object is created, a Tween will be performed to change the size to a size, and then the fadeout disappears.(Of course, using Tween opacity instead of Fade has the same effect.)

  • Have you tried to change the Text direction property of the Text object?

  • There seems to be an error in the forum, the image upload button is not responding. You can upload the image to other places and use external links to display the image

    [img=https://xxx.jpg]

    你可以加国内的QQ群(180911504),把问题发群里看看

  • Suggestion 1

    When I select an Output, I always subconsciously used Ctrl+C/V to copy and paste it to Add a new Output, but currently it always copies the entire node panel, which makes a little inconvenience.

    Suggestion 2

    It would be better if the category titles could mapped to Output Index or name, currently it hardly helps when collapse all

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are a few ways to do it:

    1. expression choose()

    Player.X + choose(random(-150, -64), random(64, 150))
    

    2. ternary operator condition ? True : False

    Player.X + random(1) > 0.5 ? random(-150, -64) : random(64, 150)
    

    and Use this method by WackyToaster better

    Player.X + random(64,150) * choose(-1,1)
    
  • I think it's theoretically possible to make a plugin for Construct that can run Python code, as it could use a WebAssembly build of the Python interpreter.

    Please do this! That would be cool!

  • If you want to interrupt the currently playing voice, You can add the Stop Speaking action before this

    I have also recently exploring how to make Speech Synthesizer speak different texts texts at the same time. I want to simulate multiple characters reciting together. However, I found this doesn't work. It appears unfeasible to speak multiple voices at the same time. One voice must finish before another can begin.

    But I think it might be possible to achieve it through external TTS technology.

  • I did it using regex. file.c3p

    Functions.TagAt(text, "tag", 0)
    Functions.TagTokenAt(text, "tag", 1, 1)
    Functions.TagTokenCount(text, "tag")
    Functions.TagReplace(text, "tag", "replace", 0)
    

    Eventsheet cheatsheet

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"group","disabled":false,"title":"BBCode Match","description":"","isActiveOnStart":true,"children":[{"functionName":"TagAt","functionDescription":"","functionCategory":"","functionReturnType":"string","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[{"name":"text","type":"string","initialValue":"","comment":"The text to search within."},{"name":"tag","type":"string","initialValue":"","comment":"The BBCode tag name to match."},{"name":"index","type":"number","initialValue":"0","comment":"Zero-based index of the tag occurrence to retrieve."}],"eventType":"function-block","conditions":[],"actions":[{"type":"comment","text":"example: This is [u][tag]Hello[/tag][/u] string.\nTagAt(text, \"tag\", 0)\nreturn: [b]Hello[/b]"},{"type":"script","script":"const {text, tag, index} = localVars;\nconst result = matchBBCode(text, tag, index);\nruntime.setReturnValue(result.content);"}]},{"functionName":"TagTokenAt","functionDescription":"","functionCategory":"","functionReturnType":"string","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[{"name":"text","type":"string","initialValue":"","comment":"The text to search within."},{"name":"tag","type":"string","initialValue":"","comment":"The BBCode tag name to match."},{"name":"index","type":"number","initialValue":"0","comment":"The occurrence index of the tag to replace. 0 indicates replace all; 1 for the first occurrence, and so on."},{"name":"part","type":"number","initialValue":"0","comment":"Zero-based index of the part to return."}],"eventType":"function-block","conditions":[],"actions":[{"type":"comment","text":"example: This is [u][tag]Hello[/tag][/u] string.\nTagTokenAt(text, \"tag\", 0, 1)\nreturn: [b][tag]Hello[/tag][/b]"},{"type":"script","script":"const {text, tag, index, part} = localVars;\nconst result = splitBBCode(text, tag, index, part);\nruntime.setReturnValue(result);"}]},{"functionName":"TagTokenCount","functionDescription":"","functionCategory":"","functionReturnType":"number","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[{"name":"text","type":"string","initialValue":"","comment":"The text to search within."},{"name":"tag","type":"string","initialValue":"","comment":"The BBCode tag name to match."}],"eventType":"function-block","conditions":[],"actions":[{"type":"comment","text":"example: a [u][tag]Hello[/tag][/u] and [u][tag]World[/tag][/u] string.\nTagTokenCount(text, \"tag\")\nreturn: 2"},{"type":"script","script":"const {text, tag} = localVars;\nconst result = tokenCountBBCode(text, tag);\nruntime.setReturnValue(result);"}]},{"functionName":"TagReplace","functionDescription":"","functionCategory":"","functionReturnType":"string","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[{"name":"text","type":"string","initialValue":"","comment":"The text to search within."},{"name":"tag","type":"string","initialValue":"","comment":"The BBCode tag name to match."},{"name":"rep","type":"string","initialValue":"","comment":"Content to replace the matched tag with; supports `$1` for the parameter and `$2` for the content."},{"name":"index","type":"number","initialValue":"0","comment":"Occurrence index of the tag to replace; `0` replaces all, `1` for the first, and so on."}],"eventType":"function-block","conditions":[],"actions":[{"type":"comment","text":"example: This is [u][tag]Hello[/tag][/u] string.\nTagReplace(text, \"tag\", [b]\"$2 World\"[/b], 0)\nreturn: This is [b]Hello World[/b] string."},{"type":"script","script":"const {text, tag, rep, index} = localVars;\nconst result = replaceBBCode(text, tag, rep, index);\nruntime.setReturnValue(result);"}]}]}]}

    ImportsForEvents.js

    /**
     * Matches all occurrences of a specified BBCode tag in the text and returns an array of match results.
     *
     * @param {string} text - The input text to search within.
     * @param {string} tagName - The BBCode tag name to match.
     * @returns {Array} Array of match result objects, each containing tagName, param, and content.
     */
    function matchAllBBCode(text, tagName) {
     const regex = new RegExp(`\[${tagName}(?:=([^\\]]+))?\\]([\\s\\S]*?)\[\\/${tagName}\\]`, 'g');
     return [...text.matchAll(regex)].map(match => ({
     tagName,
     param: match[1] || null,
     content: match[2],
     }));
    }
    
    
    /**
     * Matches the BBCode tag at the specified index in the text and returns the match result.
     *
     * @param {string} text - The input text to search within.
     * @param {string} tagName - The BBCode tag name to match.
     * @param {number} index - Zero-based index of the tag occurrence to retrieve.
     * @returns {Object|null} Match result object or null if not found.
     */
    function matchBBCode(text, tagName, index) {
     return matchAllBBCode(text, tagName)[index] || null;
    }
    
    
    /**
     * Replaces specified BBCode tags in the text with new content, supporting references to matched groups.
     *
     * @param {string} text - The original text to search within.
     * @param {string} tagName - The BBCode tag name to match.
     * @param {string} replacement - Content to replace the matched tag with; supports `$0` for the full match, `$1` for the parameter, and `$2` for the content.
     * @param {number} index - Occurrence index of the tag to replace; `0` replaces all, `1` for the first, and so on.
     * @returns {string} Text with the specified BBCode tags replaced.
     */
    function replaceBBCode(text, tagName, replacement, index) {
     const regex = new RegExp(`\[${tagName}(?:=([^\\]]+))?\\]([\\s\\S]*?)\[\\/${tagName}\\]`, 'g');
     let matchCount = 0;
     return text.replace(regex, (match, p1, p2) => {
     matchCount++;
     return (index === 0 || matchCount === index)
     ? replacement
    	 .replace(/\$0/g, match)
    	 .replace(/\$1/g, p1 || '')
    	 .replace(/\$2/g, p2)
     : match;
     });
    }
    
    
    /**
     * Splits the text based on the specified BBCode tag and retrieves parts according to the tagIndex and partIndex.
     *
     * @param {string} text - The original text to split.
     * @param {string} tagName - The BBCode tag name to match.
     * @param {number} tagIndex - Specifies which tag occurrence to split by. `0` for all matches, `1` for the first tag only.
     * @param {number} partIndex - The part to return: 0 for the text before the tag, 1 for the tag itself, and 2 for the text after the tag.
     * @returns {string|null} The extracted part or null if not found.
     */
    function splitBBCode(text, tagName, tagIndex, partIndex) {
     const regex = new RegExp(`(\[${tagName}(?:=[^\\]]+)?\\][\\s\\S]*?\[\\/${tagName}\\])`, 'g');
     const parts = text.split(regex).map(part => part.trim());
    
     if (tagIndex === 0) {
     return parts[partIndex] || null;
     }
    
     if (tagIndex === 1) {
     if (partIndex === 0) return parts[0];
     if (partIndex === 1) return parts[1];
     if (partIndex === 2) return parts.slice(2).join(' ');
     }
     return null;
    }
    
    
    /**
     * Counts the occurrences of a specified BBCode tag in the text.
     *
     * @param {string} text - The original text to search within.
     * @param {string} tagName - The BBCode tag name to count.
     * @param {number} tagIndex - returns the match count;
     * @returns {number} The count based on tagIndex.
     */
    function tokenCountBBCode(text, tagName) {
     const regex = new RegExp(`\[${tagName}(?:=[^\\]]+)?\\][\\s\\S]*?\[\\/${tagName}\\]`, 'g');
     const matches = [...text.matchAll(regex)];
     return matches.length;
    }
    
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