Jump to content
Sign In to follow this  
boformer

Need your advice: BuildingThemes config format

6 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

I'm still testing the new "Better Upgrade' feature of the Building Themes mod. It works quite well so far.

The mod creates duplicates of growable assets and assigns different wealth levels to them.

It also provides an upgrade mapping: Buildings will upgrade to a higher level duplicate if one is defined.

The current config format is quite simple:

<Building name="original asset name" min-level="1" max-level="3" upgrade="level 4 asset name" />

(The upgrade attribute determines the asset that the duplicate with the max. Level will upgrade to)

The mod automatically creates the duplicates and names them "original asset name#LevelX".

The thing is that this configuration format is quite limited when it comes to future extensions, like changing the zone type, density, the footprint size, spawn rate or the display of props of the duplicates.

That's why I thought about a more advanced configuration format that lists up every duplicate separately:

<Building name="myasset" upgrade="myasset#L2" />
<Building name="myasset#L2" level="2" duplicateof="myasset" upgrade="myasset#L3" />
<Building name="myasset#L3" level="3" duplicateof="myasset" />

The problem with this kind of configuration: It is harder to understand, and the manual naming might cause problems when 2 theme authors chose the same name for their duplicates. It also means that there might be multiple similar duplicates which raises the number of prefabs (there is a hardcoded prefab limit). On the other hand, it allows two themes to contain completely different variations of the original asset, with different color combinations and different props.

Question: Which config format should I implement?


  Edited by schmidtbochum  

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

With my limited knowledge I can't say much about this matter but I don't think the 2nd version is any harder to understand. Just more text.

 

But I actually commented for this:

There is a mod (Mesh Info, I think) which displays the SteamID of each asset. So I assume you can access this information via the API. Using the ID instead of names makes it more cryptic, but you avoid the issue of double names which might happen sooner or later :)


  Edited by Dubai Skyscraper  

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

just curious. is it only possible to store data in attributes or is something like this possible?

 

<Building name="myasset#L2">

    <DuplicateOf>myasset</DuplicateOf>

    <UpgradesTo>myasset#L3</UpgradesTo>

    <AvailableLevels>

        <Level> 1</Level>

        <Level> 2</Level>

    </AvailableLevels>

    ...

</Building>

guess it will always be kinda limited using only one tag + attributes


  Edited by Shelltoe  

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    just curious. is it only possible to store data in attributes or is something like this possible?

     

    <Building name="myasset#L2">

        <DuplicateOf>myasset</DuplicateOf>

        <UpgradesTo>myasset#L3</UpgradesTo>

        <AvailableLevels>

            <Level> 1</Level>

            <Level> 2</Level>

        </AvailableLevels>

        ...

    </Building>

    guess it will always be kinda limited using only one tag + attributes

    It does not really matter if you use attributes or child elements. Both is possible.

    Here is a mix of both. It was the initial format I developed:

    6xgC5NR.jpg

    The only problem with the initial format: First of all, it introduces an additional "Variation" element, which increases the complexity of the code.

    The other problem is that it forces the original asset to be a part of the theme.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    hm using elements you'll probably have a lot more flexibility and extensibility in the future as attributes can't store multible values.

    of course it requires some extra code but it makes it more readable too. i would not suggest to use attributes where multible values could be possible in the future but this depends on your plans i guess

     

    as i'm not to sure if i got your initial format:

    first Terraced House1#L2 (a actual workshop item with id / the base asset will allways have an workshop id right?) gets loaded.

     then #L3-#L5 will be created using #L2 as a base, renaming it and changing its level.

     

     

    <Building active="False">
        <WorkshopId>123123312</WorkshopID>
        <AssetName>myasset</AssetName>
        <UpgradesTo>myasset#L2</UpgradesTo>
        <AvailableLevels>
            <Level>1</Level>
        </AvailableLevels>
        ...
    </Building>
    <Building>
        <AssetName>myasset#L2</AssetName>
        <DuplicateOf>123123312</DuplicateOf>
        <UpgradesTo>myasset#L3</UpgradesTo>
        <AvailableLevels>
            <Level>2</Level>
        </AvailableLevels>
        ...
    </Building>
    <Building>
        <AssetName>myasset#L3</AssetName>
        <DuplicateOf>123123312</DuplicateOf>
        <AvailableLevels>
            <Level>3</Level>
        </AvailableLevels>
        ...
    </Building>

     

    ### Pseudocode:

     foreach Building {

        if active {

            if !isLoaded(this.DuplicateOf) {

             createBase(this.DuplicateOf)

            } else {

             loadBase(this.DuplicateOf)

           }

        }

    }

    this should work shouldn't it? i might be totally wrong though, i have no clue what your sourcecode looks like.

    you could even fix the 2 authors / 1 asset name problem by attaching the orignal workshop id to all variation assetnames while generating them.


      Edited by Shelltoe  

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

     

    you could even fix the 2 authors / 1 asset name problem by attaching the orignal workshop id to all variation assetnames while generating them.

    I think I will append the theme name to the asset to fix that problem.

    I'm taking care of properties which contain multiple arguments. Right now there are none, so using attributes is fine.

    This is my current plan how the format will look like:

     
    <?xml version="1.0" encoding="utf-8"?>
    <Themes>

    <Theme name="Edinburgh">

    <Buildings>
    <Building name="455335791.ERHL1A_Data" upgradeto="ERHL1A#L2"/> <-- the original (L1) asset
    <Building name="ERHL1A#L2" level="2" duplicateof="455335791.ERHL1A_Data" upgradeto="ERHL1A#L3"/> <-- L2 duplicate
    <Building name="ERHL1A#L3" level="3" duplicateof="455335791.ERHL1A_Data" upgradeto="ERHL1A#L4"/> <-- L3 duplicate
    ...

    </Buildings>

    </Theme>
    </Themes>
    </Configuration>

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In to follow this  

    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections