Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jgame.config = {
  2.     _values : JSON.parse (jgame.file_get ('~/default.cfg')),
  3.     getVal : function (key) {
  4.         var ret = this._rGet (key.split ('.'),this._values) ;
  5.         print ("getVal("+key+") = "+ret+"\n") ;
  6.         return ret ;
  7.     },
  8.     setVal : function (key,val) {
  9.         print ("setVal("+key+","+val+")\n") ;
  10.         return this._rSet (key.split ('.'),val,this._values) ;
  11.     },
  12.     _rSet : function (key,val,root) {      
  13.         var step = key.shift () ;
  14.         if (key.length > 0) {
  15.             if (typeof (root [step]) != 'object')
  16.                 root [step] = new Object ;
  17.             return this._rSet (key,val,root [step]) ;
  18.         }      
  19.         return root [step] = val ;
  20.     },
  21.     _rGet : function (key,root) {
  22.         var step = key.shift () ;
  23.         if (key.length > 0 && typeof (root [step]) != 'undefined') {
  24.             return this._rGet (key,root [step]) ;
  25.         }      
  26.         return root [step]  ;  
  27.     }  
  28. } ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement