Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-11-2008, 08:55 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Mudlib

I've decided to create one, they're alot of fun actually. However, I'm stuck on one part!

HTML Code:
function onCreated() {
  temp.folder.loadFolder("mudlib/*", 1);
  for (temp.e: folder) {
    temp.i = e.tokenize("/");
    if (!i[2].ends(".txt")) continue;
    
    temp.d = new TStaticVar();
    d.loadvars("mudlib/" @ e);
    
    makevar("item_" @ d.realname).destroy();
    makevar("item_" @ d.realname) = new TStaticVar();
    for (temp.f: d.getdynamicvarnames()) {
      if (f.starts("#")) continue;
      makevar("item_" @ d.realname).(@ f) = d.(@ f);
    }
    echo("MUD: Created Item-:" SPC d.displayname); 
    d.destroy();   
  }
}
So this is what creates my mudlib, it works fine! [There are no problems here]

HTML Code:
public function onItem(temp.itemname, temp.amount) {
  temp.data = makevar("item_" @ itemname);
  if (data == null) return false;
  
  temp.i = (this.onGetItemCount(itemname) + amount);
  if (i =< 0) {
    this.client.("i_" @ itemname) = null;
    this.clientr.itemnames.remove(itemname);
    ("i_" @ itemname) = null;
  } else {
    data.itemamount = max(1, i);
    
    this.client.("i_" @ itemname) = new TStaticVar();
    this.client.("i_" @ itemname).copyfrom(data);
    ("i_" @ itemname) = data;
    
    if (!(itemname in this.clientr.itemnames))
      this.clientr.itemnames.add(itemname);
  }
  echo("Amount:" SPC this.onGetItemCount(itemname));
}
  
public function onGetItemCount(temp.itemname) {
  return this.onGetItemStat(itemname, "itemamount");
}

public function onGetItemStat(temp.itemname, temp.flag) {
  return ("i_" @ itemname).(@ flag);
}
Here is the problem, when I am giving the player an item
player.onItem("Item Name", amount);
it's not saving the client.flag in the players attributes. Maybe I'm doing the object copying part wrong, I don't quite know!
Any suggestions?
Reply With Quote
 


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 01:09 PM.


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