Тёмный

When to Use a Resource Over a Dictionary? 

Coding Quests
Подписаться 16 тыс.
Просмотров 4,2 тыс.
50% 1

In this Video I explain:
00:00 - What is Data?
02:10 - What is a Dictionary?
03:30 What is a Resource?
08:10 When do we use a Resource? (Example)
09:30 When to use one over the other and Why?
------------------------------------------------------------------------------------------------
If your Too lazy to watch the full video and want a Quick Answer:
RESOURCES OVER DICTIONARY:
STRONG TYPE: Resources allow for strong typing and structure, making it easier to understand and manage the data.
EDITOR INTEGRATION: Resources integrate better with Godot’s editor, offering a more visual and user-friendly approach to modifying properties.
SERIALIZATION AND RESUABILITY: Resources can be saved and loaded from disk, making them more convenient for reusable data storage compared to dictionaries.
CUSTOM EDITOR PROPERTIES: Custom resources can expose specific properties in the editor, unlike dictionaries.
DICTIONARY USE CASE:
SIMPLE DATA STORAGE: For lightweight, less complex data requirements without the need for serialization or editor integration, dictionaries can be more straightforward.
------------------------------------------------------------------------------------------------------------------------------------------
www.codingquests.com
Join my Discord if want: / discord
Check out my twitch: / codingquests
Check out my Site: www.codingquests.com
Check out my Patreon and support me: / codingquests
Check out my STEAM: store.steampowered.com/search...
2ND Channel: / @podquests
Check out My Udemy Courses: www.udemy.com/user/omar-zaki-55

Опубликовано:

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@qooldeluxx
@qooldeluxx 6 месяцев назад
I think the benefit to resource is that it can also contain methods, not just data
@CodingQuests
@CodingQuests 6 месяцев назад
that is also true
@thesomeone2nd
@thesomeone2nd 6 месяцев назад
Wdym with methods?
@qooldeluxx
@qooldeluxx 6 месяцев назад
​@@thesomeone2ndit can contain functions in it as well. Like get sets. Atleast i think im still figuring out how it all works.
@CodingQuests
@CodingQuests 6 месяцев назад
@@qooldeluxx yes you are correct, it can hold any function. the main point to understand that a resource is just a template basically which holds a script inside it. so it can have functions, variables, w.e u want
@thesomeone2nd
@thesomeone2nd 6 месяцев назад
@@qooldeluxx oh ok thx I am still learning the engine
@andrewgrinn3435
@andrewgrinn3435 6 месяцев назад
Thank you.
@owenlloyd2528
@owenlloyd2528 6 месяцев назад
Thank you
@7shiroi
@7shiroi 2 месяца назад
How about data-driven development? For example, if we have a JSON for items. I normally use a dictionary but the typing can be hard to manage. Is there a way for us to use resources?
@CodingQuests
@CodingQuests 2 месяца назад
I believe so yes. I think ive seen a few threads on this topic.
@CodingQuests
@CodingQuests 6 месяцев назад
Read the Description for short answer, Also check out my upcoming course Godot Genesis on my site: www.codingquests.com/courses
@635574
@635574 3 месяца назад
Nice, I was looking for alternative to just dictionaries becuuse I canot declare types within and they also dont pass existing variable as reference.
@jaysistar2711
@jaysistar2711 16 дней назад
3:40 I think that you mean "It's inspectable by the editor, so instance contents are editable in the inspector."
@gonderage
@gonderage 23 дня назад
commenting b4 watching but when i want more certainty about the data i work with, and I use a specific format consistently a lot, and if I want intellisense, i use a resource. if it's a one-off container of data, then a dict is enough, and I don't have to write a whole class for it.
@tsiapal
@tsiapal 6 месяцев назад
One thing that confused me. You created the item script before you created the item resource. Are these two related because of the same name or because of the extends Resource? And if it's the second doesnt that mean that all my resources will have the same variables even if I dont want to? And btw.... Happy New Years Eve!
@CodingQuests
@CodingQuests 6 месяцев назад
you need a script attached to a resource, u can have 10 resources based on the same script. thats the general advantage of them, is that thy can use the same template baically
@Wisdawms
@Wisdawms 6 месяцев назад
You can't have a resource unless you have a script that extends Resource.
@Asilhan
@Asilhan Месяц назад
Let's say we created a item resource then, using it we create 50 different items which have different values. How can I see their values in a excel-like environment? I mean listing them in a box. Do we need to export resources into a different program?
@CodingQuests
@CodingQuests Месяц назад
im not sure if theres a way to do that. maybe you could convert the .tres values into a json folder then go that way?
@Asilhan
@Asilhan Месяц назад
@@CodingQuests Hmmph. In a typical RPG game we have hundreds of items, enemies and quests. Represting them with resources must be hard if listing them isn't possible.
@ennazen2793
@ennazen2793 18 дней назад
Try plugin "edit resources as table"
@Asilhan
@Asilhan 18 дней назад
@@ennazen2793 Thanks man, this is what I wanted.
@DinoTeaser
@DinoTeaser 6 месяцев назад
jjviu
@MoraesMusician
@MoraesMusician Месяц назад
you gotta structure/plan these a little bit better, man. the amount of times you went "no, let's do it a different way" made it so confusing...
Далее
How to Measure ANY Cliffs Height with a Rock
00:46
Просмотров 10 млн
Custom Resources in Godot 4 and How to use them
9:36
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
RAG from the Ground Up with Python and Ollama
15:32
Просмотров 26 тыс.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
The Stock Market Sell Off Continues
22:33
Просмотров 151 тыс.
Google Sheets to Godot
14:23
Просмотров 9 тыс.
Database Sharding and Partitioning
23:53
Просмотров 71 тыс.