Created
September 19, 2012 20:50
-
-
Save warmist/3752176 to your computer and use it in GitHub Desktop.
Add raws to entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMyEntity() | |
return df.historical_entity.find(df.global.ui.group_id) | |
end | |
function getWorkshopId(token) | |
for k,v in pairs(df.global.world.raws.buildings.all) do | |
if token==v.code then | |
return v.id | |
end | |
end | |
end | |
function getReactionId(token) | |
for k,v in pairs(df.global.world.raws.reactions) do | |
if token==v.code then | |
return v.index | |
end | |
end | |
end | |
function addPermittedBuilding(entity,token) | |
entity.entity_raw.workshops.permitted_building_id:insert("#",getWorkshopId(token)) | |
end | |
function addPermittedReaction(entity,token) | |
entity.entity_raw.workshops.permitted_reaction_id:insert("#",getReactionId(token)) | |
end | |
function addPermits(entity,buildings,reactions) | |
entity=entity or getMyEntity() | |
for _,v in ipairs(buildings or {}) do | |
addPermittedBuilding(entity,v) | |
end | |
for _,v in ipairs(reactions or {}) do | |
addPermittedReaction(entity,v) | |
end | |
end | |
addPermits(nil,{"STEAM_ENGINE","MAGMA_STEAM_ENGINE"},{"STOKE_BOILER"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment