Handling Resources
4 posters
Survival Project :: The game :: Concepts
Page 1 of 1
Handling Resources
So I've been thinking about ways in which we could handle resources in the new game, and one idea really sticks out to me. I'm not entirely sure how resources are handled in Stranded: Episode One, but I know that in all the games in the Survival Series, resources are handled by storing values inside the object. That's great and all, but it makes it a real pain to update a resource type on a massive scale (For example, changing the Hunger restored from eating berries to a higher value, etc)
My proposition is this - Rather than relying on values and such, we could write a lookup table and give everything an ID rather than using information from the parts themselves. For the scripters, here's a code snippet to elaborate on what I mean:
As you can see, each item would have an ID in the table to specify what properties it should have. Then rather than having to update tons of different parts, everything could be updated simply by changing one line of code. It's just an idea, but if we wrote the game around the idea I think it would be much easier to manage in the future.
My proposition is this - Rather than relying on values and such, we could write a lookup table and give everything an ID rather than using information from the parts themselves. For the scripters, here's a code snippet to elaborate on what I mean:
- Code:
local ResourceTable = {
[0] = {
"Tree Stump";
Flammable = true;
},
[1] = {
"Apple";
Edible = {
Hunger = 5;
Portions = 2;
}
}
}
As you can see, each item would have an ID in the table to specify what properties it should have. Then rather than having to update tons of different parts, everything could be updated simply by changing one line of code. It's just an idea, but if we wrote the game around the idea I think it would be much easier to manage in the future.
Guest- Guest
Re: Handling Resources
I agree on the part of having a central value somewhere, where all other resources INHERIT the properties from.
However, I don't think we should use tables for that - maybe for the INITIAL creation of them, (such as a small batch program), but not the actual resources.
Why? This version will only be accessible in one script.
I think we should create some kind of Resource class (as you know, we will get an API) and you can attach a name for that.
When you attach a name to a resource it immediately inherits every property, which is stored in a "dummy resource" somewhere.
Using that, everything - including local scripts - can find these "dummy" resources. I think that's the best approach.
And yes, currently the game works with values inside every resource.
EDIT: Resources inherit their properties from a dummy class, except if that property is already there. Same as __index would work on metatables.
However, I don't think we should use tables for that - maybe for the INITIAL creation of them, (such as a small batch program), but not the actual resources.
Why? This version will only be accessible in one script.
I think we should create some kind of Resource class (as you know, we will get an API) and you can attach a name for that.
When you attach a name to a resource it immediately inherits every property, which is stored in a "dummy resource" somewhere.
Using that, everything - including local scripts - can find these "dummy" resources. I think that's the best approach.
And yes, currently the game works with values inside every resource.
EDIT: Resources inherit their properties from a dummy class, except if that property is already there. Same as __index would work on metatables.
jobro13- Posts : 250
Join date : 2013-06-02
Re: Handling Resources
Yea I agree with Scarfacial, have a global table that stores all data, instead of having String and Number values spammed all over the models.
Fattycat17- Posts : 116
Join date : 2013-06-02
Re: Handling Resources
"Default resource data".
Would also make the memory usage lower.
Would also make the memory usage lower.
jobro13- Posts : 250
Join date : 2013-06-02
Re: Handling Resources
Why can't ROBLOX add a feature so that you can edit a property in a script that would define if it's a Java script or a Lua script so you could increase the possibilities.
coolieman2- Posts : 78
Join date : 2013-06-21
Location : Europe meaning i'm in a good timezone :)
Re: Handling Resources
coolieman2 wrote:Why can't ROBLOX add a feature so that you can edit a property in a script that would define if it's a Java script or a Lua script so you could increase the possibilities.
No.
Just no.
Why, you might ask?
Let's go through it.
- Jobro's already implemented OOP into Lua, which is most likely the most dynamic language ever. ©Scarfacial, 2013
- Roblox doesn't need to sandbox another language.
- Adding another syntax to Roblox is a bad idea.
So this is a bad idea.
MemoryAddress- Posts : 12
Join date : 2013-07-03
Location : MAGICAL WIZARD TOWER OF MAGIC
Survival Project :: The game :: Concepts
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|