Jump to content

Transferring items from Actor Base Object to Actor ref


ProgMath2

Recommended Posts

I have an actor's Base Object and a reference (of other base) I need to be equipped identically. I tried to use that

 

let aItems := GetBaseItems rBase

foreach aIterator <- aItems

let rTemp := aIterator[item]
let i := aIterator[count]
rActor.Additem rTemp i

loop

 

And that does not work. As well as the 20 other variants I tried in past two hours. For now the only working one is to summon a copy of rBase and duplicateallitems. But it has it's own problems...

 

Now the question.

How in the Almsivi's name can I get an item from aIterator?!

Edited by ProgMath2
Link to comment
Share on other sites

Does it throw an error upright on compiling (a.k.a. saving) or does it just not work during runtime?

 

How is your "rBase" obtained? Is it really a Base Object instead of a reference? I recall NPCs in the game are treated a little differently, chances are their EditorIDs already are the BaseIDs and trying to obtain their Base Objects first will just kill it. Did you try using "rBase" the "reference" way as well already, like "rBase.GetBaseItems"?

 

I'm a little surprised the StringMaps can be indexed without quotes, but it seems that is so, going by the docs at least. Have you tried it with quotes around the indices instead already though, like "aIterator['item']"?

 

Have you tried debugging the iterations' values already by printing each "item" and "count" out to console like in the documentation example?

 

"rActor" is a reference to another NPC I take it. How is that one obtained again?

 

And last but not least I'm not quite sure what exactly "rTemp" will contain, provided everything else works flawlessly. It could either be a specific item's Inventory Reference, likely not going to work as a parameter for "AddItem", or the Base Object instead, in that case it should work though. Aren't there ways to check, or just trial-and-error and obtaining the Base Objects of "rTemp" first before the "AddItem" calls?

Link to comment
Share on other sites

Hoooh! Yes. I've made it work.

Thanks for your answer, DrakeTheDragon, it helped me very much.

 

First of all, during the past tries my script tured into a mess, and I have grown too dizzy to notice it. In my message here i wrote 'GetBaseItems rBase', when in my code was 'rBase.GetBaseItems', like if rBase was a reference.

Second. The quotes. Despite of the example in the official manual, my game does not like 'aItems[0][item]' syntax. 'aItems[0]["item"]' works.

Third, I've replaced 'foreach' with common 'while i < max'. Don't know if the 'foreach' is connected to the errors, but i don't trust it anymore.

One last thing is left to do: to catch leveled lists in that array and calculate the result item before adding it to an actor. But I will do that the other time.

So in case someone will have the similiar problems, here's the code of running through a Base Object's inventory:

 

let aItems := GetBaseItems rBase
let i := 0
let iLast := ar_last aItems
while i <= iLast
let rTemp := aItems["item"]
let iTemp := aItems["count"]
rActor.Additem rTemp iTemp
let i += 1

loop

Edited by ProgMath2
Link to comment
Share on other sites

  • Recently Browsing   0 members

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