• Welcome to SC4 Devotion Forum Archives.
 

News:

The SC4 Devotion Forums are no longer active, but remain online in an archived, read-only "museum" state.  It is not possible for regular members to post or use the private messaging system, and no technical support will be provided for any issues pertaining to the forums in their current state.  Attachments (those that still work) are accessible without login.

The LEX has been replaced with SC4Evermore (SC4E), and SC4E maintains an active Discord server.  For traditional forums, we recommend Simtropolis.

Main Menu

Exporting Exemplars As Plain Text (Maybe LUA Script Help?)

Started by MutantPlatypus, August 09, 2010, 10:30:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MutantPlatypus

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.  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.


NOTE:  If the above post is just one sentence about some inconsistency, bug, or broken link, don't be offended.  I'm posting the info because I assumed it was some minor oversight and want to help you fix it, or I want the information to be available to others who are doing a search for the same problem.  Once the issue is resolved, moderators are encouraged to delete my post.

Venom+Eggs+Lactation=Platypus

MutantPlatypus

#1
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:



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



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...


NOTE:  If the above post is just one sentence about some inconsistency, bug, or broken link, don't be offended.  I'm posting the info because I assumed it was some minor oversight and want to help you fix it, or I want the information to be available to others who are doing a search for the same problem.  Once the issue is resolved, moderators are encouraged to delete my post.

Venom+Eggs+Lactation=Platypus