Difference between revisions of "Talk:RemoveItem"
Jump to navigation
Jump to search
Refresh and Lag notes
imported>GreyWanderer |
imported>Haama (Refresh and Lag notes) |
||
Line 8: | Line 8: | ||
-- [[User:GreyWanderer|Grey]] Nope, you get that wrong. The "calling object" is the container, since the function is run/called on the container, not on the item. One could possibly change ''ObjectID'' into ''ItemID'', but for consistency reasons this should NOT be done, since ObjectID is used widely in the wiki. | -- [[User:GreyWanderer|Grey]] Nope, you get that wrong. The "calling object" is the container, since the function is run/called on the container, not on the item. One could possibly change ''ObjectID'' into ''ItemID'', but for consistency reasons this should NOT be done, since ObjectID is used widely in the wiki. | ||
Note: I also removed the note on the ''retainownership flag'', since it's clearly wrong, as of now. | Note: I also removed the note on the ''retainownership flag'', since it's clearly wrong, as of now. | ||
== Refresh and Lag notes == | |||
The notes come from my experience with the Keychain mod (by the way, credit for the refresh code should go to [[User:mmmpld|mmmpld]] - the code was in there long before I started working on it). I have a section of code that, when the player equips the Keychain, will either remove all the keys from a remote container back to the player (Unhook keys), or move all the keys from the player to the remote container. | |||
<pre>;Take keys on/off the keychain when player equips it (Hook keys). | |||
begin onEquip player | |||
if Mode | |||
;Unhook keys | |||
set Mode to 0 | |||
con_ToggleMenus | |||
P1DkeyContainer02.RemoveAllItems player, 1 ;Still causes lag in inventory menu, but AddItem does no better | |||
con_ToggleMenus | |||
;Equipping and unequipping an item will force the inventory menu to update, showing the keys | |||
if (MenuMode 1002) | |||
message "Unhooked keys from Keychain" | |||
message "Unhooked keys from Keychain" | |||
player.EquipItem P1DKeychain | |||
player.UnEquipItem P1DKeychain | |||
else | |||
message "Unhooked keys from Keychain" | |||
endif | |||
else ;if (Mode == 0) | |||
;Hook keys | |||
set Mode to 1 | |||
set NoKeysRemoved to 1 | |||
con_ToggleMenus | |||
message "Re-hooked keys to Keychain" | |||
message "Re-hooked keys to Keychain" | |||
set InvPos to 0 | |||
Label 2 | |||
set pItem to (player.GetInventoryObject InvPos) | |||
if pItem | |||
if (IsKey pItem) | |||
if (pItem != P1DKeychain) ;&& ((IsQuestItem pItem) == 0) | |||
set KeyCount to (player.GetItemCount pItem) | |||
P1DkeyContainer02.AddItem pItem KeyCount | |||
player.RemoveItem pItem KeyCount | |||
Label 3 | |||
set KeyCount to (player.GetItemCount pItem) | |||
if KeyCount | |||
player.RemoveItem pItem KeyCount | |||
Goto 3 | |||
endif | |||
if NoKeysRemoved | |||
set NoKeysRemoved to 0 | |||
endif | |||
else | |||
set InvPos to (InvPos + 1) | |||
endif | |||
else | |||
set InvPos to (InvPos + 1) | |||
endif | |||
Goto 2 | |||
endif | |||
con_ToggleMenus | |||
;Refresh inventory menu if necessary | |||
if (MenuMode 1002) | |||
if (NoKeysRemoved == 0) | |||
player.EquipItem P1DKeychain | |||
player.UnEquipItem P1DKeychain | |||
endif | |||
endif | |||
endif | |||
end</pre> | |||
If you comment out the ''Refresh inventory menu'' section and try it out in-game (tested with all the non-scripted keys from Oblivion and SI), when the keys are hooked all of the key icons will remain displayed, as if the player still had them. However, if you click on anything in the inventory, close and re-open the inventory, or move to a different tab and back the keys will correctly no longer show. Add back the ''Refresh inventory menu'' section and the keys will correctly disappear without the need to close the menu, etc. | |||
If you comment out the [[con_ToggleMenus]], there will be a noticeable pause/delay in the game (the player avatar stops bouncing). Add them back and the lag disappears. | |||
Finally, if you extend the '''con_ToggleMenus''' section to include the ''Refresh inventory menu'' section, it will no longer refresh the menu.--[[User:Haama|Haama]] 16:07, 23 January 2008 (EST) |