Author Topic: loop question  (Read 375 times)

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
loop question
« on: April 16, 2011, 02:27:04 am »


               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 .
                     
                  


            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
loop question
« Reply #1 on: April 16, 2011, 03:21:05 am »


               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"))));


               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
loop question
« Reply #2 on: April 16, 2011, 03:38:17 am »


               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"))));

    }
  }
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
loop question
« Reply #3 on: April 16, 2011, 06:31:11 am »


               thanks lightfoot '<img'>

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