Post Reply 
 
Thread Rating:
  • 5 Votes - 3.4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modding Modern Times
Author Message
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #1
Modding Modern Times
The loading sequence used for Tropico 4 consists of loading the base game packages (HPKs), and then loading the DLC (including the Expansion code). Nothing spectacular has changed. Here's the load sequence from MT, and the corresponding shutdown (if you need it)


Load Sequence

Code:
Message fired: Autorun
Message fired: ClassesGenerate
Message cleared: ClassesGenerate
Message fired: ClassesPreprocess
Message cleared: ClassesPreprocess
Message fired: ClassesPostProcess
Message cleared: ClassesPostProcess
Message fired: ClassesBuilt
Message fired: DataInstancesLoaded
Message cleared: ClassesBuilt
Message cleared: Autorun
Message fired: (M) Start
Message cleared: Start
Message fired: ChangeMap
Message fired: MissionStorageChanged
Message fired: Resume
Message fired: OpenMainMenu
Message fired: LeavingGameplay
Message fired: MissionStorageChanged
Message fired: UASetMode (Pre-Game)
Message fired: BackgroundMovieStarted
<-- DLC Loads here -->
Message fired: Pause
Message fired: UASetMode (Boot)
Message fired: ReloadLua
<-- Where I bypass the reload issues -->
Message fired: XboxRecheckSigninState
Message fired: XPlayerSignin

Shutdown sequence
Code:
Message fired: ApplicationQuit
Message fired: Autodone

The ReloadLua message is where the code breaks, so we need to bypass that somehow. By creating a thread which runs in parallel to the main Lua state, we can install our mod here. (Note: You probably don't need the FirstLoad stuff, but without it anyone firing the Boot message could do nasty things to your code.)

The problem with this approach is that the building and unit classes are built (or compressed) prior to the fact, and we lose in the modding point I introduced before.

However, prior to MT being released, and after some experimentation, I found out where the classes went, and why. While this has made modding some building functionality difficult, there are ways around it.

First of all, here's the loading code (with a little bit of over the top protection code (i.e. `single use' checking)):

Code:
function MyMod()
    -- Do things here
end

-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

    -- Fire until fired once
    if not FiredOnce then
        -- If we boot, trip it ...
        if(mode == "Boot") then
            FiredOnce = true
            
            -- Run the thread to bypass it
            CreateRealTimeThread(function()

                -- Do mod loading code here.
                MyMod()
                
            end)
        end
    end
end

If you wanted to mod the apartment, you'd need to mod each instance of it, so you'd replace MyMod with the following:

Code:
function MyMod()
    g_Classes.Apartment_01.num_families = 1
    g_Classes.Apartment_02.num_families = 2
    g_Classes.Apartment_03.num_families = 3
    g_Classes.Apartment_04.num_families = 4
end

This would setup the variants to have a different number of families in them, giving you more customisation.

If you wanted to add additional variants, you can still do that at the original injection point by defining the entities:

Code:
OnMsg.ClassesPreprocess = function()
    DefineClass.TyrannusApartment001_04 = {__parents = {"Apartment"}, entity = "Apartment_04"}
end

--------- <edit>

If your mod ceases to work after playing an old map, or fails to work when switching between MT and non-MT saves/campaigns, just load the function with the actual modification again:
Code:
OnMsg.MapPermanentObjectsLoaded= function()
    MyMod()
end

