View Single Post
10-01-22, 11:23 AM   #3
glupikreten
A Theradrim Guardian
Join Date: Apr 2009
Posts: 60
Thank you .. but it doesn't go thru if...

It is not considered as "FRAME and FRAME" but "string with spaces" if you know what i mean.

i ended up doing this... this seems to be working

lua Code:
  1. local keywords = {
  2.     ["and"] = "and",
  3.     ["or"] = "or",
  4. }
  5.  
  6. function f(condition, callback)
  7.     condition_table = {}
  8.     condition_table['and'] = {}
  9.     condition_table['or'] = {}
  10.  
  11.     condition:gsub(
  12.         '[_%w]+',
  13.         function(word)
  14.             -- return keywords[word] or string.format("_G[%q]", word)
  15.             -- text.keywords[word] = string.format('_G[%q]', word)
  16.             if keywords[word] then
  17.                 next_keyword = keywords[word]
  18.             else
  19.                 if next_keyword then
  20.                     table.insert(condition_table[next_keyword], word)
  21.                 else
  22.                     table.insert(condition_table, word)
  23.                 end
  24.             end
  25.         end
  26.     )
  27.  
  28.     for k, v in ipairs(condition_table) do
  29.         c = _G[v]
  30.     end
  31.     for k, v in ipairs(condition_table['and']) do
  32.         c = c and _G[v]
  33.     end
  34.     for k, v in ipairs(condition_table['or']) do
  35.         c = c or _G[v]
  36.     end
  37.  
  38.     if(c) then
  39.         callback()
  40.     end
  41. end

I'm faaaaar from lua developer.. I'm struggling a lot... so if anyone have better solution I'm game

Last edited by glupikreten : 10-01-22 at 12:04 PM.
  Reply With Quote