Advertisement
Stiepen

Stupid code

Mar 22nd, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. // Doesn't do stuff when key contains at least one dot
  2.  
  3. private void rawset(LuaTable table, String key, LuaTable value) {
  4.         String tree[] = key.split("\\.");
  5.         LuaTable t = table.opttable(new LuaTable());
  6.         for (int i = 0; i < tree.length; i++) {
  7.             String k = tree[i];
  8.             if (i == tree.length - 1) {
  9.                 t.rawset(k, value);
  10.                 return;
  11.             }
  12.             LuaValue newt = t.get(k);
  13.             if (!newt.istable()) {
  14.                 newt = new LuaTable();
  15.                 t.set(k, newt);
  16.                 System.out.println("Set " + t.tojstring() + "[" + k + "] to " + newt.tojstring() );
  17.             }
  18.             t = (LuaTable) newt;
  19.         }
  20.  
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement