Home
Resource Distribution

Links
Resource Distribution Release Thread

Story
This is mainly a tool for developing Scripted Entities which operate on resources. For example, you could create a Bread Machine that consumes Flour, Water, Yeast and Energy to produce units of Bread, which could either be stored in a container or consumed by the player if user-addon provides for it.

Using the included Link Tool you can hook devices up and create networks of shared resources. Also included is a retractable Supply Connector for temporary connections such as fueling stations or modular forts. I have included some test entities in the base pack, the "Bucket o' Crud", the "Tub o' Crud and Junk", and the "Barrel o' Stuff and Junk." These are accessible in the SEnts Spawn Menu, and serve no other purpose than perhaps as templates for you to study.

Enjoy, and Happy Modding!


Technical Details
An example of what this can do is found in the Life Support Addon, where the 3 main resources of Air, Energy and Coolant are generated, stored, distributed and consumed for the purpose of survival in hostile environments. The best part is that it's extremely easy to use. For example

our Bread Machine's Init() function could have the following lines included:
RD_AddResource(self.Entity, "flour", 0)
RD_AddResource(self.Entity, "water", 0)
RD_AddResource(self.Entity, "yeast", 0)
RD_AddResource(self.Entity, "energy", 0)


Then in the Bread Machine's Think() function it could say:
local flour = RD_GetResourceAmount(self, "flour")
local water = RD_GetResourceAmount(self, "water")
local yeast = RD_GetResourceAmount(self, "yeast")
local energy = RD_GetResourceAmount(self, "energy")

if (flour >= 4) and (water >= 2) and (yeast >= 1) and (energy >= 25) then
      RD_ConsumeResource(self, "flour", 4)
      RD_ConsumeResource(self, "water", 2)
      RD_ConsumeResource(self, "yeast", 1)
      RD_ConsumeResource(self, "energy", 25)

      ... MAKE BREAD ....
end


Here are all of the utility function definitions:
RD_AddResource(ent, res, capacity)
--Adds a named resource with the specified storage capacity to the ent

RD_ConsumeResource(ent, res, amount)
--Consumes a named resource from the entity

RD_SupplyResource(ent, res, amount)
--Replenishes a named resource on the entity by a specified amount

RD_GetResourceAmount(ent, res)
--Returns the amount of a named resource accessible to the entity

RD_GetUnitCapacity(ent, res)
--Returns the maximum storage capacity of a specified entity, disregarding the network size(for named resource only)

RD_GetNetworkCapacity(ent, res)
--Returns the maximum storage capacity of an entire network accessible to the entity(for named resource only)


Home