Jump to content

What's wrong with this script?


Recommended Posts

Posted

So i'm calling this function 4 times, to replace an NPC's boots, gloves, body armor, and helmet with Nise's bikini armors:

function bikinify(actor caster, form oldarmor, formlist replacements)
   form newarmor = getrandompiece(replacements)
   if(newarmor != none)
      caster.unequipitem(oldarmor,false,true)
      caster.additem(newarmor,1,true)
      caster.equipitemex(newarmor,0,false,false)
      caster.removeitem(oldarmor,1,true)
    endif
endfunction

 
The expected result it that the NPC ends up with a piece of bikini armor for each old armor the function's called on.
 
The actual result is that the NPC ends up naked save for 1 piece of bikini armor, with the rest in inventory unequipped.

 
Any thoughts on why this is?
Posted

no idea

that one give and equip an item on npc without problem

 

function OnEffectStart(Actor akTarget, Actor akCaster)

    ((ShowPoseMenu as form) as uilistmenu).OnInit()
    armor gnd
    int max = armorlist.getsize() as int
    Int i = 0
    while i < max
        gnd=armorlist.Getat(i) as armor
        ((ShowPoseMenu as form) as uilistmenu).AddEntryItem(gnd.GetModelPath(true) as string, -1, -1, true)
        i += 1
    endWhile


    Int ret = ((ShowPoseMenu as form) as uilistmenu).OpenMenu(ClientForm, ClientForm)
    trace ("ret    " +ret)
    int resultInt = ((ShowPoseMenu as form) as uilistmenu).GetResultInt()
    trace("resultint    " + resultint)
    aktarget.additem(armorlist.getat(resultInt))
    aktarget.equipitem(armorlist.getat(resultInt))
    trace (armorlist.getat(resultInt))
endFunction

 

 

Posted

Not too sure, but I think you may need to specify which armour piece on each call of it, so it would do boots on the first call, helm on the second, etc, though to be honest the last significant coding I did was 20 years ago and was assembly code.

 

Though my nasty side of thinking on this makes me think you would need separate functions for each armour piece, and call them 1 by 1.

Posted
I think it is a logic error - no thing of programming.

 

Where and when is variavle oldamor set?

 

4x Call the function and oldarmor is the armor of the last call - for example.

 

Only speculation. For more help, the whole code would be important - not just a function.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...