access array from script

0 favourites
  • 2 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Please someone help, as this issue is driving me crazy for days in a row.

    I am very new to scripting, but been able to make it right with the help of gpt, but now, even gpt is tired of this issue and cannot resolve it further.

    I need to update a textbox called textDebug with the first value of the array called NEWScheduleArray. Whatever I (and gpt) do it always gives the same result "scheduleArray.get is not a function"

    right now, after 1000 changes, the code goes like this:

    // Access the NEWScheduleArray instance

    const scheduleArray = runtime.objects.NEWScheduleArray.getFirstInstance();

    // Retrieve the value at position [0, 0] from the array

    const valueAt00 = scheduleArray.get(0, 0); // Correct method to use

    // Access the textDebug Text object instance

    const textDebugObject = runtime.objects.textDebug.getFirstInstance();

    // Update the text of textDebug with the retrieved value

    textDebugObject.text = valueAt00.toString(); // Convert to string if necessary

    What is wrong and how to capture the value 0,0 inside the array?

    Many thanks in advance

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • const valueAt00 = scheduleArray.get(0, 0); // Correct method to use

    It's the incorrect method. The correct method is scheduleArray.getAt(0,0)

    In such cases I always recommend to consult the manual over gpt, because gpt will not be familiar with the API of Construct.

    construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/plugin-interfaces/array

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)