Scriptname emObjectCoinPurseScript Extends ObjectReference Int GoldCount = 0 ; 小銭入れの中に入っている金額 Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) debug.trace(Self + " " + akNewContainer + " " + akOldContainer) Actor kPlayerRef = Game.GetPlayer() MiscObject kGold = Game.GetForm(0xF) as MiscObject if akNewContainer ; いずれかのコンテナに入れられた if akNewContainer as Actor == kPlayerRef ; プレイヤーが入手したのなら、小銭入れの中に入っているゴールドを取り出す if GoldCount kPlayerRef.AddItem(kGold, GoldCount) endif ; 小銭入れは回収(削除)する kPlayerRef.RemoveItem(Self.GetBaseObject(), abSilent = true) else ; プレイヤー以外のコンテナに入れられたのなら、コンテナ内のゴールドを数える Int iCount = akNewContainer.GetItemCount(kGold) ; ゴールドが見つかったら回収(削除)して小銭入れの中に入れる if iCount akNewContainer.RemoveItem(kGold, iCount, abSilent = true) GoldCount += iCount endif endif else ; コンテナから外に出された(Cellに置かれた) endif EndEvent