Jump to content

nested reference


Recommended Posts

i'm in the midst of making a mod that's already been done, but i can't get that mod to work.

any who, feel i've got stuck with nesting ref calls.

what i would like to do:

set someActorRef to getFirstRef 69 1

Label 100

if someActorRef

 

set someInvRef to getFirstRef 70 1 <-- i need this confined to the someActorRef
Label 101
if someInvRef

 

moveTo someContainer

 

getNextRef
goto 101

 

endif

 

getNextRef

goto 100

 

endif

i just slopped this down trying to convey what i was asking, just ignore the syntax ... i think it's legible enough to know whether this is possible w/ script.

Link to comment
Share on other sites

I'm not sure using this function with type 70 (inventory items) is really what is thought it is.

I for one would rather use the slightly newer inventory reference walking for the second loop to do the trick: http://obse.silverlock.org/obse_command_doc.html#Inventory_Reference

Trying to adapt your script to an example would make it:

ref someActorRef
ref iter
 
set someActorRef to getFirstRef 69 1
Label 100
if someActorRef
    foreach iter <- someActorRef
        iter.RemoveMeIR someContainer
    loop
    set someActorRef to getNextRef
    goto 100
endif


But as you seem to want to remove "all" items from the actor to the container, the good old Vanilla function RemoveAllItems would be a much more performant way to the goal... unless we're talking "unplayable" items here.

ref someActorRef
 
set someActorRef to getFirstRef 69 1
Label 100
if someActorRef
    someActorRef.RemoveAllItems someContainer
    set someActorRef to getNextRef
    goto 100
endif

I'm also not a friend of the Label and GoTo approach, but it has its merits and I can't think up a better way in the short time I got for writing this.

 

Hope it helps.

 

P.S.: Keep those links at hand. The function references are invaluable when it comes to finding the best solution for a specific job.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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