Jump to content
atsf189

Help generating Automata from lots

34 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Is there a tutorial on how to write a script to make a lot spawn cars or trucks?

I would like to make a post office spawn mail trucks.

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
4 hours ago, atsf189 said:

Is there a tutorial on how to write a script to make a lot spawn cars or trucks?

I would like to make a post office spawn mail trucks.

check out MattB325s post distribution centre.   It has a LUA script and a postal truck to do exactly that. Unfortunately I'm unaware of any tutorial as such, but if you copy that script and make sure your building has the final right occupant group, and your truck does too then it should work with that script. Those values are in the script. 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
9 hours ago, atsf189 said:

Is there a tutorial on how to write a script to make a lot spawn cars or trucks?

In addition to @rivit's excellent answer (model your code after existing code which does what you want) you could also read the comments in the lua code in this post to get an idea of what does what. (The code was originally written by @Daeley and then I tweaked and documented it.)

The actual text file is attached there, but in the meantime here's a picture preview:

Cori's Canal Tweaked Lua Code.png

 

Just make sure whatever you create uses unique IIDs for everything so it doesn't interfere with any other content. (Or if it's for your own use only then that's still a good idea, but not required.) *;)

 

  • Like 1
  • Thanks 1

Chance favors the prepared mind. ― Louis Pasteur  
Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

