Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-14-2008, 09:52 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
loadIni2() - loadIni() replica

Since I couldn't get loadIni() to work, and I don't want to halt my script until I find out why, I decided to script my own version of it. Should work the exact same way loadIni() is intended too.

PHP Code:
function loadini2(file)
{
  
temp.data.loadlines(file);
  
temp.var = new TStaticVar();
  
  for (
temp.linetemp.data) {
    if (
temp.line.starts("[")) {
      
this.preffix temp.line.substring(1temp.line.length() - 2);
      continue;
    } else if (
temp.line.tokenize("=").size() < 2) continue;
    
    
temp.str temp.line.tokenize("=")[0];
    
temp.var.(@this.preffix).(@temp.str) = temp.line.substring(temp.str.length() + 1temp.line.length());
  }
  
  return 
temp.var;

Use it with:
PHP Code:
this.var = loadIni2(path/to/file/filename.ext); 
Example of .ini file:
PHP Code:
[slotA]
charname=Rawr
level
=17

[slotB]
charname=Roar
level
=
this.var.slotA.charname would echo "Rawr".
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 04-14-2008 at 10:11 PM..
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.