Jump to content

Quick Question About Constants


Recommended Posts

local PIGTRADE_ONE = { PIGTRADE = 1 }
local PIGTRADE_TWO = { PIGTRADE = 2 }

--print(GLOBAL.constants)
table.insert(GLOBAL.TECH, PIGTRADE_ONE)
table.insert(GLOBAL.TECH, PIGTRADE_TWO)

Sorry, so it there anything i'm doing wrong 
 

TECH =
{
    NONE = TechTree.Create(),

    SCIENCE_ONE = { SCIENCE = 1 },
    SCIENCE_TWO = { SCIENCE = 2 },
    SCIENCE_THREE = { SCIENCE = 3 },
    -- Magic starts at level 2 so it's not teased from the start.

--bit of refrence

print(GLOBAL.TECH.PIGTRADE_ONE) will always come as nil for some reason

Link to comment
Share on other sites

Since you are using table.insert, it would end up as:

TECH =
{
    NONE = TechTree.Create(),

    SCIENCE_ONE = { SCIENCE = 1 },
    SCIENCE_TWO = { SCIENCE = 2 },
    SCIENCE_THREE = { SCIENCE = 3 },
  	[1] = { PIGTRADE = 1 },
	[2] = { PIGTRADE = 2 },
 }

Change 

table.insert(GLOBAL.TECH, PIGTRADE_ONE)
table.insert(GLOBAL.TECH, PIGTRADE_TWO)

to

GLOBAL.TECH.PIGTRADE_ONE = PIGTRADE_ONE
GLOBAL.TECH.PIGTRADE_TWO = PIGTRADE_TWO

Which will leave you with 

TECH =
{
    NONE = TechTree.Create(),

    SCIENCE_ONE = { SCIENCE = 1 },
    SCIENCE_TWO = { SCIENCE = 2 },
    SCIENCE_THREE = { SCIENCE = 3 },
  	PIGTRADE_ONE = { PIGTRADE = 1 },
	PIGTRADE_TWO = { PIGTRADE = 2 },
 }

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...