It is currently Mon Dec 01, 2008 9:05 am

All times are UTC - 8 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: npc.template
PostPosted: Thu Sep 07, 2006 2:48 pm 
Offline

Joined: Wed Aug 30, 2006 5:24 pm
Posts: 82
Location: Italy
A member "template" in npc like:

me.template := FindConfigElem(ReadConfigFile(":*:npcdesc"), Filter(me.npctemplate));

where Filter(me.npctemplate) is a function that remove package name in npctempalte is template is defined in to package and non in config/npcdesc.cfg....

_________________
Admin/Scripter Innominabile
ZuluHotelItalia shard on m4d


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 13, 2006 10:30 am 
Offline
POL Core Developer

Joined: Mon Jan 30, 2006 9:28 am
Posts: 292
Location: Germany, Bavaria
why not a core function like FullShard(shardname) ?

sorry...

Shinigami


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:10 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
CoreChanges.txt
Quote:
September 14, 2006
Added - CoreShard.em.
Contains over a hundred billion functions.
See file for more information.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:21 pm 
Offline

Joined: Mon Jun 19, 2006 4:48 pm
Posts: 79
cant you just use splitwords with the ":" spliter and get the last return?

owned by austin and shini i gotta add


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 6:09 pm 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 843
Location: Bowling Green, KY
....................

interesting feature

....................

Find() and Splitwords() are a better idea to me. Since the addition of a delimeter in the SplitWords() function, that gives you all the power you need to do what you want with this,without an all new, cutie pie function in the core to do it.

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 3:23 am 
Offline

Joined: Mon Jun 19, 2006 4:48 pm
Posts: 79
SplitWords(template, ":")[SplitWords(template, ":").size()];

;)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 3:28 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
From npcutil.inc in the brain AI...
Helps with the pol/config/npcdesc.cfg and packaged npcs..

Code:
/* $Id: npcUtil.inc 373 2006-06-17 18:27:33Z austinheilman $
*
*/
/*===============================================================
* Current Version
* NPCUTIL.INC - v1.0
* Updated 8/31/2005 4:23AM
*
* -- Revision v1.0 --
* Austin:
*  Created include file
===============================================================*/

use uo;
use os;
use polsys;
use cfgfile;

/*
* NPC_ParseTemplateName(template_name)
*
* Purpose
* Finds the appropriate npcdesc.cfg to load.
* This enables npcs to be placed in packages and not just the ::npcdesc file.
* ReadConfigFile(":*:npcdesc") does not work in this case because packaged npcs
* have the package name at the begining of their .npctemplate member. Reading the
* specific config file - helps to avoid possible elem name collisions.
*
* Parameters
* template_name:   Name of the npc template to parse
*
* Return value
* Returns struct .package .template
*
*/
function NPC_ParseTemplateName(template_name)
   if ( template_name.IsA(POLCLASS_NPC) )
      template_name := template_name.npctemplate;
   endif

   //Find positions of ":" characters
   var colon_a := Find(template_name, ":", 1);
   var colon_b := Find(template_name, ":", 2);

   var parsed := struct{"package", "template"};

   if ( !colon_a || !colon_b )
      //Not a complete package name - use default npcdesc.cfg
      parsed.package := "";
      parsed.template := template_name;
   else
      parsed.package := template_name[colon_a+1, colon_b-2];
      parsed.template := template_name[colon_b+1, Len(template_name)];
   endif

   return parsed;
endfunction

/*
* NPC_GetNPCConfig(template)
*
* Purpose
* Retrieves a config elem for an npc template.
*
* Parameters
* info:   Template info from NPC_ParseTemplateName()
*
* Return value
* Config elem reference
*
*/
function NPC_GetNPCConfig(template)
   if ( !template.package )
      template := NPC_ParseTemplateName(template);
   endif

   var npc_cfg := ReadConfigFile(":"+template.package+":npcdesc");
   if ( npc_cfg.errortext )
      return error{"errortext":="Error::NPC_GetNPCConfig() - Could not open :"+template.package+":npcdesc ->"+npc_cfg.errortext};
   endif

   var cfg_elem := npc_cfg[template.template];
   if ( cfg_elem.errortext )
      return error{"errortext":="Error::NPC_GetNPCConfig() - Could not find elem ["+template.template+"] ->"+cfg_elem.errortext};
   endif

   return cfg_elem;
endfunction

/*
* NPC_GetAllTemplateNames()
*
* Purpose
* Retrieves a list of all npc templates in the shard's npcdesc.cfg files
*
* Parameters
*
* Return value
* Returns an array
*
*/
function NPC_GetAllTemplateNames()
   var elem_names := array{};
   elem_names := elem_names + GetConfigStringKeys(ReadConfigFile("::npcdesc"));
   foreach package in (Packages())
      if ( package.npcdesc )
         var pkg_name := ":"+package.name+":";
         foreach template_name in (GetConfigStringKeys(ReadConfigFile(pkg_name+"npcdesc")))
            elem_names.Append(pkg_name+template_name);
            SleepMS(2);
         endforeach
      endif
      SleepMS(2);
   endforeach

   return elem_names;
endfunction

_________________
-Austin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl