Jump to content
Sign In to follow this  
jms

LUA questions, please help!

7 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online: A long, long time ago... 
 

hi guys, i've just got a few very important lua questions that i was hoping could be answered...

firstly, how are lua scripts executed inside the game?  i'd like to create my own but i'm not quite sure how i'd get it to run.

also, how do i get a lua script to send game variables that are constantly changing to a custom query window that i've made?

help would be greatly appreciated, thankyou.

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online: A long, long time ago... 
     
    15.gif    ...anyone?

    Share this post


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

    I'm not 100% sure, but I think the game runs every LUA script it comes across. It just needs it's own LUA code and IID. The LUA id is the same as the instance id, but the first digit is changed to a zero. Look for an already existing LUA file that has a code like this at the top to figure out a template for doing this...the Maxis ones probably won't have it, so check out a STEX download or maybe the el-rail-UDI file in the NAM (just search the NAM file for a LUA).

    Are these in-game variables or variables of your own?

    Sorry, I'm no LUA expert...just giving you answers until, say Daeley stops by.

    -qurlix

    Share this post


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

    ok here's a few questions before i can give you asnwers:

    1. Do you have any experience in modding? 
    2. Do you have any exprerience in programming? (any language - even matlab - is a plus)
    3. What do you plan to do? Chances are that you either don't need LUA for it, or that it's impossible to do with LUA.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online: A long, long time ago... 
     

    hi daeley,
    no i don't really have any experience in modding but i plan to within the next few months.  i'm looking to add a mod to the game which can extract certain game variables that you cannot usually see while playing the game.  it'd help if i could design a query window to display these changing variables or if i can just send these variable values to an external .dat file or whatever hopefully using a batch script inside the lua script.
    it's a small project i'm working on and would like to construct a model with the data i extract.  the variables i'm looking at analysing are basically all the constant changing variables in the game, so in the lua scripts, most of the 'game.####' variables.  i'm almost finished my software engineering degree, i'm familiar with most languages and although i haven't used lua before, it seems fairly straight forward.

    thanks for your time.

    and thanks qurlix, i'm reading through the regional tracking mod for some tips, but i can't get the thing to run so there's not much point, i'll check out the other mods you've suggested.

    Share this post


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

    as I somewhat suspected, you don't need LUA to do this. if all you want to do is simply show variables (or simple calculations on variables) you can do this in the UI itself, by using script "tags" in the LTEXT files.

    for example, suppose you want an UI (or news message for that matter) to say this: "congratulations mayor mayorname, we have now reached a population level of total_res_population"

    this would look like the following in the LTEXT file:

    congratulations mayor #mayor# we have now reached a population level of #game.city_r_population#

    You can put snippets of LUA code or variables between # and the game will simply replace them. Simple calculations also work, for example #(game.city_r_population/game.region_r_population)*100# will show the percentage of people in your city compared to regional population etc.

    some good examples of this are Equinox' query mod and my old ninja tax collectors lot.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online: A long, long time ago... 
     

    thanks a lot daeley, just a few more questions...

    how would i go about copying these variables that i display to an external file such as a .txt one?
    and also, can i make my UI refresh every second or so, so it displays variables that are constantly changing?  or must i manually click on an object to make the UI appear again with a new set of data?

    thanks so much for your help.

    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  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×

    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