Starfinder Playlist
  1. #1

    Splitting stubborn data that doesn't want to split

    So i'm currently trying to obtain data contained within combattracker.list.id-XXXXX.
    when I print my variable this is what i get

    combattracker-list.PNG

    now what I haven't shown what i've attempted to do with it. I'm trying to split the values up and StringManager.split() doesn't do anything. the for loop i use earlier works but the second for loop which is identical in structure won't ever process it seems.

    Code:
    function onCall()
    	local tokenCT = CombatManager.getCombatantNodes(); --{ s'id-*****' = databasenode = {combattracker.list.id-***** }, s'id-*****' = databasenode = {combattracker.list.id-***** }}
    	Debug.console(tokenCT);
    	for i, v in ipairs(tokenCT) do
    		Debug.console(v);
    	end
    	
    end
    Can someone help me? no output is being displayed for the value of tokenCT during the for loop. trying to figure out why/how to fix it..
    FG License: Unity Ultimate License
    Timezone: -5 EST/EDT

  2. #2
    I cannot explain why, but change "ipairs" to "pairs". Using "ipairs" seems to never go into the loop. Using "pairs" does. (Maybe one of the nodes is nil? Cannot really explain it. But using your exact code, pairs works and ipairs does not.)

  3. #3
    I was thinking pairs might work, but given my limited knowledge I assumed I was incorrect.
    FG License: Unity Ultimate License
    Timezone: -5 EST/EDT

  4. #4
    I just looked it up (and this might be right or wrong), it looks like ipairs will look in the table assuming the items are indexed starting at 1. So tokenCT[1], tokenCT[2], etc. However, tokenCT is actually indexed with the node number (tokenCT["id-00002"], tokenCT["id-00001"], etc.) Therefore, you need to use pairs which does not make assumptions about the indexing. (Again, that is how I interpret it, but I could be wrong.)

  5. #5
    Omg that makes so much sense to pairs and impairs then any other explanation I've read. Lol
    FG License: Unity Ultimate License
    Timezone: -5 EST/EDT

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in