PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
npc.template

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
innominabile



Joined: 30 Aug 2006
Posts: 81
Location: Italy

PostPosted: Thu Sep 07, 2006 6:48 pm    Post subject: npc.template Reply with quote

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....

Author Message
Shinigami
POL Core Developer


Joined: 30 Jan 2006
Posts: 292
Location: Germany, Bavaria

PostPosted: Wed Sep 13, 2006 2:30 pm    Post subject: Reply with quote

why not a core function like FullShard(shardname) ?

sorry...

Shinigami

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Thu Sep 14, 2006 7:10 pm    Post subject: Reply with quote

CoreChanges.txt
Quote:

September 14, 2006
Added - CoreShard.em.
Contains over a hundred billion functions.
See file for more information.

Author Message
DeiviD



Joined: 19 Jun 2006
Posts: 79

PostPosted: Thu Sep 14, 2006 7:21 pm    Post subject: Reply with quote

cant you just use splitwords with the ":" spliter and get the last return?

owned by austin and shini i gotta add

Author Message
MuadDib
POL Developer


Joined: 13 Feb 2006
Posts: 830
Location: Indiana, USA

PostPosted: Thu Sep 14, 2006 10:09 pm    Post subject: Reply with quote

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

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.

Author Message
DeiviD



Joined: 19 Jun 2006
Posts: 79

PostPosted: Fri Sep 15, 2006 7:23 am    Post subject: Reply with quote

SplitWords(template, ":")[SplitWords(template, ":").size()];

Wink

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Fri Sep 15, 2006 7:28 am    Post subject: Reply with quote

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

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty