Jump to content

Keep Reference in Inventory


Recommended Posts

i have been trying to remove a certain item if some conditions are met. this is pretty easy but since the player might have several of these items in his inventory and i have to use this exact id it needs to have a reference from which i can acess it in the inventory. i thought that something like this could work

scn blabla

ref myitem
short init
float fQuestDelayTime

begin gamemode
   if ( init == 0 )
      set init to 1
      set fQuestDelayTime to 0.0001
      set myitem to player.additem item01 1
   endif
   if ( init == 1 ) && ( iskeypressed3 48 )
      set init to 2
      player.removeitem myitem 1
   endif
end
      

adding the item is no problem at all but when i want to delete it by pressing b it seems like it can't access the reference anymore. does the reference get removed by picking it up? is there another way of doing it? please help

Edited by flamingaxe
Link to comment
Share on other sites

Where did you get the idea from "AddItem" would return anything? Even if it would, as you can pass an arbitrary number of items to add in as the second parameter, what would the return be? The first, the last, an array of ids?

Don't know why it still compiles to begin with, but I'd bet my monthly wages that "myitem" is "0" after the AddItem call.

 

Actually the situation is quite a bit more complex/difficult in Oblivion scripting, as you'll loose every reference the very moment an item gets picked up or dropped.

An item lying on the ground can have a reference id, but the moment you pick it up, once the item is inside your inventory, the reference is no longer valid. It's an "inventory reference" from that point on.

The same goes in the reverse case. An item inside your inventory might have a specific inventory reference id, but the very moment it's dropped it's no longer an inventory reference to begin with, but a new-spawned world object instance again.

 

I don't know much about working with inventory references myself, yet, apart from the few things I had to learn for what my scripting approaches needed to achieve, but there are ways to, by use of OBSE functions, obtain the inventory reference id of a specific item inside your inventory, and, unless it's dropped, it will be accessible through that.

You can also put a script onto the item itself and use "RemoveME" to make it remove itself, once a specific condition is met. Just keep in mind, the moment RemoveMe is called, the rest of the script won't execute anymore. It acts like a "return" and aborts the script.

 

I'm not quite sure, which approach would be the best suited for your intended goal though. So maybe, if you'd elaborate some more, people might have better ideas what you could use.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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