I would like to completely delete a BlackBoard variable in lua as it causing me grief in md script plus its cluttering up the manager object un-necessarily
<do_if value="@$Manager.$TestVar"> remains true even if $TestVar is empty
but there is no RemoveNPCBlackboard or DeleteNPCBlackboard command
Code: Select all
local testtable = {}
table.insert(testtable, "dummydata")
SetNPCBlackboard(menu.manager, "$TestVar", testtable)
local readbacktable = GetNPCBlackboard(menu.manager, "$TestVar")
DebugError("Read back " .. tostring(readbacktable[1]) .. " " .. #readbacktable)
SetNPCBlackboard(menu.manager, "$TestVar", nil)
readbacktable = GetNPCBlackboard(menu.manager, "$TestVar")
DebugError("Read back " .. tostring(readbacktable[1]) .. " " .. #readbacktable)
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
I then tried
SetNPCBlackboard(menu.manager, "$TestVar", "")
which gives
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back nil 0
[General] ======================================
which means that it blanked it but it still exists and has zero entries
how do I do it ?
jth
EDIT
I have manged to recreate a work around in md script that detects missing or empty list
<do_if value="$Manager.$TestVar? and $Manager.$TestVar != '' ">
which keeps me going but my save games could do with an answer on completely deleting variables from the BlackBoard please
EDIT2
The lua code is having the same problem as the md code where its interpreting an empty table variable from the BlackBoard as an empty string so had to code round that too. Yuck