Your setup should be a function which is easy to recall (use something unique or you'll get conflicts), which is called in the big 'OnMsg.UASetMode = function(actions,mode)' block, and called again in the DataInstances block. Again, if you're adding new entities or forms (i.e. Apartment_05), then you do that once in the ClassesPreprocess stage (it won't be reset because it won't be replaced because it didn't exist before).

--------- </edit>

Due to various factors, including people asking me to do things I'm really not interested in doing, while I'll be happy to help people mod, I'm not going to be actively releasing things. (If you want someone to blame, try the people who kept asking me to bypass the DLC.)

Using the loader code (i.e. the OnMsg.UASetMode snippet above) you can load my old HPKs, or use "dofolder" to re-execute my mods. What this fixes or breaks is beyond the scope of what I care about. Tyrannus probably runs fine again, but the car edict isn't really important now anyway.

Note: The per-building code has always worked, it's just annoying for people to employ.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
(This post was last modified: 25-05-2012 09:55 PM by Swixel.)
06-04-2012 07:32 AM
Find all posts by this user Quote this message in a reply
TurtleShroom Offline
Censor
****

Posts: 238
Joined: Aug 2010
Post: #2
RE: Modding Modern Times
Swixel, I love you.

Jesus loves you and died for you!!
---

Religious (+++) Leader
Capitalists (++)
Intellectuals (+)
Militarists (+)
Communists (---)
Environmentalists (---)
06-04-2012 10:39 PM
Visit this user's website Find all posts by this user Quote this message in a reply
simcutie Offline
Junior Member
**

Posts: 44
Joined: Apr 2012
Post: #3
RE: Modding Modern Times
Putting mod lua files into "ex/Game" folder for Modern Times (instead of "Game" folder for vanilla Tropico 4) helps a lot. I solved many problems in moding with this. (like making new edicts) OnMsg.ClassesPreprocess() works as it did in original.
(This post was last modified: 11-05-2012 04:58 PM by simcutie.)
11-05-2012 04:34 PM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #4
RE: Modding Modern Times
Yes, but to not need two files, you can just approach it using a larger loading block (as above).

I thought about ex/Game, but then I realised I'd need a loader for Game too ... and then ex isn't 'officially' part of the VFS, so it wouldn't even mount, meaning the core data would have to be Game, which is overloaded ... there's a way around that with placement and mucking around, but if you want to support both, this should still work better than just ex/Game + Game

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
11-05-2012 09:43 PM
Find all posts by this user Quote this message in a reply
PapiGamer Offline
Newbie
*

Posts: 5
Joined: May 2012
Post: #5
RE: Modding Modern Times
Can someone please help me, I am finding it impossible to find the new DLC building LUA files. When I got Tropico 4 vanilla, I used some other peoples mods for a time and then made my own that incorporated different ideas. I orignally got all the info I needed from the GAME.HPK file (unpacked specifically GAME\CLASSES\BUILDINGS\building name.LUA). The problem being I cannot find the following buildings using this technique (so I can update my mod):
* Solar Power Plant
* Telecom HQ
* Ship-O-Rant
* Bio Farm
* Borehole Mine
* Fish Farm
* Supermarket
* Swat HQ
* Modern Apartment Block (and other new housing)
* National Bank
* Crystal Cathedral
* Sanatorium
* Car Factory (and other new industry)
etc etc with all the new buildings basically.

I have opened up all the .HPK files I could see, and have not found them anywhere.

I have been thru all the info at BitBucket (from Swixel's link) but it did not contain all the information that I needed.

Any help appreciated.

This game is my most favourite city building game of them all.
27-05-2012 12:42 AM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #6
RE: Modding Modern Times
You need dlc\Expansion.hpk
Steam has it in the directory, everything else I know about is in %APPDATA%\Tropico 4\dlc

I can add more to the info I dumped if you want it. I haven't looked at it for a while because there was never any real demand (I removed a lot of old modding stuff which wasn't interesting ... Tongue).

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
27-05-2012 01:31 AM
Find all posts by this user Quote this message in a reply
PapiGamer Offline
Newbie
*

Posts: 5
Joined: May 2012
Post: #7
RE: Modding Modern Times
Ahh...I didnt even think to go look over in the APPDATA area.

That is exactly what I needed.

Tyvm.
27-05-2012 02:18 AM
Find all posts by this user Quote this message in a reply
Togfan Offline
Senior Member
****

Posts: 200
Joined: Apr 2012
Post: #8
RE: Modding Modern Times
(Disclaimer: I don't know lua so if I sound n00bish, it's because I am n00bish)

(06-04-2012 07:32 AM)Swixel Wrote:  I'll be happy to help people mod

I'm trying to do the basic tutorial (editing parameters of existing buildings) and create different versions of some buildings, but of course, it won't work.

I'm not sure what to do (actually I have no idea) so I'm just trying to read carefully the explenation but it doesn't actually help me that much. Enough talk--here's the coding.

[spoiler]
Code:
Message fired: Autorun
Message fired: ClassesGenerate
Message cleared: ClassesGenerate
Message fired: ClassesPreprocess
Message cleared: ClassesPreprocess
Message fired: ClassesPostProcess
Message cleared: ClassesPostProcess
Message fired: ClassesBuilt
Message fired: DataInstancesLoaded
Message cleared: ClassesBuilt
Message cleared: Autorun
Message fired: (M) Start
Message cleared: Start
Message fired: ChangeMap
Message fired: MissionStorageChanged
Message fired: Resume
Message fired: OpenMainMenu
Message fired: LeavingGameplay
Message fired: MissionStorageChanged
Message fired: UASetMode (Pre-Game)
Message fired: BackgroundMovieStarted
<-- DLC Loads here -->
Message fired: Pause
Message fired: UASetMode (Boot)
Message fired: ReloadLua
<-- Where I bypass the reload issues -->

Message fired: XboxRecheckSigninState
Message fired: XPlayerSignin

-- 'OnMsg' hooks are called on messages being passed
-- "ClassesPreprocess" is used part way through loading the classes.

OnMsg.ClassesPreprocess = function()
    Apartment["money_cost"] = 7000
    Apartment["num_families"] = 12
    Tenement["money_cost"] = 7000
    Tenement["num_families"] = 32
    Church["num_serviced"] = 16
    Cathedral["num_serviced"] = 42
    Cathedral["num_workers"] = 6
    Cathedral["money_cost"] = 30000
    ShoppingMall["num_serviced"] = 60
    ShoppingMall["num_workers"] = 12
    ShoppingMall["money_cost"] = 35000
    StockExchange["num_workers"] = 30
    StockExchange["money_cost"] = 20000
    Marketplace["num_workers"] = 6
    PoliceStation["num_workers"] = 20
    SkyscraperOffice["num_workers"] = 175
    SkyscraperOffice["money_cost"] = 50000
    DefineClass.TawgApartment001_02 = {__parents = {"Apartment"}, entity = "Apartment_02"}
    DefineClass.TawgTenement001_02 = {__parents = {"Tenement"}, entity = "Tenement_02"}
    Apartment_02["money_cost"] = 4000
    BankModern["num_workers"] = 180
    BankModern["money_cost"] = 45000
    DefineClass.TawgBankModern001_02 = {__parents = {"BankModern"}, entity = "BankModern_02"}
    BankModern_02["num_workers"] = 240
    BankModern_02["money_cost"] = 50000
    BankModern_02["male_worker_class"] = Office Worker
    BankModern_02["female_worker_class"] = Office Worker
    
        -- Upgrade [1] is the first one (lua lists start at 1)
    -- This sets the aircon power to 0, the quality boost to 1, and the price to $1
    Apartment["upgrades"][1]["price"] = 2000
    Apartment["upgrades"][1]["param1"] = 20
    Apartment["upgrades"][1]["power"] = 2
end

OnMsg.MapPermanentObjectsLoaded= function()
    MyMod()
end
    


Message fired: ApplicationQuit
Message fired: Autodone
-- Dance.
Code:
function building_edit()
g_Classes.Apartment_01.num_families = 12
g_Classes.Apartment_02.num_families = 6
g_Classes.Apartment_01.num_families = 32
g_Classes.Tenement_02.num_families = 16

end

-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

    -- Fire until fired once
    if not FiredOnce then
        -- If we boot, trip it ...
        if(mode == "Boot") then
            FiredOnce = true
            
            -- Run the thread to bypass it
            CreateRealTimeThread(function()

                -- Do mod loading code here.
                MyMod()
                
            end)
        end
    end
end
[/spoiler]
What have I done wrong/what do I miss/what did I place wrong/what did I write wrong/dafuq am I trying to do/what the heck have I been doing?

Political views:
Capitalists (+++)
Intellectuals (+++)
Enviromentalists (++)
Nationalists (+)
Militarists (+)
Loyalists (-)
Religious (--)
Communists (---)
15-10-2012 04:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #9
RE: Modding Modern Times
(15-10-2012 04:36 PM)Togfan Wrote:  (Disclaimer: I don't know lua so if I sound n00bish, it's because I am n00bish)

I didn't know Lua before I started this, don't worry, it's easy Smile

Just change the function you used for the preprocessing to MyMod (so it runs):

Code:
MyMod = function()
    Apartment["money_cost"] = 7000
    Apartment["num_families"] = 12
    Tenement["money_cost"] = 7000
    Tenement["num_families"] = 32
    Church["num_serviced"] = 16
    Cathedral["num_serviced"] = 42
    Cathedral["num_workers"] = 6
    Cathedral["money_cost"] = 30000
    ShoppingMall["num_serviced"] = 60
    ShoppingMall["num_workers"] = 12
    ShoppingMall["money_cost"] = 35000
    StockExchange["num_workers"] = 30
    StockExchange["money_cost"] = 20000
    Marketplace["num_workers"] = 6
    PoliceStation["num_workers"] = 20
    SkyscraperOffice["num_workers"] = 175
    SkyscraperOffice["money_cost"] = 50000
    DefineClass.TawgApartment001_02 = {__parents = {"Apartment"}, entity = "Apartment_02"}
    DefineClass.TawgTenement001_02 = {__parents = {"Tenement"}, entity = "Tenement_02"}
    Apartment_02["money_cost"] = 4000
    BankModern["num_workers"] = 180
    BankModern["money_cost"] = 45000
    DefineClass.TawgBankModern001_02 = {__parents = {"BankModern"}, entity = "BankModern_02"}
    BankModern_02["num_workers"] = 240
    BankModern_02["money_cost"] = 50000
    BankModern_02["male_worker_class"] = Office Worker
    BankModern_02["female_worker_class"] = Office Worker
    
        -- Upgrade [1] is the first one (lua lists start at 1)
    -- This sets the aircon power to 0, the quality boost to 1, and the price to $1
    Apartment["upgrades"][1]["price"] = 2000
    Apartment["upgrades"][1]["param1"] = 20
    Apartment["upgrades"][1]["power"] = 2
end

But you'll need to change these to things like:

Code:
-- old: Apartment["upgrades"][1]["price"] = 2000
g_Classes.Apartment_01.upgrades[1].price = 2000

Or in the second ...

Code:
function MyMod()
    g_Classes.Apartment_01.num_families = 12
    g_Classes.Apartment_02.num_families = 6
    g_Classes.Apartment_01.num_families = 32
    g_Classes.Tenement_02.num_families = 16
end

-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

    -- Fire until fired once
    if not FiredOnce then
        -- If we boot, trip it ...
        if(mode == "Boot") then
            FiredOnce = true
            
            -- Run the thread to bypass it
            CreateRealTimeThread(function()

                -- Do mod loading code here.
                MyMod()
                
            end)
        end
    end
end


Basically, Modern Times does a reload which kills the Preprocess. You can load it/use it by placing it elsewhere, but, frankly, I should've used this approach before, as it gives each unique building entity (i.e. the 4x Tenement/Apartment building 'looks') their own stats if you choose.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
15-10-2012 08:31 PM
Find all posts by this user Quote this message in a reply
Togfan Offline
Senior Member
****

Posts: 200
Joined: Apr 2012
Post: #10
RE: Modding Modern Times
Now the local file works fine (thanks Big Grin)
And another thing that doesn't work is the internal .hpk file... It's placed in boot/persist/zTogfan.hpk as it said in the first tutorial but that doesn't work?

Political views:
Capitalists (+++)
Intellectuals (+++)
Enviromentalists (++)
Nationalists (+)
Militarists (+)
Loyalists (-)
Religious (--)
Communists (---)
(This post was last modified: 15-10-2012 10:36 PM by Togfan.)
15-10-2012 10:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #11
RE: Modding Modern Times
It should. But anyway, you can just create the Game folder in the same folder as Tropico 4 (so, at the same level of 'boot').

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
15-10-2012 10:49 PM
Find all posts by this user Quote this message in a reply
Togfan Offline
Senior Member
****

Posts: 200
Joined: Apr 2012
Post: #12
RE: Modding Modern Times
Ok I got a question--what would I have to do if I for example wanted to make a new building using a currently exisiting model? Is it also possible to do that in the .lua file placed in Tropico4\Game\ or does it need to be in Tropico4\Packs?
Also, how to change the type of worker? (when I tried it crashed the mod)

Political views:
Capitalists (+++)
Intellectuals (+++)
Enviromentalists (++)
Nationalists (+)
Militarists (+)
Loyalists (-)
Religious (--)
Communists (---)
17-10-2012 04:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #13
RE: Modding Modern Times
I used packs in the past because I shipped many, many, things. The loose files are loaded *instead* of files in the packs, so they're the same things anyway. You just need to make sure you don't overload an existing file.

As for making a building, it's a question of entity. While I never released the pub with no beer, I did release duplicates of housing which used existing models. You could also pull Apartment 3/4 out and use them as a new type -- they're smaller looking. Or maybe 1/2 (being bigger).

You'll need to look into the building structure though (and understand it). I'd recommend using a decompiler on whichever buildings you want ... though you'll probably need to build the decompiler first. (Mine isn't finished, nor is it public.)

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
17-10-2012 07:46 PM
Find all posts by this user Quote this message in a reply
Graham1 Offline
Newbie
*

Posts: 1
Joined: Nov 2012
Post: #14
RE: Modding Modern Times
Is a modification to Call To Power II, specifically being developed for the upcoming Apolyton Edition, taking advantage of the enhanced modding features and improved performance introduced by the Source Code Project. Both the Apolyton Edition and this Mod are still under development. When some sort of final version of CTP2 AE will be released I will hopefully be able to release some sort of beta version of this Mod, too.

http://www.cheapcarhireguide.com/car-rental-deals.html
http://www.plagiarismsoftware.net/
http://www.airlinesplanet.com
27-11-2012 08:57 AM
Find all posts by this user Quote this message in a reply
Psyckosama Offline
Junior Member
**

Posts: 19
Joined: Nov 2012
Post: #15
RE: Modding Modern Times
So, is there any way to mod it so you don't lose your older buildings when the replacement time comes around and still have the option of using them?
27-11-2012 12:04 PM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #16
RE: Modding Modern Times
Sure, just break/filter the timeline's effect.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
27-11-2012 08:50 PM
Find all posts by this user Quote this message in a reply
Psyckosama Offline
Junior Member
**

Posts: 19
Joined: Nov 2012
Post: #17
RE: Modding Modern Times
(27-11-2012 08:50 PM)Swixel Wrote:  Sure, just break/filter the timeline's effect.

Cool. Thanks. So how do you do that?

Is there any way to do it so you can still get the newer buildings?

If it will take modding, is there a how to guild to modding?
(This post was last modified: 28-11-2012 01:33 AM by Psyckosama.)
28-11-2012 01:19 AM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #18
RE: Modding Modern Times
I don't think anyone other than SimCutie and myself ever poked around extensively enough to put together a guide.

I basically stopped releasing things once my PMs and email inbox overflowed with "can I unlock the locked buildings" (i.e. bypass DLC restrictions) and things like that.

As for what you want to do the easiest way to do it is to create a switching building menu pool (I haven't had time yet, but I know what I'm doing because Tyrannus used this). There's a table which stores the menu items. If you take that and then switch it out as required you'll get what you need. The problem is, as Timo identified (and a few of us have in other places (cf. other boards/etc.)) is balance.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
28-11-2012 02:26 AM
Find all posts by this user Quote this message in a reply
Psyckosama Offline
Junior Member
**

Posts: 19
Joined: Nov 2012
Post: #19
RE: Modding Modern Times
(28-11-2012 02:26 AM)Swixel Wrote:  I don't think anyone other than SimCutie and myself ever poked around extensively enough to put together a guide.

I basically stopped releasing things once my PMs and email inbox overflowed with "can I unlock the locked buildings" (i.e. bypass DLC restrictions) and things like that.

I can understand that. If I knew how I'd do it myself and just post it up.

Quote:As for what you want to do the easiest way to do it is to create a switching building menu pool (I haven't had time yet, but I know what I'm doing because Tyrannus used this).

switching building menu pool?

Quote:There's a table which stores the menu items. If you take that and then switch it out as required you'll get what you need.

Is it a UI thing or a case of "swamp the menu when you want to use the older buildings"

Quote:The problem is, as Timo identified (and a few of us have in other places (cf. other boards/etc.)) is balance.

I only intend to use it on Sandbox anyways, and then its less about balance and more about having a good time mucking about in the game.

Campaign I believe should be left as intended.
28-11-2012 02:37 AM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #20
RE: Modding Modern Times
If you reverse the menu related code you'll see it pretty quickly. But the problem will be stopping the existing code from eating it. I've looked into it a bit and would like to actually do it (been wanting to since about April), but there are loose ends you'll find tugging elsewhere. i.e. the timeline code will push updates you don't want to your stack, meaning you need to keep two backup copies and deep copy the tables on switch *or* change the menu it calls based on a key, which requires rewriting the building menu code (which I did once before).

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
28-11-2012 08:33 PM
Find all posts by this user Quote this message in a reply
Psyckosama Offline
Junior Member
**

Posts: 19
Joined: Nov 2012
Post: #21
RE: Modding Modern Times
(28-11-2012 08:33 PM)Swixel Wrote:  If you reverse the menu related code you'll see it pretty quickly. But the problem will be stopping the existing code from eating it. I've looked into it a bit and would like to actually do it (been wanting to since about April), but there are loose ends you'll find tugging elsewhere. i.e. the timeline code will push updates you don't want to your stack, meaning you need to keep two backup copies and deep copy the tables on switch *or* change the menu it calls based on a key, which requires rewriting the building menu code (which I did once before).

I wish I knew how to do that. I'm pretty ignorant as to how this game is modded. Sad

It's why I asked if there was as 'how to'.
29-11-2012 01:46 AM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #22
RE: Modding Modern Times
The game is written largely in Lua (5.1). It works well, is reasonably fast, but it multithreaded so a lot of weird things can happen if you mod things too early or late.

This thread was designed to show you where to inject data for certain things. For modifying the data you want it should work too. But there's a lot you'd need to do to get a clean copy of the building menu system.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
29-11-2012 06:25 AM
Find all posts by this user Quote this message in a reply
Psyckosama Offline
Junior Member
**

Posts: 19
Joined: Nov 2012
Post: #23
RE: Modding Modern Times
Yeah. Seems like SimCuties's mod did it, but for some reason it doesn't work in 1.06...
30-11-2012 11:10 PM
Find all posts by this user Quote this message in a reply
MichaelW Offline
Newbie
*

Posts: 3
Joined: Dec 2012
Post: #24
RE: Modding Modern Times
help please.
For example, how can I change these values?
name = "Newspaper", __parents = {"NewspaperImpl"}, area_effects = {Liberty = {falloff = 350, radius = 300}},
What code should be to change these values(falloff and radius)?

or this example
DefineClass.Trees = {__autogenerated = true, __parents = {[1] = "BeautyObject"}, area_effects = {Beauty_Decors = {amount = 2, falloff = 100, radius = 80}}

how it should look in the script?

PS Sorry for my English)
(This post was last modified: 24-12-2012 07:48 AM by MichaelW.)
24-12-2012 07:47 AM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #25
RE: Modding Modern Times
Something like:

g_Classes.Newspaper.area_affects.Liberty.falloff = 512


If you know Lua, it's just variable assignment within tables. Just traverse the names within the instance.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
26-12-2012 01:55 AM
Find all posts by this user Quote this message in a reply
MichaelW Offline
Newbie
*

Posts: 3
Joined: Dec 2012
Post: #26
RE: Modding Modern Times
(26-12-2012 01:55 AM)Swixel Wrote:  Something like:
g_Classes.Newspaper.area_affects.Liberty.falloff = 512
Unfortunately, this is not working.
Moreover, if this line insert like this(for example):

Church["money_cost"] = 10
g_Classes.Newspaper.area_effects.Liberty.radius = 1
Bungalow["money_cost"] = 100

line @Church["money_cost"] = 10@ work
line @Bungalow["money_cost"] = 100@ does not work
(26-12-2012 01:55 AM)Swixel Wrote:  If you know Lua
I do not know LUA Sad
(This post was last modified: 27-12-2012 01:06 PM by MichaelW.)
27-12-2012 01:05 PM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #27
RE: Modding Modern Times
Can you please paste your whole script? I had a look this morning and my injection code is still working here (I have all DLCs bar Vigilante).

Also, your radius is tiny; the default is 40. You may also want to play with fall-off and amount.

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
29-12-2012 09:21 PM
Find all posts by this user Quote this message in a reply
MichaelW Offline
Newbie
*

Posts: 3
Joined: Dec 2012
Post: #28
RE: Modding Modern Times
(29-12-2012 09:21 PM)Swixel Wrote:  Can you please paste your whole script?

Code:
-- Original mod code
function MyMod()
     Apartment["money_cost"] = 100
     Church["money_cost"] = 10
     Pub["money_cost"] = 10
     Apartment["num_families"] = 14
     Bungalow["money_cost"] = 100
     Newspaper["blueprint_cost"] = 1
     Newspaper["money_cost"] = 100
     Cathedral["money_cost"] = 200
     Cathedral["num_people_serviced"] = 32
     Church["job_quality"] = 90
     Church["num_people_serviced"] = 22
     DiplomaticMinistry["money_cost"] = 200
     Dock["job_quality"] = 90
     FishFarm["money_cost"] = 100
     Garage["money_cost"] = 100
     Garage["job_quality"] = 90
     HealthClinic["money_cost"] = 100
     HighSchool["money_cost"] = 100
     HighSchool["service_time"] = 10000
     g_Classes.Newspaper.area_effects.Liberty.amount = -500
     g_Classes.Newspaper.area_effects.Liberty.falloff = -500
     g_Classes.Newspaper.area_effects.Liberty.radius = 1
end

-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

     -- Fire until fired once
     if not FiredOnce then
         -- If we boot, trip it ...
         if(mode == "Boot") then
             FiredOnce = true
            
             -- Run the thread to bypass it
             CreateRealTimeThread(function()

                 -- Do mod loading code here.
                 MyMod()

                 -- Reconfigure/force the settings every map load.
                 OnMsg.MapPermanentObjectsLoaded = function()
                     MyMod()
                 end
             end)
         end
     end
end

-- Legacy load (what the original mod used)
OnMsg.ClassesPreprocess = function()
     MyMod()
end

I use this code to immediately see it works or not(for checking). But these lines do not work, no changes:
g_Classes.Newspaper.area_effects.Liberty.amount = -500
g_Classes.Newspaper.area_effects.Liberty.falloff = -500
g_Classes.Newspaper.area_effects.Liberty.radius = 1


P.S^ Tropico 4 + Modern Times
(This post was last modified: 29-12-2012 09:49 PM by MichaelW.)
29-12-2012 09:47 PM
Find all posts by this user Quote this message in a reply
Swixel Offline
Epic Member
*******

Posts: 1,087
Joined: Sep 2011
Post: #29
RE: Modding Modern Times
Have you tried setting falloff and amount to zero, rather than a negative number? I have no way of knowing if negative numbers work as I've never tried them.

If the rest isn't working there's a fairly simple reason: while global (i.e. _G) appears to be used (sort of), things like Church["money_cost"] = 10 shouldn't work. You should be using g_Classes.Church.money_cost = newcost. (EDIT: I should probably clarify I've moved away from direct assignments like that; that's the old system which applied when there was no complex DLC loading. Now I sued g_Classes for specificity.)

And I should correct myself (was looking elsewhere), the defaults for Newspaper effects are (copied from my notes, so ignore my array syntax here):
Code:
g_Classses = {
    ["Newspaper"] = {
        ["area_effects"] = {
            ["Liberty"] = {
                ["radius"] = 300,
                ["falloff"] = 350,
            },
        },
    }

"I am not ashamed to confess I am ignorant of what I do not know" ― Cicero.

"You had to hand it to the Patrician, he admitted grudgingly. If you didn't, he sent men to come and take it away." ― Terry Pratchett (Guards! Guards!)
(This post was last modified: 30-12-2012 02:55 AM by Swixel.)
29-12-2012 10:02 PM
Find all posts by this user Quote this message in a reply
Pezzaro Offline
Newbie
*

Posts: 4
Joined: Jul 2012
Post: #30
RE: Modding Modern Times
Hello everyone, i desperately need a script for increase my apartment living spaces.
My not working.

local MyMod = function()
Apartment["num_families"] = 12
ChildhoodHome.unique = false
EternalFlame = false
ChemicalPlant.unique = false
SkyscraperHotel.unique = false
SkyscraperHotelModern.unique = false

end

-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

-- Fire until fired once
if not FiredOnce then
-- If we boot, trip it ...
if(mode == "Boot") then
FiredOnce = true

-- Run the thread to bypass it
CreateRealTimeThread(function()

-- Do mod loading code here.
MyMod()

end)
end
end
end


Very sorry for my english

Thanks
(This post was last modified: 17-02-2013 08:27 PM by Pezzaro.)
17-02-2013 07:35 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | kalypso media :: website | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication