Surviving Mars

Surviving Mars

Modify your Mars journey
Modify your Surviving Mars experience using mods created and shared by the Surviving Mars community.
Leost 10 Jul, 2019 @ 9:24pm
Simple modding help
I'm wanting to modify an existing building and have no clue how to go about doing that.

First, is it possible or is it better/easier to make a new building completely? I've created a new mod and added a building template. I've tried setting the building class to the existing building I want to modify (Cement Plant), but then have no idea what to do. Is there a way to populate the template with the existing values of the normal building so I can change them? Do I just ignore the fields I don't want to change and just change the ones I want? Really no idea what to do.
< >
Showing 1-9 of 9 comments
ChoGGi 456 10 Jul, 2019 @ 10:01pm 
What are you trying to change?
Leost 11 Jul, 2019 @ 1:36am 
I want the Concrete Plant to accept Concrete and output Rare Metal. I want the ratio to be roughly 5:1. No waste rock should be produced. Might be nice but not needed to change the building to not require the Russian sponsor.

With existing mods and normal in-game buildings Concrete is the biggest resource I end up with having way to much of at end game and I want something to do with it besides your bottomless supply depot. Advanced resources have a similar problem but their production is sufficiently slower that I can usually manage with just adding storage. Concrete on the other hand is needed to be produced because I usually want the waste rock from the Excavator for other mods which use waste rock for things but that means I need a place for all the Concrete.

Leost 11 Jul, 2019 @ 1:37am 
5:1 might be way too much actually. Perhaps 5:1 to make 1 normal metal and then I can use your Golden Storage to convert that to Rare Metal later. I'm not really wanting the income, I just hate destroying the resource.
ChoGGi 456 11 Jul, 2019 @ 1:51am 
Not tested, but it'll probably work (you can figure out the ratios yourself), just paste it into a code section (in mod editor go to new mod>code).
https://pastebin.com/2v7M6ry5

Edit: This'll only apply to newly placed buildings, let me know if you want to update existing ones.
Last edited by ChoGGi; 11 Jul, 2019 @ 1:52am
Leost 11 Jul, 2019 @ 3:21am 
ChoGGi, that works great. Is there anyway to suppress the warning about the building not working when there is insufficient concrete? This is intended as a way to handle excess supply so it's a bit annoying to have that message all the time. Your Golden Storage avoids this as the building isn't a producer, it's just a depot, but I like that this thing takes some input (maintenance/energy) to operate.
ChoGGi 456 11 Jul, 2019 @ 3:34am 
function ConcretePlant:ShouldShowNotWorkingNotification() return false end
Leost 11 Jul, 2019 @ 3:40am 
Man you know this stuff without needing to look.

Ok, one more question. Well, maybe two.

So looking at your Golden Storage code I see where you add the options to the game:

-- max 40 chars
DefineClass("ModOptions_ChoGGi_GoldenStorage", {
__parents = {
"ModOptionsObject",
},
properties = {
{
default = false,
editor = "bool",
id = "Default10",
name = T(302535920011353, "Default to 10 items"),
},
},
})


If I wanted to let the user specify a number instead of a true/false, how would I do that? I assume 'editor' would need to be set to some other value than bool and 'default' would need to be a number rather than false. Is this possible?

Also, if I wanted this building to shut itself on and off when the player has more or less than a certain amount of a resource how can I do that? I would need to define a function that the game would call once in a while so I could check the resource, I would need to know how to access the value for that resource and then compare it to the setting from above. Obviously the name of the class above would be different and I would also not use the id "Default10".
ChoGGi 456 11 Jul, 2019 @ 3:55am 
just take a look at some of my other mods
{ default = 15, max = 25, min = 0, editor = "number", id = "NumberExample", name = T(0, "number slider"), },
neg numbers don't work btw, and no step sizes (hopefully next update).


If you add stuff manually without adding the corresponding entries in items.lua; saving in the mod editor will remove anything not added. I don't use the mod editor, so it doesn't matter to me (if you're wondering about the blank items.lua).
Last edited by ChoGGi; 11 Jul, 2019 @ 4:03am
ChoGGi 456 11 Jul, 2019 @ 3:59am 
function YourBuilding:BuildingUpdate(dt, day, hour)
YourBuilding.building_update_time = const.HourDuration (default for the Building class obj).

Check out Lua\ResourceOverview.lua / ResourceOverviewObj if you need the count.


btw fresh blood is always welcome on the modders discord: https://discord.gg/FeWVN3t
Last edited by ChoGGi; 11 Jul, 2019 @ 4:01am
< >
Showing 1-9 of 9 comments
Per page: 1530 50