Sign In Register

How can we help you today?

Start a new topic
Answered

Working with metacollections through admin screens.

Hey there,


I just started really digging into GameSparks about a week or two ago when we greenlit our latest game project. 


Right now  I am doing a lot of system and tool design and I want my designers to have an ability editor at hand through which they can set up new character/npc abilities to be used ingame. These abilities are stored in a meta collection and right now I have a custom editor window in Unity in place that updates the data through the NoSql REST API. 


I would however prefer to reate an admin screen in GameSparks to manage the abilities. From my understanding and tests, I can not update meta data directly through admin screen cloud scripts, because the meta collections are served as read-only. That does make sense considering that admin screens could be pushed to live and would then mess with live data. But then I could just go ahead and use make the necessary REST calls in the admin page to achieve the same result so that security feature is more of a hurdle instead of a stop.


Since I am so green in regards to GameSparks, I would like to ask: What is the official / recommended way of editing meta collections in admin screens? I am pretty sure I am missing something here.


Thanks  in advance,


Patrick


Best Answer

Alright, i figured it out. The issue is that the in-editor documentation shows the meta collections as SparkMongoCollectionReadOnly while the runtime collections are SparkMongoCollectionReadWrite. This lead me to the conclusion that changing the data this way would not work in an admin screen. But it works just fine even though actions like insert etc. are not suggested due to the incorrect type being associated. 


If possible, this should be fixed, because I can't imagine I am the only one that ran into this issue.


image



Hi Sean,


I think I am good for now, but thank you for inquiring again. :-)


It took a few days to get the mechanics down, but I have now created an ability editor that enables our game designer to do all the balancing of the game through the admin screen. The only parts left to implement on the game design side are the item management and the npc management. Both should be fairly easy to implement now that I know my way around the system. And I have to say: I really enjoy working with it.


I didn't have to write any serious javascript in a couple of years, so I had to warm up to that as well. At one point one script file would no longer be evaluated for errors and I only got one notification saying something along the lines of "Too many errors. 83% scanned". I dug a bit into JSHint and found out that I could display the "missing" errors by adding the following to the top of my script:  

'use strict';
/* globals Spark, Game */

 Adding this, the correct errors popped up and the Spark object was now correctly recognized as a global. "Game" is my primary object which I use to avoid polluting the global namespace with my own variables.


I'll also gladly share a screen for other people to check out. 


This one is our ability editor. In our game, abilities encompass game cards the users can play, character talents, base abilities like moving, but also auras (buffs/debuffs) and area of effect spells that are placed on the map. With abilities being so different, I had to write up a couple of definitions in cloud code that determined for example which component required which custom values. I am quite happy with it now, though I am pretty sure that a few things are still missing. Still, it should not be that hard to add them in.


image


Thank you for such a great product,


Patrick

 Hey Patrick,

Let us know if you have anymore questions.
We'd love to see some of your manage screens if you would like to share. We are always interested in what our customers use them for and its good inspiration for forum users to see whats possible.

Thanks,
Sean

Hi Patrick,


They can be written to in cloud code in and used in manage screens you are correct. It only works in preview and does not autocomplete. I believe it is mentioned in some of the tutorials that you can write to them in previews Cloud Code but we could maybe do with making this clearer going forward.


Regards,

Liam

Answer

Alright, i figured it out. The issue is that the in-editor documentation shows the meta collections as SparkMongoCollectionReadOnly while the runtime collections are SparkMongoCollectionReadWrite. This lead me to the conclusion that changing the data this way would not work in an admin screen. But it works just fine even though actions like insert etc. are not suggested due to the incorrect type being associated. 


If possible, this should be fixed, because I can't imagine I am the only one that ran into this issue.


image


Login to post a comment