Thalassicus
Bytes and Nibblers
I want to move a table from lua to xml, but I'm somewhat confused how to use loadstring to convert a string to lua code.
The lua table looks like this:
I moved it to xml like so:
I know the basic algorithm is something like:
What's the proper syntax to do the loadstring part? From looking at the examples I can tell I'm missing something, but I'm not sure how exactly to structure it.
The lua table looks like this:
PHP:
for pBuildingInfo in GameInfo.Buildings() do
stats.Buildings[pBuildingInfo.ID] = {
...
{"SpecialistType" , pBuildingInfo.SpecialistType },
{"GreatGeneralRateChange" , pBuildingInfo.GreatGeneralRateChange },
...
}
I moved it to xml like so:
Code:
<Table name="BuildingStats">
<Column name="Order" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Value" type="text" />
</Table>
<BuildingStats>
...
<Row><Type>SpecialistType</Type> <Value>pBuildingInfo.SpecialistType</Value></Row>
<Row><Type>GreatGeneralRateChange</Type> <Value>pBuildingInfo.GreatGeneralRateChange</Value></Row>
...
</BuildingStats>
PHP:
for pBuildingInfo in GameInfo.Buildings() do
for row in GameInfo.BuildingStats() do
stats.Buildings[row.Order] = {row.Type, loadstring(row.value)}
end