Forum Discussion

Elem08's avatar
Elem08
Member
5 months ago

Global Cross World Storage

Hello!

I'm working on various scripts to learn the capabilities of the Horizon Desktop editor. I haven't found any information on cross-world, cross-player "global" storage that I can reference in my world.

For example, let's say I want to build a system where users could "vote" for Option A or Option B, and at the end of the week, the Option with the most votes wins, and some text is updated. I cannot use player-specific storage for their votes, nor to store the total votes Option A has received across users, and across instances of the world. 

I'm also not sure how an instantiated class on a Script could keep that state across users either, since (my understanding is) all scripts that are attached to entities are run client-side.

Am I missing something? What kind of strategy could I use to manage something like that? I feel like I've seen gizmos and other tools in worlds that can independently manage their own leaderboards outside of the "leaderboard" tool.

5 Replies

  • The only persistence we currently have is player-based. So, Variable Groups allow you to create variables on a per-player basis, but you can only access a player's variables while they are active in the world. You can also share those Variable Groups with your other worlds so the player has their status across your worlds, but sadly, there is no world persistence yet.

  • If you just want to cast a vote you can add their vote to leaderboard A or B. Leaderboards are the closest things we have to world storage, but we cannot have the script read from the leaderboard. At the end of the voting period you may simply need to look at how many pages of votes were on option A or option B.

  • There are no World Persistent Variables (WPVs) available at the moment to MHCP creators. It is a frequently requested feature. The closest thing is the Leaderboard Gizmo, which lets you present _something_ across all world instances and players. It's very limited tho (only a number per player).  Might be sufficient for your 'voting' mechanic, tho? You can't 'read' the value out via scripts, tho.  Would only be able to have two leaderboards, one for option A, and one for option B, and then count up how many people have an entry on each leaderboard to tally the votes.

    Edit: I see proto_vr said something very similar below.

  • Thank you all for the replies! So it sounds like there could be some way to use leaderboard functionality purely for display purposes, but that still wouldn't provide a way to retrieve the data for use in other scripts.

    If I stood up my own public facing API (using AWS or any other hosting), would the scripts running in Meta Horizon have the ability to call `fetch()` to access those APIs? I assume I could just add some basicAuth and then (assuming there is a way to make those fetch calls) I could have that API respond to the votes and then expose another endpoint to retrieve the accumulated data.

    Thanks again in advance!

  • Unfortunately not. Horizon Worlds is completely firewalled from external resources and APIs. It's been a request likely as old as world persistent storage. 

    Anything you have seen that appears to be using an external API has likely been ported over to exist entirely in the Horizon Worlds environment. External API access would give us so much more capability, but also much more risk. In comparison I'm guessing that world persistent storage would be the easier of these two, but that's someone else's job. They are watching these forums, so keep these great questions coming!