CODE
----------------------------------------------------------------------------------------------------------
-- Name: TLuaStorageTest.lua
-- Author: Intellipool AB
-- Version: 1.0
-- Date: 2006-03-07
-- Description: Example of how to use the TLuaStorage class
----------------------------------------------------------------------------------------------------------
Storage = TLuaStorage:new();
-- Create a new item, this would normaly be done if the first iteration
sName = GetObjectAddress();
-- Note that we are using the object address (that should be unique enough) as the name of the storage item
if Storage:CreateItem(sName,"test","10",string.len("10")) == false then
print("Item already created");
end
-- Find the recently created item and print it, the first iteration it will
LuaItem = Storage:FindItem(sName,"test");
print("\nBefore update:");
print(LuaItem.m_Key);
print(LuaItem.m_Name);
print(LuaItem.m_pData);
-- Update the item
Number = tonumber(LuaItem.m_pData);
Number = Number + 10;
Data = tostring(Number);
Storage:UpdateItem(sName,"test",Data,string.len(Data));
LuaItem = Storage:FindItem(sName,"test");
print("\nAfter update:");
print(LuaItem.m_Key);
print(LuaItem.m_Name);
print(LuaItem.m_pData);
-- Name: TLuaStorageTest.lua
-- Author: Intellipool AB
-- Version: 1.0
-- Date: 2006-03-07
-- Description: Example of how to use the TLuaStorage class
----------------------------------------------------------------------------------------------------------
Storage = TLuaStorage:new();
-- Create a new item, this would normaly be done if the first iteration
sName = GetObjectAddress();
-- Note that we are using the object address (that should be unique enough) as the name of the storage item
if Storage:CreateItem(sName,"test","10",string.len("10")) == false then
print("Item already created");
end
-- Find the recently created item and print it, the first iteration it will
LuaItem = Storage:FindItem(sName,"test");
print("\nBefore update:");
print(LuaItem.m_Key);
print(LuaItem.m_Name);
print(LuaItem.m_pData);
-- Update the item
Number = tonumber(LuaItem.m_pData);
Number = Number + 10;
Data = tostring(Number);
Storage:UpdateItem(sName,"test",Data,string.len(Data));
LuaItem = Storage:FindItem(sName,"test");
print("\nAfter update:");
print(LuaItem.m_Key);
print(LuaItem.m_Name);
print(LuaItem.m_pData);