It is currently Mon Jan 05, 2009 6:51 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Storing custom values in itemdesc
PostPosted: Tue Oct 16, 2007 5:10 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
I've been using custom values for items in itemdesc.cfg entries for a while now.
It's not too hard to set and retrieve numbers and strings but how do you set an array (eg as required in the SYSBOOKS distro package)?

Eg in the distro a piece of armour might have:
MedLoss 100
That can be retrieved easily.

But what if you wanted to store an array - eg the Contents of a Sysbook? (I can do it in cprops, but no thanks, I want the array to be stored in the itemdesc.cfg entry once and storing it like a cprop is stored won't work)

Hope someone can help me - otherwise the sysbooks package has a BIG flaw :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 1:09 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
So is this impossible or simply nobody has ever tried to do it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 1:40 am 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 903
Location: Bowling Green, KY
DataFiles are your friends. There is that, or config files using multiple key entries for each page/array elem, and use GetConfigStringArray or whichever it was, hehe.

DataFiles though, are way underused, even in Distro. I say this because, you can store all that stuff in DataFile, and then make an Ingame editor for it all! You could edit medless entries on the fly, book entries for static books on the fly. All those custom things that are script controllable, could be done that way.

Just an idea :)

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 3:22 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
MuadDib, have you looked at the distro sysbooks package? :)

I have no issue with using any form of data file, in fact for individual books the distro sysbook package uses the datastore with the key on the serial number of the book. It works fine.

It's just that if the datastore entry is missing it will then try to read cprops on the item and then finally read the itemdesc entry for the objtype looking for the author, title and contents.

Thus the question. Is sysbooks package trying to do something impossible?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 12:17 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
Well, I wasn't going to let this one beat me.
Only cprops and datafiles seem to store arrays, so to get them into itemdesc you have to store each element of the array separately and use GetConfigStringArray to get them.

This can be made to work with the sysbooks package from the 097 distro.


In Distro\pkg\items\sysbook\book\methods.src around line 250:

Code:
   //If we got this far.. then lets fall back on the itemdesc.cfg
   //Note its read in as :*: which reads in every itemdesc.cfg
   var cfg := ReadConfigFile(":*:itemdesc");
   cfg := cfg[book.objtype];
   if ( prop_name == "Contents" )
      prop_value := GetConfigStringArray(cfg, prop_name);
   else
      prop_value := GetConfigString(cfg, prop_name);
   endif
   if ( prop_value )
      return prop_value;
   endif


The itemdesc entry for each book is now of the form:

Code:
Item 0x7025
{
   ObjtypeName   newbiebook
   desc      Player guide
   Graphic      0xff2
   CreateScript      book/onCreate
   DestroyScript      book/onDestroy
   Script         book/use
   MethodScript      book/methods
   vendorsellsfor   50
   vendorsellsfor   50
   newbie      1

   ReadOnly   1
   IsBook      1
   NumPages   9
   Author      Me I guess
   Title      Guide to This Shard
   Contents   Welcome to my very
   Contents   own shard. This book will
   Contents   try to explain some of
   Contents   the most basic things
etc etc


So if you want to give out a welcome book to each player, and want to use the disto's book package, this is one way to do it without using the 'orrible cprops on each book.

If this is of any value to the distro, let me know. I know MuadDib is a fan of editable datafiles so this might not meet requirements.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 4:58 am 
Offline
Packet Maintainer

Joined: Thu Feb 02, 2006 8:33 am
Posts: 346
Quote:
I've been using custom values for items in itemdesc.cfg entries for a while now.
It's not too hard to set and retrieve numbers and strings but how do you set an array (eg as required in the SYSBOOKS distro package)?


If you want to set an array e.g. for the contents of a book to the itemdesc.cfg you better write the book inside the game first and then copy its contents line from the items.txt to your itemdesc.cfg. Otherwise you have to count a lot of letters :)

It looks this way:
Code:
    cprop contents a3:S14:Welcome to theS12:world of UO.S16:At the beginning


To translate the lines:
a3: an array with 3 members
S14: string with 14 letters follow
S12: string with 12 letters follow
...

Edit: Just found that Yukiko already explained that here:
http://forums.polserver.com/ftopic1874.php


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 5:30 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
Pierce,
I wasn't trying to set cprops, but using itemdesc.cfg for setting arrays on custom entries.
They aren't stored in the same way as cprops or data files. (ie the packed format)

Sorry if I wasn't clear. I think I was getting answers to questions I wasn't asking!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 22, 2007 10:59 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1252
Location: Southern Central USA
*** Warning: Slightly off-topic reply! ***

OnG isn't this similar to the way corpseitem (the items placed on corpses after "skinning" them) was stored on NPCDesc entries for the old Distro?

I am looking at using something very similar to your method for storing material requirements for items that are crafted from more than one material eg.
Code:
Item 0x5678
{
Name             anitem
materials        boards cloth ironingot
materialamt    4 5 6
}

I prefer editing stuff in cfg files rather than gumps anyway.


_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 22, 2007 11:31 pm 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
Yukiko,
Yes in that it's custom entries,
but no, what you posted was stored as a string for splitwords to retrieve. My problem was a little different in that I wanted arrays to be stored.

I realise it was a somewhat odd thing to do and normally I wouldn't even worry about it except that the distro sysbooks package tried to use it but was bugged slightly.

I solved the problem after a lot of trial and error (ie no real clue how to do it) and was able to get books stored in itemdesc entries without resorting to cprops. Now that I see it done, it's kinda useful to know for next time. The 097 distro sysbooks package has been modified to use this and has an example of a book written in itemedesc.cfg custom entries. I figured that someday someone might need to know.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 9:39 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1252
Location: Southern Central USA
It looks like you stored the data pretty much the same way I was thinking of. It's the retrieval method that differs.

I hadn't thought of using the GetConfigStringArray function to retrieve the "materials" list. I would have probably used SplitWords like the Distro had done.

Your method works well when you need to grab a custom member in an array. I'll definitely keep that tucked away in my memory.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl