10 Aug, 2008, orychle wrote in the 1st comment:
Votes: 0
SO, i have no life so i've decided to devote my non-paying work time to doing some free-work for the creator of the mud i play. Anyway, I am having a bit of trouble finding any kind of general 'dictionary' for some of the code stuff.. I am a fast learner, and learn mor ethrough doing than reading/learning. But i can't seem to find a coder tha has any free time to sit down with me and explain " this code line, means this" etc, etc. Now after a week of piddling around with random codes i've found, i'm starting to snag some of it…and i think im ready to write my own code…which i've already started. anyway..my question: im working on an alteration of the brew code for potion brewing; and i want to set it to where it requires to components for a spell (a container and a spell-specific item, such as an herb, or monster piece like, zombie's toenail/dragon scale, etc). what code 'lingo' causes it to check the inv for component1, component2? I'm *sure* its possible, as a coding friend is the one that actually put the idea into my head…but i can't seem to find the answer i need and she's MIA most times i'm on. So please–any help at all? :(
10 Aug, 2008, Davion wrote in the 2nd comment:
Votes: 0
orychle said:
what code 'lingo' causes it to check the inv for component1, component2? I'm *sure* its possible, as a coding friend is the one that actually put the idea into my head…but i can't seem to find the answer i need and she's MIA most times i'm on. So please–any help at all? :(


Usually when you're starting off, most of what you want to accomplish already exists in some form or another in the code. My guess, is you'd want brew to act as such -> "brew <container> <ingredient1> … <ingredient n>" To check for a component you would use a simple for loop to look for it. Eg.

for( struct obj_data *cont = ch->carrying ; cont ; cont = cont->next_content )
{ if( isname(arg, cont->name ) ) //Content found, do something with it.
}
10 Aug, 2008, orychle wrote in the 3rd comment:
Votes: 0
yeah, that looks about like what i was needing, thanks :D i appreciate it :)
now as soon as cygwin starts behaving, i can set up a localhost testmud to try some things out LOL

thanks again :)
11 Aug, 2008, kiasyn wrote in the 4th comment:
Votes: 0
a linux VM is always better than using cygwin.
11 Aug, 2008, The_Fury wrote in the 5th comment:
Votes: 0
kiasyn said:
a linux VM is always better than using cygwin.


A native port of linux kernel to window tops a VM too, Andlinux is native linux that uses windows as the desktop. I use it for all my day to day linux needs and since discovering it have dumped my dual boot and the vmware setup i had also.
20 Aug, 2008, Sandi wrote in the 6th comment:
Votes: 0
Davion said:
Usually when you're starting off, most of what you want to accomplish already exists in some form or another in the code. My guess, is you'd want brew to act as such -> "brew <container> <ingredient1> … <ingredient n>" To check for a component you would use a simple for loop to look for it. Eg.

for( struct obj_data *cont = ch->carrying ; cont ; cont = cont->next_content )
{ if( isname(arg, cont->name ) ) //Content found, do something with it.
}


I just went through two months of hell trying to track down a bug I'd introduced because of a "bug fix" I found on Darkoth's old site. Now, I think I "get it", but you guys feel free to explain it if I don't.

Here's a bit from the top of act.item.c, ACMD(do_put):
for (obj = ch->carrying; obj; obj = next_obj) {
next_obj = obj->next_content;
if (obj != cont && CAN_SEE_OBJ(ch, obj) &&
(obj_dotmode == FIND_ALL || isname(arg1, obj->name))) {
found = 1;
perform_put(ch, obj, cont);
}


Similar to what Davion posted, but with a keen difference. In this case, the "do something with it" includes removing it from the list we are cycling through. The reason for the "next_obj = obj->next_content;" line is it sets "next_obj" to the proper value before we take it away. (ie, perform_put will remove it from the player's inventory list and add it to the container's content list)

This is often found with objects which are often being moved around from containers to inventory to worn or dropped. So if you're looking to see if the player has the proper herb, and then are going to make it go away because it's been used…

Hope that helps, some.
20 Aug, 2008, David Haley wrote in the 7th comment:
Votes: 0
Yes, this is one of the more unpleasant consequences of embedding the list structure into the objects themselves, instead of having a separate list or even just an iterator encapsulation on top of the object-list. A pretty easy trap to fall into even when you've done so several times before. :wink:
0.0/7