LoobyLoo's Recent Forum Activity

  • Thanks oosyrag It worked.

    Also if you're a beginner, my recommendation is to never use the wait action, ever.

    Please correct me if I'm mistaken, I used wait() for a specific reason. Here in my case, the C3 array is converted from a JSON array, If I don't include wait here, the array always shows 0. However, when I do include wait, the array provides the correct output.

    Or I should use here something else like "wait for signal" or "wait for the previous action to complete"?

  • Thanks for your response, I visited that page already, but I didn't understand it, so I asked the question. I'm getting on colsole

    a reference error: My_Array is not defined

    // My_Array is an array from c3 event (converted from JSON array),I put it on start of the layout, after using 1sec wait.
    
    var valueAt00 = My_Array.getAt(0, 0);
    
    console.log("Value at (0, 0):", valueAt00);
    
  • To manipulate global variables from the Construct 3 event sheet using JavaScript, we do

    // Fetched the data from the Construct 3 global variable to JavaScript
    var jsVariable = runtime.globalVars.c3Variable;
    
    // Store the data in the Construct 3 global variable from JavaScript
    runtime.globalVars.c3Variable = jsVariable;
    
    

    Similarly, What is the direct way to manipulate Arrays in Construct 3 Using JavaScript? What expression I should use?

    Let's say I have an array (JSON array converted into the native array) in Construct 3.

    I want to use JavaScript to add elements to the array, remove elements, or do other things with the array.

  • Construct 3 is really fun.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, R0J0hound, thanks for your suggestions.

    The three areas from which I could extract the text, the Array, Button Animation Name, and the local variable "String_LV"—all contain the same string. That's why I didn't create an instance variable, though I can understand why you're recommending that. I'll attempt to implement your suggestion to streamline the code.

    Initially, I believed it could be accomplished using a function due to the repetitive pattern, such as:

    "+ System: Pick BUTTON where BUTTON.AnimationName = String_LV"

    However, it appears to me now I might have overcomplicated things. I'll try to simplify first and then utilize a function. Thank you to everyone for your time.

    :)

  • oosyrag

    I still have no idea what your buttons are for.

    Sorry, I have updated my previous response with more details, could you please check that, Thank you.

    Also you have a wait for previous action to complete in there, which has no function without an asynchronous action before it. Which you don't, so you're probably misunderstanding something there. All actions are processed in order from top to bottom unless its specified as an asynchronous action.

    Yeah, I have an Array that is converted from a JSON array. At the start of the layout, when that condition is true, it's unable to fetch the Array, because for it needs some more time. So, I thought that instead of use wait 1 sec action, I would use this "wait for previous action ", but it turned out it is unnecessary, thanks for pointing it out.

  • Giving advice is a thankless task.

    I would follow the wish "if it works you don't need to get in the way".

    😅😂

  • Hi, oosyrag, Thanks for your response,

    I think the overall code feels a bit lengthy. For example, there's a repetitive pattern eg.

    "+ System: Pick BUTTON where BUTTON.AnimationName = String_LV"

    However, some of these events also include a "Trigger once" condition. I'm not certain whether we can refactor these into a function to improve efficiency.

    Edit 1.

    Speaking about the code, its purpose is to auto Spawn icons and text on a button on the run time. When the animation name of the button matches the value of "String_LV",

    and for the text, "Button_Name.Button_Name_iv" matches the value of "String_LV", it will Spawn and reposition itself to the button.

    (TextVisibility_iv, Clickable_iv & ICONVisibility_iv are Booleans, if it is true, then it will be executed, in the given code, all are true)

    Having said that the same code will be used in multiple buttons (same button sprite but different instance of button), with only variations in local variables, I posted this question to explore avenues for enhancing efficiency.

  • The above code is working just fine. However, I'm wondering how I can make it more efficient. I'm still learning about functions, and I'm curious if I can enhance their efficiency using a function. Below is how I started. Any suggestions?

  • I'm trying to include the value of a global variable in a JSON array or BBCode. Could anyone please help?

    For E.g.

    (Obviously,

    [@UserName_GV]

    doesn't work; I'm uncertain about the format through which it detects the global variable.)

    Tagged:

  • You do not have permission to view this post

  • So your solution involves an additional Text object (referred to as 'HideText') to store the array text initially. This 'HideText' is then set as the source for the visible text object. When the append button is clicked, the hidden text appends. Subsequently, if the comparison condition is met, the remaining text is extracted from the hidden text object 👏

    I appreciate your solution—it works well, though the solution is a bit lengthy. However, considering there isn't a direct way in C3 to achieve this, it's quite understandable.

    Thank you for your time and help!

LoobyLoo's avatar

LoobyLoo

Member since 10 Jul, 2023

Twitter
LoobyLoo has 1 followers

Trophy Case

  • 1-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

6/44
How to earn trophies