SC4 Devotion Forum Archives

SimCity 4 General Discussion and Tutorials => SimCity 4 General Discussion => General Custom Content Discussion => Topic started by: MutantPlatypus on August 09, 2010, 10:30:59 AM

Title: Exporting Exemplars As Plain Text (Maybe LUA Script Help?)
Post by: MutantPlatypus on August 09, 2010, 10:30:59 AM
Hello,

I would like to have a look at a bunch of exemplars at the same time.  Specifically, I want to get a certain property out of about 700 exemplars and into a table.  The property is 256 float32s.  All the exemplars are in a single dat.  Unfortunately, saving the examplar file using iLive's Reader doesn't save them in plain text, so I can use the data in them (easily).  Does anybody know how I could autonomously extract those property reps from a bunch of exemplars?

A Reader script is one option, but I can't figure out how :/.  I've posted the script on a more relevant thread (http://sc4devotion.com/forums/index.php?topic=10488.msg338781#msg338781).  Perhaps there's another way?  Like does anyone know how to decompress and decode the .eqz files saved by the Reader when you choose the "Save Selected File(s)" option?  Even just knowing the kind of compression used in the file would help.  If I could decompress it I might be able to convert the data to a more human-readable format.

Specifically, I'm trying to deconstruct Cycledogg's Missouri Breaks tree controller.  I need to look at a spreadsheet the Exemplar Name properties next to all the reps of the kSC4FloraPreferencesProperty (Name Value=0x083DC487) properties.
Title: Re: Exporting Exemplars As Plain Text (Maybe LUA Script Help?)
Post by: MutantPlatypus on August 11, 2010, 02:01:29 PM
UPDATE:  Right, so, this script exports all the kSC4FloraPreferences properties to a csv file that can be imported to Excel or OpenOffice.org Calc.  That way, you can easily analyze which tree clusters are where in a huge tree controller.

function reader.main (this)

    entryPosition = reader:entries_GetHeadPosition()

    outfile = io.open("Flora.csv", "w+")

    while entryPosition~=0 do

        entry,entryPosition = reader:entries_GetNext(entryPosition)
        flag = reader:entry_GetFlag(entry)

        if (flag == 7) then

            exemplar = reader:ex_Decode(entry)

            propertyPosition = reader:exprop_GetHeadPosition(exemplar)
            hasClusterType=false

            while propertyPosition~=0 do

                property,propertyPosition = reader:exprop_GetNext(exemplar,propertyPosition)
                nameValue,propertyName = reader:exprop_GetDesc(property)

                if (nameValue == 0x00000020) then
                    exemplarName = reader:exprop_GetValueStr(property)
                    outfile:write(exemplarName)
                    outfile:write(",")

                elseif (nameValue == 0x083DC487) then

                    kSC4FloraPreferencesProperty = reader:exprop_GetValueStr(property)
                    propertyValueLen = kSC4FloraPreferencesProperty:len()
                    characterIndex = 1
                    while characterIndex <= propertyValueLen do
                       outputCharacter = kSC4FloraPreferencesProperty:sub(characterIndex, characterIndex)
                       outfile:write(outputCharacter)
                       characterIndex = characterIndex+1
                    end
                    outfile:write("\n")
                end
            end
        end
    end

    outfile:flush()
    outfile:close()

    reader:refresh()

end


Specifically, you can make documents like this:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fa.imageshack.us%2Fimg38%2F2348%2Fmissouribreakspreferenc.th.png&hash=b483079da72ead435f53fdee1a1f3b83074acc31) (http://img38.imageshack.us/i/missouribreakspreferenc.png/)

Or, if you want a less-detailed view, you can edit it a bit more to get this:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fa.imageshack.us%2Fimg534%2F2348%2Fmissouribreakspreferenc.th.png&hash=d631b46eec2cd0f69c87da64b48c4301829b5dc3) (http://img534.imageshack.us/i/missouribreakspreferenc.png/)

Now you can see where Cycledogg put the trees and where he didn't... so maybe you can have an idea of where to put trees in a tree controller for the Missouri Breaks terrain mod...