Someone asked me, how to make an object become invisible in Live Mode and visible again in Build/Buy Mode. Good for OMSPs, kind of like my Invisible Kitchen Surface.
This tutorial is for a non-recolorable object, or an object whose recolor doesn't matter to you. It'll just change material based on whether you're in Live Mode or not and ignore the recolor chosen by design tool.
on cMaterialDefinition tab, rename the material in Description field to something resembling invisibility
copy-paste the new name to Filename field adding _txmt at the end
change Type to Null
fix TGI and Commit
Add both visible and invisible material names to text list #88
create this resource, if there isn't one in your package already:
clone an existing text list, i.e. Model Names
change its instance number from 85 to 88
change its filename to Material Names or something like that
remove model names or whatever text was written there
copy-paste your visible and invisible material names to any two lines
if the TXMT is custom, i.e. created by you, add ##0x1C050000! in front of the name
if the TXMT is an in-game resource, don't add ##0x1C050000! (like maybe you're editing a Maxis object and using its original material for the visible state)
Commit File
Add the subset name you want to become invisible to text list #87
create this resource, if there isn't one in your package already:
clone an existing text list, i.e. Model Names
change its instance number from 85 to 87
change its filename to Subset Names or something like that
remove model names or whatever text was written there
write the subset name to any line (find it in GMDC -> Groups)
Commit File
Create a BHAV named Function - Stop Live Mode
clone an existing BHAV, i.e. Function - Init
change its instance number to a number that hasn't been used yet (say, there are BHAVs from 1000 to 1006 in your package, then use 1007)
change Filename to: Function - Stop Live Mode
delete all lines (Special Buttons -> Delete to end), it won't let you delete line 0, that's ok
select line 0
change OpCode to 2
open raw entry box by clicking a quotes button
if your object is 1-tile, copy-paste this: 00000B0000050A030000000000000000
if your object is multi-tile, copy-paste this: 0000130000050A030000000000000000
you should see: Expression (Stack Object ID := My object id) or Expression (Stack Object ID := My lead tile object ID)
change True Target to 1
change False Target to Error (using drop-down list)
add a line (click Add)
select the new line 1
change OpCode to 6D
click an X button to set all operands to zero
copy-paste this to raw entry box: 00000000000A00000A00000000000000
you should see: Change Material (Stack Object ID, Me ("something"), Me ("something"))
open a wizard by clicking a wrench and axe button
make sure you see the visible material name and the subset you want to toggle (if material name is long, place your cursor on it and click keyboard right arrow to go to the end)
if material or subset is wrong, change index number until you see the right one (don't click fast forward buttons, they don't work)
change True Target to Return True (using drop-down list)
change False Target to also Return True
Commit File
Create a BHAV named Function - Start Live Mode
clone the Stop Live Mode BHAV you've just finished
change its instance number to an unused number (if there are BHAVs from 1000 to 1007 in your package, use 1008)
change Filename to: Function - Start Live Mode
select line 1
open a wizard
change material index number to the invisible one
Commit File
Add the new functions to OBJf
open the OBJf, there's probalby at least one in your package
select Start Live Mode
click a play/triangle button next to Action BHAV field
choose your Function - Start Live Mode
Okay it and make sure it appeared in the Action BHAV field
select Stop Live Mode and do the same for Function - Stop Live Mode
Commit File
if your object is multi-tile and has more OBJfs, you may have to do the same for them (actually, you might have to do it only for the lead tile's OBJf and leave the rest alone, but I'm not sure and I don't feel like testing, if you do it, tell me the results please :D)
Notes
In apartments, this method causes the object in hidden unit to show itself when not in Live Mode. If it bothers you, you could add checks for that to BHAVs.
For recolorable objects, if you want the game to respect the recolor chosen by design tool, it's a bit more complicated. You can do it the way clean and dirty material states are done, with additional MMATs and TXMTs and the right naming and flags and stuff. There's probably a tutorial somewhere on how to do clean and dirty states, just consider clean state as visible and dirty state as invisible. Basically, you'll have to add a dirty TXMT and MMAT to every recolor and rename all of them. The correct naming is important in this case. If your object already has clean and dirty states and you want to keep them, there's an option to use lit and unlit states for this purpose, but I haven't tried it. It'll probably multiply the amount of TXMTs and MMATs like crazy, if it even works. I don't recall any objects that have lit/unlit as well as clean/dirty states, it might not be doable.
New: To Avoid Object Becoming Visible During Cutscenes
I found out that if you have special events camera on, then objects edited by this method would become visible during cinematics, because apparently they trigger the 'Stop Live Mode' function. What you would do to avoid that is add a line at the beginning of 'Function - Stop Live Mode' to check for presence of Cinematic Placeholder on the lot and not perform material change if it finds it.
So, in Stop Live Mode BHAV,
- change Local Var Count to 1 (if it wasn't 0, you may want to add +1 and use a different local further on)
- click on the line 0 and then click 'Ins/false' button; it will copy that line
- click back on the new line 0 and change its op-code to 1F
- open the wizard and adjust it to say: Set to Next Local 0x0000, object of type: GUID 0xCD87F642
- change its true target to return True and false target to lead to node 1
Thank you for the tutorial! I have used it to edit these OMSPs. I did have to do a couple of tweaks and I wonder whether this is an issue with the object or because I did something else wrong.
--> In the txt list materials name I had to put them in a certain order: first the invisible txmt and then the original txmt
--> I've added an extra line in the BHAV between stack object and change material: stack object's graphic: literal 0x0002 (removing this line did not fix the issue with the txmts having to be in that specific order)
As long as you point to the right material name in the Change Material primitive in the BHAV, the order in which they are listed in the text list doesn't matter. It's not wrong to have them the way you have them, if it's easier for you. (In some cases, MMATs also look into the list and you have to point them to the right lines, but not in this case.)
Your objects only have one model/graphic, so adding a graphic change is not what I would do. You're basically telling it to display a second model when it doesn't exist. Doesn't it give you errors? Maybe the game ignores it. Is there something you were trying to achieve with it?
@Lamare Thanks for your quick reply! Following your tutorial doesn't turn the object invisible in live mode, the material didn't change at all. That's why I started poking at it and trying different things. I think the extra line came from your invisible counter. Now that I've looked at it a bit more, it doesn't give me any errors because that particular line in model names is empty. So I can just remove it.
The order of the materials still matters, if I reverse them (and fix the lines in the BHAVs so they correspond) it stops turning invisible.
The order of the materials still matters, if I reverse them (and fix the lines in the BHAVs so they correspond) it stops turning invisible.
Weird. Maybe there really is something special about your objects. I bet on MMAT or some kind of texture reset. Being recolorable and having an MMAT shouldn't be a problem in itself, I tested SilentLucidity's OMSP for this tutorial, and it is recolorable, and the order of materials does not matter. Attaching the file in case you're interested in poking around in it. Although, you managed to make it work, right? The rest is history :D
If the single tile object doesn't have multiple colors or container slots, wouldn't it be easier to switch it to a null graphic similar to how we have pedestrian portals invisible? This way we don't need to deal with textures and materials, which is quite complex. Adding a graphic only requires changing a text list. This doesn't work with recolorables, which revert to the first color on update graphic.
If the single tile object doesn't have multiple colors or container slots, wouldn't it be easier to switch it to a null graphic similar to how we have pedestrian portals invisible? This way we don't need to deal with textures and materials, which is quite complex. Adding a graphic only requires changing a text list. This doesn't work with recolorables, which revert to the first color on update graphic.
It would, yes!
This tutorial started with me working on an object that had recolors and container slots. I have been asked to share how I did it, so I whipped this up.
If I was a good tutorial writer and set off to thoroughly explore the topic, I would list all the ways to achieve this result, but alas.
Thank you for mentioning it!