String from ResourceID

LastSword

Prince
Joined
Feb 24, 2013
Messages
1,064
(LUA) How to get:
1. Resource string/description (ex. Marble) from ResourceID or GameInfo.Resources().
1.5 ResourceID from GameInfo.Resources().
2. PolicyBranchType from PolicyID.

Thanks for help.
 
(LUA) How to get:
1. Resource string/description (ex. Marble) from ResourceID or GameInfo.Resources().
1.5 ResourceID from GameInfo.Resources().
2. PolicyBranchType from PolicyID.

Thanks for help.

1 GameInfo.Resources[ResourceID].Description is the text key for the description of a resource
1.5 GameInfo.Resources() is an iterator which you use to iterate over all of the resource information tables. Each one returned by it will have an ID entry which is the ID.

E.g.:
Code:
for pInfo in GameInfo.Resources() do
    -- prints all resource IDs
    print(pInfo.ID)
end

Side note: GameInfoTypes.RESOURCE_NAME is much, much faster than doing the above loop to find an ID.

2 GameInfo.Policies[PolicyID].PolicyBranchType
 
Code:
for iResource in GameInfo.Resources() do
	if Game.GetResourceUsageType(iResource.ID) == ResourceUsageTypes.RESOURCEUSAGE_LUXURY then
		LuxCount = LuxCount + 1;
		PhoResTable[LuxCount] = iResource.ID;
	end
end
That's why I needed ID, previously I was just using variable increasing by 1, was working but... not elegant enough.

Now, I have for example TXT_KEY_RESOURCE_SILK, how to make it "Silk".


@Edit
Thanks. :)
 
Now, I have for example TXT_KEY_RESOURCE_SILK, how to make it "Silk".

Code:
local sTxtKey = "TXT_KEY_RESOURCE_SILK"
local sText = Locale.Lookup(sTxtKey)
 
Top Bottom