+1 vote

This has probably been asked and answered many times. I've done research into the matter but still cannot wrap my head around how I'd do it.

I'm trying to figure out a proper way to store items. I can simply handle this as a JSON file, right? The problem is, what if there are consumable items? How do I make these items have effects? I've decided storing every item as scenes and scripts so that they can be used, but this prevents the full use of a json file then does it not?

I'm completely lost, so what would be an appropriate way of handling this?

For the record, I know how I'd store them as classes. The point is, in godot, you cannot just instantiate a class like you could in normal C#. So this leaves me confused. Do I just create 1000 item scenes with different scripts associated with them? I've heard having tons of scenes like this could be bad.

in Engine by (39 points)

What do you mean by items exactly, what kind of scene are we talking about? Is it a sprite with some variables and multiple animations?
I'm trying to undertstand what needs to be stored for each item (used or not), and what is common to all of them.

EDIT: Wrote a comment before but I was tired and didn't give a proper description.

So generally think of most JRPGs. When you have a Health Potion, for example, what might be needed for one of these? A name, an icon, a use, maybe a description. The list goes on for what might be needed.

Would it be wise to create a scene for every single item with their own scripts and use cases so they can be instantiated when needed? Or would it be wise to just have one "item" scene, then add a script to it whenever needed?

It seems redundant to create a JSON file for storing item information when you need a script for each item anyway. Why not have the item stats in each script that will be "used" anyway?

Just a thought.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.