5E Character Create Playlist
  1. #1

    Help me locate and delete nodes...

    I'm iterating through database entries that I've created trying to delete them and I must be doing something wrong. Here is my code and the database:

    Code:
    	for k, v in pairs(ztWindowRecordList.getChildren()) do
    		if (DB.getValue(v, "windowNodePath") == sWindowNodePath) and (DB.getValue(v, "windowClass") == cWindowClass) then
    			DB.deleteChild(v, k);
    		end
    	end

    and

    Code:
    	<DM_ZTabber>
    		<ztabber_window_list>
    			<id-00001>
    				<windowClass type="string">masterindex</windowClass>
    				<windowNodePath type="string">tables</windowNodePath>
    			</id-00001>
    			<id-00002>
    				<windowClass type="string">table</windowClass>
    				<windowNodePath type="string">tables.id-00001</windowNodePath>
    			</id-00002>
    		</ztabber_window_list>
    	</DM_ZTabber>


    The database looks exactly how I want it. What I want to do is now delete, say, the entry with id-0002 if the data in "windowClass" and "windowNodePath" match some variable information in my script (sWindowNodePath and cWindowClass).

    I'm pretty sure I'm doing something wrong because the data never gets deleted from the DB.

    Thanks.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,684
    Blog Entries
    1
    make sure you hit /save after doing it - fg runs from an in memory DB and writes to disk every 5 mins
    is the code right? i dont know

  3. #3
    Quote Originally Posted by damned View Post
    make sure you hit /save after doing it - fg runs from an in memory DB and writes to disk every 5 mins
    is the code right? i dont know
    I have been.

    Does the code look right?

  4. #4
    Duh.

    I was doing it wrong.

    Here's the corrected code for future reference:


    Code:
    	for k, v in pairs(ztWindowRecordList.getChildren()) do
    		if (DB.getValue(v, "windowNodePath") == sWindowNodePath) and (DB.getValue(v, "windowClass") == cWindowClass) then
    			DB.deleteChild(ztWindowRecordList, k);
    		end
    	end

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
  •  
STAR TREK 2d20

Log in

Log in