• Welcome to SC4 Devotion Forum Archives.

Scripting Help

Started by cogeo, March 16, 2007, 08:57:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cogeo

Hi all,
I have seen a lot of plugins containing LUA scripts performing almost every function, eg enabling rewards, managing menus, spawning automata etc etc. Is there some tutorial or reference conaining the "language" definition? The language seems quite extensive, with capabilities like creating structures and arrays, loops, external (or built-in?) functions and the like. Please let me know if such a document or manual exists (a link would be highly appreciated).
Thanks -

BarbyW

Daeley is the LUA expert so I would suggest a PM to him. He can give you links to the various on stuff about LUA.
Inside every old person is a young person wondering what happened. TP



Barbypedia: More alive than the original

cogeo

Thanks for the suggestion Barby. I'm gonna send him a PM right now!  :thumbsup:

cogeo

#3
Hi again,

I'm making a set of roadtop stations for the Avenue/GLR puzzle pieces (incl in NAM June 2007).
The set will contain two stations that serve both Subway and GLR (ie GLR/Subway and GLR/Subway/Bus). I think it could be a good idea to make a script that would rid the game of that stupid "marriage" (subway + EL) message, if one of the above stations is plopped, and not just the ingame Subway-to-Elevated Transition. I have examined the ingame station carefully but could not find something special, like an Occupant Group. The only "weird" feature that exemplar contains is a "Misc Type 1" property, but it's just an LTEXT name.
So I guess this is done by some LUA script, but unfortunately I have no clue. Could someone please help please? (I have already PMed Daeley).

Thanks -

EDIT: Just found the script that generates that message. It examines variable game.g_num_rapidtransit_transitions which is "the number of subway-to-elevated rapid transit track transitions in the city" as the comment says. But what sets this variable? As mentioned above, I have found nothing special in this building exemplar. Is it possible that it's somehow hardcoded, eg check the TGI ID of the building exemplar?
A similar case is with DeadWood's garbage query. It displays the number of W2E plants and numner of incinerators in the city. The game appears not to count any occupant groups (there is no Building:"Incinerator" occupant group anyway), but instead the number of buildings with the "Waste to energy monthly Capacity" and "Incinerator monthly capacity" properties set.

Andreas

I think those "game.g_num_..." variables are hardcoded into the game, to make it easier to count certain buildings or other stats. There are also variables for the number of neighborhood connections and other stuff, which cannot be counted via an occupant group. So if you don't want those messages, I guess you'll have to change the script itself.
Andreas

Swamper77

Cogeo,

The TGI of the LUA file that has all the variables that are defined by Maxis is this one:

0xca63e2a3 0x4a5e8ef6 0xffbf9ccf

Some of them don't work and have comments near them. Comments start with a "--"

-Swamper77
You can call me Jan, if you want to.
Pagan and Proud!

cogeo

Andreas and Swamper: Thank you for your replies. I have found the scripts were these variables are declared, but no script modifying them directly. I considered a script modifying these when a Sub+GLR station is plopped or destroyed, but I'm afraid this might not work if the game re-calculates that variable say every months or every few months. I guess this is a hardcoded thing, counting buildings with some specific properties set (like the W2E/Incinerator cases I mentioned above), but was not able to find which ones.

daeley

as for your first question, LUA is not an SC4-specific language, it's an existant scripting language used in many applications... as such there are quite a few documents available on programming in LUA, just search google. The original site supporting LUA is http://www.lua.org/

as for your other questions, I'm not quite sure what you mean without having those files at hand...

if you are referring to news that pops up under certain conditions, these conditions have no relation what so ever to any building (and will most certainly not be found in exemplars) but they will be based upon game variables - which, in turn might have some relation to ingame buildings, but you will have to check the appropriate LUA file for that.

all the game.g_ ... (and similar) variables are hardcoded to be updated with the appropriate value every so often (probably a function of game performance)

1. Install SC4+RH
2. Install LEX (CD&DVD helps) and latest NAM + updates
3. Play the game
4. ? ? ? ?
5. Profit!