Characters List is Empty

  • #1, by santachaosFriday, 07. March, 11:34 2 weeks ago
    Hello everyone,


    I'm testing some little little scripts for getting into it and preparing the funtions I planned for my game.

    Today I wanted to get a specific character from the characters list to e.g. let him move in the active scene.
    First I wanted to try accessing the characters list and printing all names in the logfile by executing the following code:

    print("Character Count: "..#Characters)
    for i=1, #Characters do
      print(i..": "..Characters.Name)
    end

    But it looks like the Characters list is empty:
    11:26:34.082:Engine Version: 5.3.4 (Build 1245 from Build date: Jan 30 2025)
    11:26:34.082:Time needed for preloading game: 4 msec
    11:26:34.083:No config.ini in C:\Users\santachaos\AppData\Local/EarlyAlphaDemo//config.ini
    11:26:34.092:Using DX11 Subsystem
    11:26:34.338:Initializing graphics interface. Surface size: 1920x1080, render size: 1920x1080
    11:26:34.373:Serialization finished. Needed time: 32 ms
    11:26:34.373:SetupParents finished. Needed time: 0 ms
    11:26:34.373:SortLinks finished. Needed time: 0 ms
    11:26:34.374:Interfaces loaded. Needed time: 1 ms
    11:26:35.380:Scripts loaded. Needed time: 6 ms
    11:26:35.380:Time needed for loading game: 298 msec
    11:26:36.469:Serialization finished. Needed time: 1 ms
    11:26:36.469:SetupParents finished. Needed time: 0 ms
    11:26:36.469:SortLinks finished. Needed time: 0 ms
    11:26:36.470:Serialization finished. Needed time: 1 ms
    11:26:36.470:SetupParents finished. Needed time: 0 ms
    11:26:36.470:SortLinks finished. Needed time: 0 ms
    11:26:37.982:Character Count: 0


    I do not understand why this is happening.
    Is my code incorrect?
    Am I missing something?

    I also added an Screenshot of my last Integrity Check because it is saying that all my Scenes an some of my characters are "not linked anywhere"(?)
    Maybe this is related?


    Thank you for your help

    Christian

    Newbie

    2 Posts


  • #2, by SimonSFriday, 07. March, 11:56 2 weeks ago
    Hello,
    the # operator does not work on the built-in lists, you need to use __len:

    print(Characters.__len)

    Haven't fixed this yet, that it works with #.

    Thread Captain

    1601 Posts

  • #3, by santachaosWednesday, 12. March, 18:01 2 weeks ago
    Hello,
    the # operator does not work on the built-in lists, you need to use __len:

    print(Characters.__len)

    Haven't fixed this yet, that it works with #.

    Hello,

    I tested it today with "Characters.__len" and it worked fine for me.
    Thank you

    Newbie

    2 Posts

Write post