Monolith Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Hey guys.........
Some functions that can serve I_icon_minitimeFri Sep 09, 2011 4:58 pm by WhiteWolf

» Last to post wins
Some functions that can serve I_icon_minitimeFri Sep 09, 2011 4:57 pm by WhiteWolf

» COMBAT ARMS WOOOOO
Some functions that can serve I_icon_minitimeTue Oct 19, 2010 10:59 pm by viperjake31

» Its over (Bye)
Some functions that can serve I_icon_minitimeWed Sep 22, 2010 10:05 pm by Supanooba

» Sorry guys...
Some functions that can serve I_icon_minitimeWed Sep 22, 2010 10:01 pm by Supanooba

» bad feeling...
Some functions that can serve I_icon_minitimeTue Sep 21, 2010 1:16 pm by Supanooba

» This game...
Some functions that can serve I_icon_minitimeSun Sep 19, 2010 10:01 am by Supanooba

» Me, D@rk T3mpl4r, Hacking?
Some functions that can serve I_icon_minitimeSun Sep 19, 2010 12:36 am by D@rk T3mpl4r

» fractured my arm and leg
Some functions that can serve I_icon_minitimeSat Sep 18, 2010 9:08 pm by Supanooba

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Some functions that can serve

2 posters

Go down

Some functions that can serve Empty Some functions that can serve

Post by Starkkz Fri Jun 11, 2010 3:29 pm

Table Find - Function: find a value in a table
Code:

function table.find(t,v)
   if type(t)=="table" then
      for _, value in ipairs(t) do
         if value == v then
            return true
         end
      end
   end
   return false
end

String Split - Function: split a word every space
Code:

function string.split(t,b)
   local cmd = {}
   if not b then match = "[^%s]+" else match = "[^"..b.."]+" end
   for word in string.gmatch(t,match) do
      table.insert(cmd,word)
   end
   return cmd
end

Sound 3 X, Y - Function: make a sound in a position -- This is made by Me Very Happy
Code:

function sound3(file,x,y)
   for _, id in pairs(player(0,"table")) do
      local dist = math.sqrt((player(id,"x")-x)^2 + (player(id,"y")-y^2))
      if dist < 150 then
         parse("sv_sound2 "..id.." "..file)
      end
   end
end

Starkkz

Posts : 30
Rep : 0
Join date : 2010-06-11

Back to top Go down

Some functions that can serve Empty Re: Some functions that can serve

Post by Debt Wed Jul 07, 2010 8:58 pm

More Powerful Scripts:

Script by weiwen:
Code:

function deepcopy(object)
   local lookup_table = {}
   local function _copy(object)
      if type(object) ~= "table" then
         return object
      elseif lookup_table[object] then
         return lookup_table[object]
      end
      local new_table = {}
      lookup_table[object] = new_table
      for index, value in pairs(object) do
         new_table[_copy(index)] = _copy(value)
      end
      return setmetatable(new_table, getmetatable(object))
   end
   return _copy(object)
end
Imprints all values in a table to another table.

Script by Weiwen:
Code:

function table.tostring( tbl )
   local result, done = {}, {}
   for k, v in ipairs( tbl ) do
      if k ~= 'tmp' then
         table.insert( result, table.val_to_str( v ) )
         done[ k ] = true
      end
   end
   for k, v in pairs( tbl ) do
      if not done[ k ] then
         table.insert( result,
            table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
      end
   end
   return "{" .. table.concat( result, ", " ) .. "}"
end
As many people know, when you try to print a table, it creates a table memory value, unhelpful to the process, this one prints the values in it.

Debt

Posts : 10
Rep : 0
Join date : 2010-06-13

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum