Partial refactor of merch for multiple shelves
Loads merch onto multiple shelves after loading interior refs.
This commit is contained in:
parent
90087c3056
commit
8eeae0cf64
BIN
Bazaar Realm.esp
BIN
Bazaar Realm.esp
Binary file not shown.
@ -1,13 +1,7 @@
|
||||
scriptname BRMerchActivatorScript extends ObjectReference
|
||||
|
||||
Keyword property BRLinkMerchShelf auto
|
||||
Keyword property BRLinkMerchChest auto
|
||||
Keyword property BRLinkItemRef auto
|
||||
Keyword property BRLinkActivatorRef auto
|
||||
Keyword property BRLinkMerchToggle auto
|
||||
Keyword property BRLinkMerchNext auto
|
||||
Keyword property BRLinkMerchPrev auto
|
||||
Activator property ActivatorStatic auto
|
||||
Actor property PlayerRef auto
|
||||
Quest property BRQuest auto
|
||||
MiscObject property Gold001 auto
|
||||
@ -63,9 +57,10 @@ endEvent
|
||||
function RefreshMerchandise()
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("RefreshMerchandise not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endFunction
|
||||
|
||||
event OnCreateTransactionSuccess(int id, int quantity, int amount)
|
||||
|
@ -103,9 +103,10 @@ endFunction
|
||||
function RefreshMerchandise()
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("RefreshMerchandise not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endFunction
|
||||
|
||||
event OnCreateTransactionSuccess(int id, int quantity, int amount)
|
||||
@ -121,3 +122,22 @@ Event OnCreateTransactionFail(string error)
|
||||
Debug.MessageBox("Failed to buy merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
RefreshMerchandise()
|
||||
endEvent
|
||||
|
||||
event OnLoadMerchandiseSuccess(bool result)
|
||||
Debug.Trace("BRMerchChestScript OnLoadMerchandiseSuccess result: " + result)
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
debug.MessageBox("Successfully loaded shop merchandise")
|
||||
|
||||
; TODO: the assumption that player is in shop cell may be incorrect
|
||||
Cell shopCell = PlayerRef.GetParentCell()
|
||||
while !BRMerchandiseList.ReplaceAll3D(shopCell)
|
||||
Debug.Trace("BRMerchandiseList.Replace3D returned false, waiting and trying again")
|
||||
Utility.Wait(0.05)
|
||||
endWhile
|
||||
endEvent
|
||||
|
||||
event OnLoadMerchandiseFail(string error)
|
||||
Debug.Trace("BRMerchChestScript OnLoadMerchandiseFail error: " + error)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
endEvent
|
@ -1,13 +1,6 @@
|
||||
scriptname BRMerchNextPageScript extends ObjectReference
|
||||
|
||||
Keyword property BRLinkMerchShelf auto
|
||||
Keyword property BRLinkMerchChest auto
|
||||
Keyword property BRLinkItemRef auto
|
||||
Keyword property BRLinkActivatorRef auto
|
||||
Keyword property BRLinkMerchToggle auto
|
||||
Keyword property BRLinkMerchNext auto
|
||||
Keyword property BRLinkMerchPrev auto
|
||||
Activator property ActivatorStatic auto
|
||||
Actor property PlayerRef auto
|
||||
Quest Property BRQuest Auto
|
||||
|
||||
@ -15,10 +8,11 @@ event OnActivate(ObjectReference akActionRef)
|
||||
if akActionRef == PlayerRef
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
bool result = BRMerchandiseList.NextPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.Trace("BRMerchandiseList.NextPage result: " + result)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("BRMerchandiseList.NextPage not implemented yet!")
|
||||
; bool result = BRMerchandiseList.NextPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf)
|
||||
; Debug.Trace("BRMerchandiseList.NextPage result: " + result)
|
||||
; if !result
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endif
|
||||
endEvent
|
@ -1,13 +1,6 @@
|
||||
scriptname BRMerchPrevPageScript extends ObjectReference
|
||||
|
||||
Keyword property BRLinkMerchShelf auto
|
||||
Keyword property BRLinkMerchChest auto
|
||||
Keyword property BRLinkItemRef auto
|
||||
Keyword property BRLinkActivatorRef auto
|
||||
Keyword property BRLinkMerchToggle auto
|
||||
Keyword property BRLinkMerchNext auto
|
||||
Keyword property BRLinkMerchPrev auto
|
||||
Activator property ActivatorStatic auto
|
||||
Actor property PlayerRef auto
|
||||
Quest Property BRQuest Auto
|
||||
|
||||
@ -15,10 +8,11 @@ event OnActivate(ObjectReference akActionRef)
|
||||
if akActionRef == PlayerRef
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
bool result = BRMerchandiseList.PrevPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.Trace("BRMerchandiseList.PrevPage result: " + result)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("BRMerchandiseList.PrevPage not implemented yet!")
|
||||
; bool result = BRMerchandiseList.PrevPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf)
|
||||
; Debug.Trace("BRMerchandiseList.PrevPage result: " + result)
|
||||
; if !result
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endif
|
||||
endEvent
|
@ -1,13 +1,6 @@
|
||||
scriptname BRMerchToggleScript extends ObjectReference
|
||||
|
||||
Keyword property BRLinkMerchShelf auto
|
||||
Keyword property BRLinkMerchChest auto
|
||||
Keyword property BRLinkItemRef auto
|
||||
Keyword property BRLinkActivatorRef auto
|
||||
Keyword property BRLinkMerchToggle auto
|
||||
Keyword property BRLinkMerchNext auto
|
||||
Keyword property BRLinkMerchPrev auto
|
||||
Activator property ActivatorStatic auto
|
||||
Actor property PlayerRef auto
|
||||
Quest Property BRQuest Auto
|
||||
|
||||
@ -15,25 +8,27 @@ event OnActivate(ObjectReference akActionRef)
|
||||
if akActionRef == PlayerRef
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
bool result = BRMerchandiseList.Toggle(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.Trace("BRMerchandiseList.Toggle result: " + result)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("BRMerchandiseList.Toggle not implemented yet!")
|
||||
; bool result = BRMerchandiseList.Toggle(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf)
|
||||
; Debug.Trace("BRMerchandiseList.Toggle result: " + result)
|
||||
; if !result
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endif
|
||||
endEvent
|
||||
|
||||
event OnLoadMerchandiseSuccess(bool result)
|
||||
Debug.Trace("BRMerchToggleScript OnLoadMerchandiseSuccess result: " + result)
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
while !BRMerchandiseList.Replace3D(MerchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkItemRef)
|
||||
Debug.Trace("BRMerchandiseList.Replace3D returned false, waiting and trying again")
|
||||
Utility.Wait(0.05)
|
||||
endWhile
|
||||
endEvent
|
||||
; event OnLoadMerchandiseSuccess(bool result)
|
||||
; Debug.Trace("BRMerchToggleScript OnLoadMerchandiseSuccess result: " + result)
|
||||
; ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
; debug.MessageBox("BRMerchandiseList.Replace3D not implemented yet!")
|
||||
; ; while !BRMerchandiseList.Replace3D(MerchantShelf)
|
||||
; ; Debug.Trace("BRMerchandiseList.Replace3D returned false, waiting and trying again")
|
||||
; ; Utility.Wait(0.05)
|
||||
; ; endWhile
|
||||
; endEvent
|
||||
|
||||
event OnLoadMerchandiseFail(string error)
|
||||
Debug.Trace("BRMerchToggleScript OnLoadMerchandiseFail error: " + error)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
endEvent
|
||||
; event OnLoadMerchandiseFail(string error)
|
||||
; Debug.Trace("BRMerchToggleScript OnLoadMerchandiseFail error: " + error)
|
||||
; BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
; endEvent
|
@ -1,13 +1,14 @@
|
||||
scriptname BRMerchandiseList
|
||||
|
||||
; TODO: a save function that saves the merch to the server, load should load from server
|
||||
bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
|
||||
bool function NextPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
|
||||
bool function PrevPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
|
||||
bool function Load(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
|
||||
bool function Refresh(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword chestKeyword, Keyword itemKeyword, Keyword activatorKeyword, Keyword toggleKeyword, Keyword nextKeyword, Keyword prevKeyword) global native
|
||||
; bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
; bool function NextPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
; bool function PrevPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
bool function Load(string apiUrl, string apiKey, int shop_id, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference merchantChest) global native
|
||||
; bool function Refresh(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
|
||||
bool function Replace3D(ObjectReference merchantShelf, Form activatorStatic, Keyword shelfKeyword, Keyword itemKeyword) global native
|
||||
bool function Replace3D(ObjectReference merchantShelf) global native
|
||||
bool function ReplaceAll3D(Cell shopCell) global native
|
||||
|
||||
bool function Create(string apiUrl, string apiKey, int shopId, ObjectReference merchantChest) global native
|
||||
|
||||
|
@ -1,13 +1,6 @@
|
||||
scriptname BRPublicMerchChestScript extends ObjectReference
|
||||
|
||||
Keyword property BRLinkMerchShelf auto
|
||||
Keyword property BRLinkMerchChest auto
|
||||
Keyword property BRLinkItemRef auto
|
||||
Keyword property BRLinkActivatorRef auto
|
||||
Keyword property BRLinkMerchToggle auto
|
||||
Keyword property BRLinkMerchNext auto
|
||||
Keyword property BRLinkMerchPrev auto
|
||||
Activator property ActivatorStatic auto
|
||||
Actor property PlayerRef auto
|
||||
Quest property BRQuest auto
|
||||
FormList property BREmptyFormList auto
|
||||
@ -67,9 +60,10 @@ event OnCreateMerchandiseSuccess(bool created, int id)
|
||||
Debug.Notification("Saved merchandise successfully")
|
||||
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
||||
Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
debug.MessageBox("BRMerchandiseList.Refresh not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
else
|
||||
Debug.Trace("BRPublicMerchChestScript no container changes to save to the server")
|
||||
endif
|
||||
|
@ -19,6 +19,7 @@ int property ActiveOwnerId auto
|
||||
int property ActiveShopId auto
|
||||
string property ActiveShopName auto
|
||||
string property ActiveShopDescription auto
|
||||
ObjectReference[] property ActiveShopShelves auto
|
||||
; references
|
||||
Actor property PlayerRef auto
|
||||
ObjectReference property ShopXMarker auto
|
||||
@ -153,8 +154,7 @@ bool function LoadInteriorRefs()
|
||||
endif
|
||||
Debug.Trace("ClearCell result: " + result)
|
||||
|
||||
result = BRInteriorRefList.Load(ApiUrl, ApiKey, InteriorRefListId, ShopXMarker, PrivateChest, PublicChest, self)
|
||||
if result
|
||||
if BRInteriorRefList.Load(ApiUrl, ApiKey, InteriorRefListId, ShopXMarker, PrivateChest, PublicChest, self)
|
||||
return true
|
||||
else
|
||||
Debug.MessageBox("Failed to load shop.\n\n" + BugReportCopy)
|
||||
@ -162,12 +162,20 @@ bool function LoadInteriorRefs()
|
||||
endif
|
||||
endFunction
|
||||
|
||||
event OnLoadInteriorRefListSuccess(bool result)
|
||||
event OnLoadInteriorRefListSuccess(bool result, ObjectReference[] shelves)
|
||||
Debug.Trace("BRQuestScript OnLoadInteriorRefListSuccess result: " + result)
|
||||
ActiveShopId = ShopId
|
||||
ActiveShopName = ShopName
|
||||
ActiveShopDescription = ShopDescription
|
||||
ActiveShopShelves = shelves
|
||||
Debug.Trace("BRQuestScript OnLoadInteriorRefListSuccess ActiveShopShelves: " + ActiveShopShelves)
|
||||
Debug.MessageBox("Successfully loaded shop")
|
||||
; TODO: the assumption that player is in shop cell may be incorrect
|
||||
Cell shopCell = PlayerRef.GetParentCell()
|
||||
|
||||
if !BRMerchandiseList.Load(ApiUrl, ApiKey, ActiveShopId, shopCell, ActiveShopShelves, PrivateChest)
|
||||
Debug.MessageBox("Failed to load shop merchandise.\n\n" + BugReportCopy)
|
||||
endif
|
||||
endEvent
|
||||
|
||||
event OnLoadInteriorRefListFail(string error)
|
||||
|
Loading…
Reference in New Issue
Block a user