Re: how do you make another field to edit objects?

From: Patrick Dughi (dughi@imaxx.net)
Date: 07/20/00


> For objects, how do you create a new field(using ASCII objects, thank
> you all who helped so much os I could get it up).  such as Short, long,
> and ID.(want to add an id slot).  So immortals can edit it, but players
> cant see it. Only immortals.  what files and such do I need to edit, and
> so on. thank you again for the help.

        I'd help, but after writing a page and a half and realizing that a
full 80% of it was "and then, assuming you have/want/did/know/etc", I
scrubbed it.  I'll need a bit more to go on first.

Most important;

        Can you code.  You will have to code to do this, and you'll have
to figure out what to do for yourself.  This is one of those situations
where we can give you the tools, point you in the right direction, but you
actually have to know what you're doing in the end.  ... It doesn't help
to have people describe how to perform calculus when you haven't a grasp
of arithimitec, and in the same way, our 'help' would be in a different
language for all the good it'd do you.

        Other than that, you say ascii objects.  Are you refering to the
world object file format (.obj), or the rent files of players?  If it's
the rent files for players, did you use a patch (xapobjs?) or hand-write
it.  If it's not ascii rent files, have you prepared the changes in your
obj_data struct to be saved to the normal player rent files?  Do they even
need saving?  What version of circle are you using? Are you running any
particular version/type of OLC?  How do your immortals 'edit' the files
normally ('by hand' ? editing the .obj files directly perhaps?).  What
does the sentence "such as Short, long, and ID." mean?  Are those the
names of the variables you want to edit, or are you alluding to
inexperience with the types of those variables (such as int, long, short,
char, etc)?  Do players normally 'automatically' see everything about an
object, that you would need to take special measures so that they could
not view every piece (like, say, a mush object)?

        I'd cite some line about a crystal ball, but I'm much to tired.

        More information means we can help.  We don't have enough to go on
right now, and it leads me to believe that you may not have the experience
yet to use the help.  I'll try my best though;

Assuming xapobjs, oasis olc, you want to add an 'int' field to an object,
and have it save for players, but it's not set on any random loading
object until a player somehow 'claims' it.

        No problem.

        Edit the structs.h file with the obj_data in it.  Add an int
variable (int id).  Put it next to the timer variable.  As a matter of
fact, go into utils.h and copy the 'GET_OBJ_TIMER' macro, just change the
name to 'GET_OBJ_ID' and have it reference the 'id' instead of 'timer'.

        Now, edit the parse_object() function in db.c.  Have it make sure
that you set the 'id' to something invalid, like -1.  This insures that
all objs loaded from the world files have no owner.

        Now, edit objsave.c.  You're going to find where the 'timer' value
is set and restored, both in save and load functions respectively.  You're
going to copy the way timer is placed, and put id in the save/restore
functions.

        The hard part is last, find the oedit.c file, edit the main menu
(oedit_disp_menu()) and make an entry like the timer has.  Give the new
choice a number or letter, lets say you choose 'Z'.

        Drop down further in the file into oedit_parse().  Set up two
cases 'z' and 'Z' - for letters, just one case for numbers.  Make your
life easy and find the timer section and duplicate it.  It will set a
'mode'.  We haven't defined a new mode for your id yet, but put one in
there anyway.  Timer has OEDIT_TIMER, you'll have OEDIT_ID.

        Go down further in oedit_parse() and find the 'OEDIT_TIMER' case.
Duplicate it, again, for your OEDIT_ID, switching the macro to GET_OBJ_ID,
etc...

        Now open up file that defines 'OEDIT_TIMER'.  It's usually in some
header file.  Add a new entry below that which is of course, OEDIT_ID, and
increment the number so it's different from all the other OEDIT_x cases.

        That's it.

                                                        PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT