Forgive me if this doesn’t make much sense, I’m very new and I’m trying to figure out multiple steps simultaneously–while probably screwing up all of them.
My end goal is a point and click sim game. Right now, I just want to be able to click a button, open a menu, and get a single column grid where each row is the same data about different NPCs similar to:
Name:
Location:
Likes:
Dislikes:
What I have:
A button that successfully opens a panel container
A panel container with a grid container and a rich text label
A Resource script with a class name and export variables of all the data that needs to be stored for each NPC
What I don’t have: Literally anything else. For greater variety, I’d love to be able to randomize NPC data with some guardrails, instantiate a label for all NPCs that fit a certain criteria, and populate specific data in each label. If randomization is too much, I’m considering going the spreadsheet to JSON method to generate NPC data in mass, but I don’t even have a placeholder mock-up.
I’ve reached the point with Google and tutorials where I don’t know if the problem is what I’m trying to do or if I just don’t have the knowledge necessary to figure out the right search terms.
This is not a question, you want a skilled developer to do the work for you, for free. I think the problem here is that you don’t have the knowledge or skills necessary to build your vision. Said that, how can I help ?
If you really want to build that thing, I’d suggest do what all developers do, first learn that which will allow you to do so. And if you need help along the way, try to make concise and clear questions, so that ppl that want to help can actually do so.
You’re right and hindsight says I should’ve slept on this one before posting it. I was mostly hoping someone would say “look up tutorials on X” or “Read the documentation on Y” or “Randomizing the data that is the entire basis for gameplay is a bug fixing nightmare do not do that.”
I do at last have a placeholder label with the data I want, so an actual question: What do I need to load multiple labels, each containing different data? Can I use one RichTextLabel and one Resource to generate multiple instances or do I need one pair for each set of data that’ll be loaded into the scene?
Start by designing the data model for the NPC from the ground up.
What do you need to know about an NPC?
What will be randomized about the NPC exactly, and will you generate the data procedurally, or will you pick at random from a predetermined table?
What will need access to that data? (UI, randomizer, NPC scripts, etc)
Separate the UI and the data as concepts. When you know what data model you have, designing the UI around it will be much easier. Your data should be able to exist without knowing anything about the UI. It should be the UI’s job to fetch the data. Although you might want some get/set functions inside your data class to help your UI or anything that needs to access the data or modify it e.g.:
class_name NpcData
extends RefCounted
## Contains all possible likes/dislikes an NPC can have.
const ALL_POSSIBLE_LIKES :LikesTable = preload(res://data/likes_table.res)
var name: String
var location: Vector3
var likes: Array[StringName]
var dislikes: Array[StringName]
func get_likes() -> Array[StringName]:
return likes
func get_dislikes() -> Array[StringName]:
return dislikes
func add_new_like(like: StringName) -> void:
likes.append(like)
func remove_like(like: StringName) -> void:
likes.erase(like)
func add_new_dislike(dislike: StringName) -> void:
dislikes.append(dislike)
func remove_dislike(dislike: StringName) -> void:
dislikes.erase(dislike)
func add_new_random_like() -> void:
var random_like :StringName = ALL_POSSIBLE_LIKES.get_random_like()
likes.append(random_like)
func add_new_random_dislike() -> void:
var random_dislike :StringName = ALL_POSSIBLE_LIKES.get_random_like()
dislikes.append(random_dislike)
Do you want your RichTextLabels to all show the same data, or is it one label per NPC each with their own data? If they all show different data, I’d make a Resource for each. If they show the same data, you can simply have the Label get its data from the same Resource.
About Resources; the main advantage is being able to store it in a file, and/or easy viewing in the editor. Since you want to randomize the data, maybe you only need a RefCounted, and populate its data at runtime, then let the label fetch the data? You can still do that with a Resource of course, since it extends RefCounted, but that’s something to think about.
Its hard to tell without knowing more about the data model you’re working with.
This is not a trivial problem to solve, and there are lots of different approaches that games have taken. I know The Sims takes a “needs-based” approach, where each NPC has needs (hunger, entertainment, etc.) they need fulfilled and take actions to do that. Dwarf Fortress and Rim World are other similar colony-sim games that have rich NPC behavior, but their methods are more opaque.
I’d suggest narrowing in on what exactly you want these NPCs to do and behave like, then come back with some more specific questions that you’d be able to get help with.
If you wished for some insight about potential problems then there is one BIG problem - which is exponential content requirement
unless your data is numbers only or some basic repeated text, then you’ll probably need ton of names and locations - possibly more with time, it’s not important right now but think about it, it might be a nightmare later
The NPCs exist only as a fixed assortment of variables. There are no sprites, not even as a player character.
I’ve been trying for most of the day to get a JSON file set up to serve as a dictionary. I think I succeeded in getting the JSON to parse correctly, but I haven’t figured out how to retrieve any of the data so I could be wrong about that.