Are you new here? Check out the Introduction and Guide to Simtropolis.

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    9 hours ago, rivit said:

     It has a LUA script

    @rivit @CorinaMarie Do These numbers need to be generated randomly somehow for each truck automata to not cause future conflicts?

     

    automata.gif.443288da19080a9cabc55f48aa5876e2.gif

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    55 minutes ago, atsf189 said:

    Do These numbers need to be generated randomly somehow for each truck automata to not cause future conflicts?

    Yes. I presume you are making your own set to spawn?

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    16 minutes ago, CorinaMarie said:

    Yes.

    @rivit Do I use the random generator in Reader to do this?

    Could the Group ID for the LUA file be used for one of those numbers?

    I am using someone elses model files. I do not know how to create models

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    10 minutes ago, atsf189 said:

    @rivit Do I use the random generator in Reader to do this?

    While you directed your question at Ron, I feel qualified to answer. *:P

    Yes, I've used Reader to generate a random number. You can just pick any instance of an exemplar and tell it Generate new instance, make note of the number, and then exit Reader without saving.

     

    13 minutes ago, atsf189 said:

    I am using someone elses model files.

    Are they readily available? While I have forgotten a considerable amount during my hiatus, I believe I could re-figure out how to write the code you want. (I've done it more than once in the past.)

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    2 minutes ago, CorinaMarie said:

    While you directed your question at Ron

    I just clued him in since he had answered the first question.

    I trust both of you on the subject.

    I have made three scripts so far. They seem to be working.

    I just used 0xa189 thru 0xa689 not generated by the reader.

    I just wanted to follow the correct protocol.

    I must likely will share these lots

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    2 minutes ago, atsf189 said:

    I have made three scripts so far. They seem to be working.

    That's great!

     

    3 minutes ago, atsf189 said:

    I just used 0xa189 thru 0xa689 not generated by the reader.

    That could prolly be fine. I presume you are using Matt's as your base script and tweaking? If so it's possible he later did the same for the increments if he had other lots with generators. Maybe add another digit so there's less chance of a conflict. Such as 0xa1891 thru 0xa6891 or such.

    Also, if that is using their code as the template you'll want the names to be different too or there will be table entry clashes.

    automata_group.uspostal_truck maybe change to: automata_group.uspostal_truck_atsf
    generator.uspostal_out maybe change to: generator.uspostal_out_atsf (in both places)
    occupant_group.uspostal_facility maybe change to: occupant_group.uspostal_facility_atsf

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    4 minutes ago, CorinaMarie said:

    there will be table entry clashes.

    Thank you

    I did not know about the table clashes. I will change both items.

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    20 minutes ago, atsf189 said:

    Thank you

    I did not know about the table clashes. I will change both items.

    If you are curious about the Lua table, you could run the All Tables Report from my CORI Reports code. *;)

    Edit: Whoops. I just checked and that one isn't accessible to my report. *:blush:

    • Like 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    7 hours ago, CorinaMarie said:

    there will be table entry clashes.

    @CorinaMarie

    Are there any files that linger in the game when you use automata then bulldoze the lot.

    This file is crashing my test city unless it is ID 44A56844. I have randomly generated 5 IDs and all crash.

    fedex.lua

    I created a UPS truck lua with  ID 44A56844 and it was working fine until I created the above fedex file with a new ID.

    As long as the fedex file is not in the the plugins folder the ups file still works.

    ups.lua

    After the first crash i noticed the fedex and ups model files had the same IDs. they came from this download

    I have tried using a different model for the fedex lua and it still crashes

    Any ideas on why this is happening????????????????

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    11 minutes ago, atsf189 said:

    Are there any files that linger in the game when you use automata then bulldoze the lot.

    Yes, I believe each generator code gets embedded in the city save. The reason I say this is when I first got annoyed at track checkers, I downloaded the then recommended fix and didn't actually understand the simple steps so I thought it didn't work. *:blush:  Undeterred, I then set about creating my own Lua fix which doesn't require bulldozing anything.  What I discovered by accident was by creating a syntax error it broke the generator and then all track checkers disappeared and never came back. So much so that removing my code or any other tweaking would never, ever let that city tile create them again. :O

    So, based on that, I do believe each Lua coded generator gets written into the save. I don't have the tools to peek tho and say that with absolute certainty. *;)

     

    20 minutes ago, atsf189 said:

    Any ideas on why this is happening????????????????

    Nope, not yet. I have downloaded your two Lua scripts and both files you linked. I'll take a peek when I have time and see if I can come up with an answer.

    Can I assume you are adding the Occupant Group to some ploppable building?

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    30 minutes ago, atsf189 said:

    fedex.lua

    This one seems to be compiled or something? I even tried adding a .dat extension and Reader still didn't like it. The ups.lua is plain text and I can open it.

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    11 minutes ago, CorinaMarie said:

    Can I assume you are adding the Occupant Group to some ploppable building?

    yes

    I am only using the ploppable USPS, DHL. UPS, FEDEX files

    I can make the fedex building spawn UPS trucks with the UPS  lua.

    I will try loading a backup of the city.

    • Like 2

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    44 minutes ago, CorinaMarie said:

    This one seems to be compiled

    fedex.lua

    It crashed the backup city as soon as i put it in the folder

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, CorinaMarie said:

    This one seems to be compiled or something?

    fedex.txt

    • Thanks 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 minute ago, atsf189 said:

    Thanks. (In the meantime @Cyclone Boom recognized it was a compressed output from Reader and fixed it for me.)

    And I'm making some progress, but I see I've not remembered the details very well. I'm re-teaching myself, tho. Turns out not all of those hex numbers can be changed at will. One of them has to be tied to the Automata Group.

    • Like 2
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    12 minutes ago, CorinaMarie said:

    compressed output

    sorry i must have outputted it wrong.

    The original AustraliaPostTruckAutomata.dat file works with the fedex building file in the original city

    Share this post


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

    As a quick reply before I go cook my evening meal, I believe I made a mistake saying they could all be random. I now think the first instance needs to match the IID of the Automata Group which has the vehicle you want to display. So in in line 6:

    group_id = "0xa789",

    Let's try changing that to:

    group_id = "0xa38f",

    with the idea that then matches the OG of the Fed Ex Truck automata exemplar.

    I believe the rest is ok, but I won't be able to test for a while. *;)

    • Like 1
    • Thanks 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, CorinaMarie said:

    Let's try changing that to

    I tried changing that but it crashed.

    This one works but I do not know why

    workingFedEx.lua

    I started with the original AustraliaPostTruckAutomata.dat file.

    Changed the model file then the text and last the instance ID.

    I loaded it before each change to check it in the game.

    IT makes no sense why this is working and not the other file.

    Do you see a typo in the old file that I missed?

    I started from the beginning like this 6 times today and none of those worked either.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    33 minutes ago, atsf189 said:

    workingFedEx.lua

    I'll need to decompress that and I'll take a look tomorrow.

     

    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    19 hours ago, atsf189 said:

    This file is crashing my test city unless it is ID 44A56844.

    To be sure I understand, are you referring to the IID of the Lua Entry or the package signature within the Lua code? I believe I discovered long ago that the package signature (on the first line of the Lua code) must be a positive integer. This means the first digit (of the 8 digit hex number) must be 7 or lower.

     

    For this post we'll be using the Additional Courrier Trucks only. The first step is to look at the Exemplar in each of those. Go to the OccupantGroups and notice the first four (0x00004000, 0x00004002, 0x0000420E, and 0x0000420B) are all standard Maxis defined automata groups (and that's fine). Then notice the last one is 0x0000A38F. This is creator defined.

    I tweaked the top block of the Lua code a wee bit to be:

    automata_group.atsf189_fedex_truck = TTT
    {
       _parent = automata_group.vehicle,
       group_id = "0xa38f",
    }

    Adding that TTT part guarantees the new table we are creating will first be a duplicate of the Maxis defined Tag Templated Table and then we make our changes to it. The group_id = "0xa38f" part is what matches the entry in the OccupantGroups of the Automata's exemplar we just looked at above. (That's in the same .dat file as the S3Ds.)

    The generator section is fine.

    And then the last block is ok as you have it:

    occupant_group.atsf189_fedex_facility =
    {
       group_id = "0xa889",
       controllers = {
                       "atsf189_fedex_out",
                     },
    }

    But you then need to edit the building exemplar so that 0xA889 is one of its OccupantGroups. (Reader will convert that to 0x0000A889 and that's ok.)

    I was partially correct originally that you can adjust both hex numbers, but they also need to match in the corresponding exemplars. For instance both the FedEx Truck and the UPS one each have 0xa38f as their distinct OccupantGroups. If you want to be able to generate them separately, you should change one of them. For my own test I made the FedEx one be 0xF000A38F and then used that in the first block of the Lua code.

    The key part is you can use any random hex number (with the idea to not have the same as anyone else used), but they need to match up in both sections of the code to the appropriate exemplar's OGs.

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    21 minutes ago, CorinaMarie said:

    To be sure I understand,

    i have been randomly generating the IID then changing both to the new number.

    Maybe that is my mistake

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 minute ago, atsf189 said:

    i have been randomly generating the IID then changing both to the new number.

    That should be fine. Just if the first digit is greater than 7 then for the package signature change it to 7 or lower. The full random one for the IID is fine. They do not have to match each other.

    • Like 1
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 minute ago, CorinaMarie said:

    hat should be fine

    how do the letters figure into that

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    34 minutes ago, atsf189 said:

    how do the letters figure into that

    In hex:
    A = 10
    B = 11
    C = 12
    D = 13
    E = 14
    F = 15

    • Like 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


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

    OK thank you and you disregard that part of the PM

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 8/9/2024 at 12:30 PM, CorinaMarie said:

    That should be fine. Just if the first digit is greater than 7 then for the package signature change it to 7 or lower.

    Was there a reason that the programmers limited the package signature to a positive integer?

    --#-package:0eecf277# -- package signature --

    The above line of code it looks like the -- character is used for programmer comments that the game ignores.

    Most  of the comment lines only have it at the beginning. What is having it at both ends of the line telling the game?

    What is the # character telling the game?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    2 hours ago, atsf189 said:

    Was there a reason that the programmers limited the package signature to a positive integer?

    I don't know for certain they did, but empirical evidence indicates that is so. In my own tests when it was a two's complement negative number as converted to decimal the code did not get loaded so I've stated it as a fact as if I really knew what went on back in the Maxis programmer's room. *;)

    Edit: I also suspect that the package numbers dictate the order in which they load and if that's true, then negative numbers would be lower values than positive ones so then they'd have to start out massively negative to have room for later additions. By restricting it to positive only they can have the very first package be 00000001 and know that if a 00000005 is found it'll load after that.

    So, for all the ones we create, they really don't matter for their sequence compared to the Maxis ones because everything in SimCity_1.dat has already run by the time they get to our code (unless you remove them all and then load them externally like CB and I used to do).

     

    2 hours ago, atsf189 said:

    --#-package:0eecf277# -- package signature --

    The above line of code it looks like the -- character is used for programmer comments that the game ignores.

    Yep, it sure does. The -- will be telling the Lua Interpreter to ignore that line, but the game itself can read those and it likely knows to look for --#-package:<hex number># because that is important.

     

    2 hours ago, atsf189 said:

    Most  of the comment lines only have it at the beginning. What is having it at both ends of the line telling the game?

    Makes it look pretty and well balanced. From some of my own Lua Code, compare:

    --toolbox functions

    with:

    -----------------------
    -- Toolbox Functions --
    -----------------------

     

    2 hours ago, atsf189 said:

    What is the # character telling the game?

    I suspect it's similar to how Lua can pass variables to the LText to have it mean something. Like [[Hey #mayor#, you have built #city# very well.]] would say something different to you than to me. They call those tokens or say that the variable has been tokenized.

    I suspect that is simply the way they pass the package signature to the rest of the game engine.

    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    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


    ×

    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