Handling Resources

View previous topic View next topic Go down

Handling Resources

Post by Scarfacial on Fri Jun 07, 2013 1:20 pm

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:

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.
avatar
Scarfacial

Posts : 15
Join date : 2013-06-03

View user profile http://survival303.pcriot.com/

Back to top Go down

Re: Handling Resources

Post by jobro13 on Fri Jun 07, 2013 2:21 pm

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.
avatar
jobro13

Male Posts : 250
Join date : 2013-06-02

View user profile

Back to top Go down

Re: Handling Resources

Post by Fattycat17 on Sun Jun 16, 2013 12:00 pm

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.
avatar
Fattycat17

Male Posts : 116
Join date : 2013-06-02

View user profile

Back to top Go down

Re: Handling Resources

Post by jobro13 on Sun Jun 16, 2013 12:21 pm

"Default resource data".

Would also make the memory usage lower.
avatar
jobro13

Male Posts : 250
Join date : 2013-06-02

View user profile

Back to top Go down

Re: Handling Resources

Post by coolieman2 on Thu Jul 04, 2013 5:28 pm

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.
avatar
coolieman2

Male Posts : 78
Join date : 2013-06-21
Location : Europe meaning i'm in a good timezone :)

View user profile

Back to top Go down

Re: Handling Resources

Post by MemoryAddress on Sat Jul 06, 2013 7:08 pm

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.

  1. Jobro's already implemented OOP into Lua, which is most likely the most dynamic language ever.  ©Scarfacial, 2013
  2. Roblox doesn't need to sandbox another language.
  3. Adding another syntax to Roblox is a bad idea.


So this is a bad idea.
avatar
MemoryAddress

Male Posts : 12
Join date : 2013-07-03
Location : MAGICAL WIZARD TOWER OF MAGIC

View user profile

Back to top Go down

Re: Handling Resources

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum