RelicNews Forums

Go Back   RelicNews Forums > RDN - Relic Game Mods > Homeworld 2 - Tanis Shipyards > Archive Dump
User Name
Password
Register FAQ Members List Arcade Mark Forums Read



Reply
 
Thread Tools
Old 29th Jan 06, 6:42 AM Forum Rules   # 1
Mikail
Lost in the Web...
 
Mikail's Avatar
 
Join Date: Jun 2003
Location: %HW2_ROOT%

Table Manipulation Functions

Here's some table manipulation functions I created in Lua:
Code:
-------------------------------------------------------------------------------- -- Returns the length of a table. Useful where the 'getn' function is normally unavailable. function getn(tTable) local nCount = 0 for i, iCount in tTable do nCount = nCount + 1 end return nCount end -------------------------------------------------------------------------------- -- Inserts an item into a table. Useful where the 'tinsert' function is normally unavailable. function tinsert(tTable, Arg1, Arg2) if (Arg2) then local TempTable = {} for i = Arg1, getn(tTable) do TempTable[i + 1] = tTable[i] end for i = Arg1, getn(tTable) do tTable[i + 1] = TempTable[i + 1] end tTable[Arg1] = Arg2 else tTable[getn(tTable) + 1] = Arg1 end end -- Compares two tables and returns true if they're equal and false if they're not. function tcomp(tTable1, tTable2) local same = 1 if (getn(tTable1) ~= getn(tTable2)) then same = 0 else for i, k in tTable1 do if (type(tTable1[i]) == "table") and (type(tTable2[i]) == "table") then same = tcomp(tTable1[i], tTable2[i]) if (same == 0) then break end elseif (tTable1[i] ~= tTable2[i]) then same = 0 break end end end return same end
__________________
Download my HW2 mods, maps & tools. link
Mikail is offline  
Reply



Go Back   RelicNews Forums > RDN - Relic Game Mods > Homeworld 2 - Tanis Shipyards > Archive Dump
User Name
Password
Register FAQ Members List Arcade Mark Forums Read



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




All times are GMT -7. The time now is 4:45 AM.

Page generated in 0.44735193 seconds (38.91% PHP - 61.09% MySQL) with 9 queries

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.