I am VERY inexperienced with Verse. So, I was wondering if I could have some assistance.
I’m looking for a device that contains an In-Island Transaction that keeps a Switch on when owned, and off when unowned.
I can probably change metadata for the transaction itself without help (e.g. name, description, price), but I need a base to go off of.
Hello! I have not worked with entitlements, but based on the API and a quick test, this seems to work. You can purchase something and return it with the debug commands to test.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Marketplace }
using { /Verse.org/Assets }
#This will be the base entitlement for all in the island.
my_island_entitlement := class<abstract><castable>(entitlement){}
entitlement_switch_device := class(creative_device):
@editable
Switch : switch_device = switch_device{}
@editable
EntitlementType : subtype(my_island_entitlement) = false
OnBegin<override>():void=
Playspace := GetPlayspace()
Playspace.PlayerAddedEvent().Subscribe(OnPlayerAdded)
for(Player : Playspace.GetPlayers()):
OnPlayerAdded(Player)
OnPlayerAdded(Player:player):void=
GetEntitlementsChangedEvent(Player, EntitlementType).Subscribe(OnEntitlementChange)
spawn. CheckEntitlement(Player)
CheckEntitlement(Player:player)<suspends>:void=
EntitlementsPurchased := GetPurchasedEntitlements(Player,EntitlementType)
for(EntitlementTuple : EntitlementsPurchased, CastResult := EntitlementType[EntitlementTuple(0)], Amount := EntitlementTuple(1) > 0):
Switch.TurnOn(Player)#Cast was successful and player has 1 or more.
return
Switch.TurnOff(Player)#No match turn off
OnEntitlementChange(Player:player, EntitlementsChanged:[]entitlement_change(my_island_entitlement)):void=
for(EntitlementChanged : EntitlementsChanged, CastResult := EntitlementType[EntitlementChanged.Entitlement]):
#We have a match, now Check quantity
if(EntitlementChanged.Quantity > 0):
Switch.TurnOn(Player)
else:
Switch.TurnOff(Player)
return #No need to keep going.