Can anyone tell me how I could make a code that checks all the items in a users inventory for items with the suffix "Broken" and then does an action to these items.
Thank you for any help.
ID:176724
![]() Dec 16 2002, 10:38 am
|
|
ShadowBlade6300 wrote:
How can I make that chack automaticaly all the time? An automatic check is probably not what you really need. If a proc runs over and over to check on these things it goes through a process called "polling", which means it's running a lot of the time just to check to see if it has something to do. This is a waste of cycles and will be much worse if more objects are in use. What you need to do is simply use procs to handle the change of status for the item, and call those procs instead of changing vars manually. obj/item Lummox JR |
ShadowBlade6300 wrote:
Can I check this when the user loggs in? You sure can--although if the equipment saved properly, it's probably not necessary. The place to do this would be in mob/Login(), or mob/Read() (an override of the standard Read() routine used to load from a savefile). You can double-check the suffix at any other time, too. Any time the item's damage status changes, all you have to do is call the right proc. (The proc I provided will actually set the damage stat for you.) You'd use a similar method to control health meters and HUD displays. Any time the status of the item in question is changed in any way (for example, a health meter could change after healing or taking damage in battle), it should be updated via such a proc. Lummox JR |
One example:
mob
proc
check_broken_items()
for(var/obj/O in contents)
if(O.suffix == "Broken")
O.icon_state = "ruined"