RE: weights of nested containers
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Feb 16, 2004
- 521 views
> -----Original Message----- > From: Michelle Rogers [mailto:michellerogers at bellsouth.net] > Subject: Re: weights of nested containers > > > > That was part of the problem. I only have each thing being > carried have a > number that marks what they are being carried by... I don't > have a sequence > that holds everyone/thing that is being carried. Will I need > to have it > like that? I didn't WANT to do it that way. But, am I going > to have to? > > Currently to find out what is being carried by a person, here is an > example....when the person enters the room, the message say > "<Name> enters." > however I wanted it to say this if they were carrying someone........ > "<name> enters, carring <othername> over their shoulder." This is the > function that generates the part of that message from the > comma on.....This > is how I check to see who's being carried. > > function carrymessage(integer whichplayer) > sequence thecarrymessage,hisher > integer foundit > > > --This is just to determine gender of person entering the room > if mudthings[whichplayer][8][22]=1 then hisher="his" else > hisher="her" end > if > > --Foundit determines if they are carrying anyone at all, so > as to finish the > message, if they are > foundit=0 > thecarrymessage="" > > --mudthings include players, mobiles, objects, and rooms > for x=1 to length(mudthings) do > > --mudthings[x][5] is what "room" this one is in > --mudthings[whichplayer][1] is the id number of the person being > checked, which determines if the "room" is actually that > person, which would > mean they are > carrying this person > if mudthings[x][5]=mudthings[whichplayer][1] then > if length(thecarmessage)<0 then > thecarrymessage=thecarrymessage&", carrying > "&mudthings[whichplayer][2] > else > thecarrymessage=thecarrymessage&" and > "&mudthings[whichplayer][2] > end if > foundit=1 > end if > end for > > if foundit=1 then > thecarrymessage=thecarmessage&" over "&hisher&" shoulder" > end if > > return thecarrymessage > end function > > > To be able to do nested weights...am I going to HAVE to put it into a > sequence, instead of checking each time? > No, of course you don't HAVE to do it that one. I was just suggesting a more efficient method than checking the entire world every time somebody moves into a room. It was just a bit of optimisation. The key thing is to have a way to determine who is carrying what, and you have that already. My algorithm for calculatin the weight will work in either case. -- Derek