Aller au contenu

Photo

loop question


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
Edit: can someone show me how to make a loop using my loop below for object oItem to be whats equipped in helm, chest, main hand, off hand, cloak, gauntlet, and helm slots in turn? after it has run though all of  those slots each 1 time no longer run the loop.

if not no big deal just thought looping it would save lines in the include file of my in progress upgrade of my item leveling system http://nwvault.ign.c...=198690&id=3807 .

since the way it is now i have it do whats in in that do loop at the section refering to those slots not in a loop and it works how i want it to but was wondering if i could reduce the number of lines total by looping this section since its used 7 times to do the same exact thing for a different item slot each time.

this is what i mean by item slot

 
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, GetLastKiller());


do
{

//setting the item's orginal name
        if (GetLocalInt(oItem, "Killed")== 0)
        {
            SetLocalInt(oItem, "Killed", 1);
            SetLocalString(oItem, OriginalName, GetName(oItem));
        }
        //rename the items based on their levels
        sNewName = GetName(oItem,TRUE);
        if (GetLocalInt(oItem, "itemlevel")> 1) SetName(oItem, (sNewName + " Level " + IntToString(GetLocalInt(oItem, "nItemLevel"))));

} while (GetIsObjectValid(oItem));


Modifié par Ryuhi2000, 16 avril 2011 - 02:03 .


#2
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
ignore my question
i was looking over the functions in toolset and found something that was missed by 2 people 3 years ago when that section of code was first written.

those OriginalName lines aren't needed because bioware already has a thing for the original name built into the GetName so that reduces to just 1 line which i can live with at the end of each slots section

if (GetLocalInt(oItem, "itemlevel")> 1) SetName(oItem, (GetName(oItem,TRUE) + " Level " + IntToString(GetLocalInt(oItem, "nItemLevel"))));



#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
ok But since I already have it ready. Here it is.

  int nSlot;
  object oItem;
  for( nSlot = INVENTORY_SLOT_HEAD; nSlot <= INVENTORY_SLOT_LEFTHAND; nSlot++)
  {
    oItem = oItem = GetItemInSlot(nSlot, GetLastKiller());
    if(GetIsObjectValid(oItem))
    {
      //setting the item's orginal name
        if (GetLocalInt(oItem, "Killed")== 0)
        {
            SetLocalInt(oItem, "Killed", 1);
            SetLocalString(oItem, OriginalName, GetName(oItem));
        }
        //rename the items based on their levels
        sNewName = GetName(oItem,TRUE);
        if (GetLocalInt(oItem, "itemlevel")> 1)
          SetName(oItem, (sNewName + " Level " +
                  IntToString(GetLocalInt(oItem, "nItemLevel"))));

    }
  }

#4
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
thanks lightfoot :)

i can use that loop you made for every piece of code that needs run on each slot actualy looked back over it theres a bit i can throw in that to reduce lines further in the include.

the include itself with half the more\\less first and likely only upgrade done be me is a 700 line *wall* with spacing so around 350 lines of actual code since i put 1 blank line before and after one actual code line most of the time. tho the system is customizable for users to change what slots get what properties and theres a on\\off switch for every item slot in game