View Full Version : Select Object by Category

6th Aug 2012, 7:12 PM
I'm modding Inge's StayThingsShrub (http://www.drealm.info/simlogical/sl/Sims2Pages/Sims2_MiscHacks.htm) to keep things based on the object's category (right now, just toilets), but I must be messing up something simple in the line, cuz it's not working. I would also like this to become active on placement, rather than a pie menu and I'm thinking I can do that on the controller object's placement, but will that still affect all the objects that get placed after the controller goes down? Or is there a way of telling all that code to happen right before move-out?

I've attached a picture of the only line of code I've changed, so that has to be where my screw up is; cuz Inge's object works. Right?

7th Aug 2012, 12:26 AM
It shouldn't be looking at "Stack Object's Attribute 0x0010", it should be looking at "Stack Object ID". :)

I know there's a "Just Moved In" function hook, but I don't think there's a "About to move out" equivalent. There's something called "Global Awareness" which might be receiving global hooks, but to be honest I don't think I've ever actually seen it used, and I've certainly never used it, so that's a wild stab in the dark from me!

7th Aug 2012, 1:10 AM
What about a global hack that would always prevent these objects from disappearing on move out? Would I just import the semi-globals from each category and set the flag in each ones Init line? Would that affect custom objects as well?

7th Aug 2012, 3:08 AM
You could... Sort of. Most objects have a semi-global fallback for init, so it would work for them, but there are a lot which don't.

There is a hook point you could use, I considered using it once for a "challenge/storytelling gameplay mode" project, but it's a delicate one.

Pretty much every object in game calls up to global "0x010F: Init - Object" in its initialization tree. That can include tokens, props, controllers, sims, not just regular catalog objects... So it's something you really, really want to handle with care. It's the most basic, low-level point I've found where you can intervene with BHAVs, and it will intervene, to the best of my knowledge, with pretty much everything.

So you could put it in there. But, you know... There be dragons, etc etc... :)

7th Aug 2012, 3:49 AM
That sounds scary and bad and considering how badly I suck at BHAV coding, maybe I should just stick to the object version. I'll mesh it into a For Sale sign, so users will likely place it last. I can still make all of that code run on the placement of the object, so I won't need a sim to interact with it?

Edit: Awesome. That fixed it. It was highly amusing to see a completely blank house with nothing but toilets in it. Epic lulz. Now to add in all the other things that are supposed to stay. And, I got it to work on object placement too. I have learned a few tricks!

Edit: Everything is awesome and working perfectly. I just need to mesh up a cute little sign. Project piece (pretty much) done! Yay! Now I just have to get the moving boxes to work, and this whole thing is ready!

8th Aug 2012, 12:41 PM
Yay! Glad to hear it was so easily sorted!

12th Dec 2012, 6:01 PM
Project status is here: http://www.phaenoh.blogspot.com/search/label/Moving%20Day

14th Dec 2012, 11:56 PM
Were you thinking about allowing the user to ask all furnishings to stay, similar to the existing Stay-Things Shrub, or is this just for specific objects?

My logic for reimbursing the family for the lost object value is coming along. There seems to be a small problem with some lots that the value reimbursed is slightly larger than the value lost, but I'm having problems finding the problem.

15th Dec 2012, 1:03 AM
Originally I had planned on not doing that, but I suppose it could be included back in as a pie menu option and just the regular built in fixtures as the default.

I was working on something else and I noticed that in the OBJD there is a line that says 'move out with'. Couldn't technically I change all the (maxis) objects that I always want to stay and they'd stay put on their own to begin with? I imagine that's how trees and flowers stay put, and they still get to count in lot value. Could that help at all with the lost value? It wouldn't help at all with any CC objects, but it was an idea I had.

Glad to hear you are making progress with the value issue. I don't use the original shrub enough (cuz I always forget to place it when I'm building) at the right time so I never noticed it. That was my reason for having the objects predetermined. Here's my current version of my object. :)

15th Dec 2012, 1:19 AM
Yes, I believe that modifying the objects to stay would solve the problem permanently. And, yes, that would fix the lot value since the objects would be added correctly to the appropriate objects total. It's a completely different approach and would probably work well, but would require a lot of object fixes if people want their lots to remain fully furnished.

15th Dec 2012, 4:11 AM
Yeah, but it wouldn't work on CC at all unless every single piece was modded as well, and my fave thing to download tends to be sexy CC bathroom sets... :( I prefer the route you are going if you can make it work. With the categories though, we could have a 'Everything Stays' pie menu, as well as 'bathroom fixtures', 'lights', 'kitchen built-ins', and go down the line from there. That gives more options and more options is always better. :)

15th Dec 2012, 5:07 AM
I grabbed it and took a quick look. Looks great. It seems reasonable to add a menu to allow people to choose all objects, and to add my reimbursement code to both sets of objects. I'll look into doing that tomorrow and get it back to you. Then, if you want to add more categories, that would be great.

What if someone deletes the for-sale sign? Does it restore the moveable flag, or does it just leave everything as is? It might make sense to restore the objects to their normal state if the for-sale sign is deleted.

15th Dec 2012, 5:28 AM
I have no idea what happens if you delete it. I didn't test it much. I put it some of the Desdirata's houses and then booted out the families and checked to see that they still had all their stuff. Then I put the family back in and deleted the sign. : shrug :

15th Dec 2012, 4:43 PM
OK, I'll take a look at deleting it; I believe that it should probably reset the objects on deletion.


Just FYI: You've made your main logic run in Init. That means that the object just needs to be created to change the value of your lot. Since the object is created when you view the catalog, you don't even have to place the sign on the lawn for your sim to lose money. I understand that you want the objects to become stayable as soon as the object is placed, but you probably don't want the current behavior, so I'll see whether I can fix that too.

16th Dec 2012, 4:53 AM
OK, I'm stumped. How do you run code when an object is actually purchased and placed on the lot, rather than when it is selected from the catalog but not yet placed on the lot?

16th Dec 2012, 5:10 AM
While not 100% confident, I think that the code from the Main line gets run on placement. I have a calendar that manages to watch until 6am on the lot and then does something and its always been right so far. Most other objects just have some sort of idle loop on their Mains. Maybe try that?

16th Dec 2012, 5:16 AM
Nope. I tried adding the call to the beginning of Main and it was called as soon as the object hovered over a valid square.

16th Dec 2012, 6:22 AM
In the OBJF there are things like 'Placement' and 'User Placement' that say they run when the object placement is changed or when a user clicks to place an object. You can stuff BHAVs in there. My calendar updates itself on 'Go Live'. There is also an interesting one called 'Just Moved In' that gets called on objects that come to a new lot via inventory it looks like. Not sure if that last one will be useful, but the first two should be.

16th Dec 2012, 7:01 PM
Both Placement and User Placement run as soon as you grab the object in the catalog, before you place it on the lot. A bit better than Init, but still not right.

Go Live sounds interesting. I'll try that. The nice thing is that this would allow the object to update if you purchase something new.

16th Dec 2012, 7:48 PM
You could also try some sneaky work around in Init or main, set the flags so that it has to be placed outside on the ground and then run a loop asking 'am i on the ground' until it's actually placed, it shouldn't return true, right?

16th Dec 2012, 9:12 PM
I suppose that I should have listed everything that I had already tried in my post asking for help. Sorry.

I tried something similar: checking the room ID, but that also occurred too early... as soon as you hover over the room. My guess is that "am I on the ground" will also return true far too early. Although, there's no harm in trying it. Oddly, the game really doesn't seem to distinguish between getting ready to place an object and actually placing it; you'd think that would be an important distinction.

The for-sale sign seems to be working fairly well with Start Live Mod to make the objects stayable and to reimburse the family for the lost lot value, and Delete to make them moveable again (thus resetting the lot value). Unfortunately, we'd have to warn people about going into Live mod before moving out. We'll also need to explain why the family is getting cash when they set their house for sale.

I was going to do some more testing, and add an option to sell the completely furnished lot, rather than just the "built-ins". Alternatively, we could share several different versions and allow people to choose one. Are people likely to want the same behavior every time? I suspect so.

If you'd like to see what I've got so far, let me know.

16th Dec 2012, 9:31 PM
If you have something you think is working, roll with it. As far as sharing it, I haven't done much with this (nor with my original one), so you should totally upload it and just mention me for the 'just the built-ins' feature. I wasn't planning on releasing this all until I had the rest of my set (the boxes) done, and I don't foresee working on that anytime soon. I think I was planning on tweaking at the texture and the mesh a bit more before I released it though. The one you have from me is blatantly borrowed (stolen) from KiaraRawks (http://www.modthesims.info/member.php?u=63403) so I was going to work on that a bit more still. I'll try to get you a changed mesh and texture for it soonish though.

17th Dec 2012, 12:24 AM
If there's no hurry, I'm going to do some more research. Although it seems to make sense to reimburse the family for their lost lot value, in practice it seems counter-intuitive.

For example, your family has the for-sale sign on their lot. They buy a new toilet for $1000 and they can see their lot value increase by $1000 and their family funds decrease by the same amount. Then, you go into live mode and you can see your family's fund increase by $1000. When you check your lot value, it's decreased by the same amount. But, the new toilet is still on the lot!

It really would be better if your family funds were unaffected and your lot value remained constant regardless of whether the objects will stay on the lot or disappear on move-out.

Because of this, I'm going to try again to find some way to restore the object value to either the moveable or stayable totals. I had another idea which probably won't work, but it can't hurt to try.

17th Dec 2012, 2:48 AM
No hurry what-so-ever. ;) If you noticed, I hadn't touched this project since mid August! You are right about it being counter intuitive, so it would be cool if you do find a way of getting it to work the way we think it should. I keep thinking of ways that it might work too, and then I realize they couldn't... >.> frustrating.

2nd Jan 2013, 4:00 AM
I finally had a moment to change up the mesh and make a new texture for this. How have your holidays been going? :)

Attached is the new mesh file and texture. I wasn't sure how much you had done to the packages so I thought this might be better.

2nd Jan 2013, 1:36 PM
I dropped the project for the Christmas holidays. Now that we're into the new year, I suppose that I should try again. I'm still not very happy with the way that it's working, although I believe that the logic is basically correct.

I suspect that the whole thing needs a re-think. Reimbursing someone for their lost lot value seems quite reasonable, but the actual behavior just seems unexpected. It might be better if people could not modify the lot (build / buy) while the for-sale sign was on the lot.

Even if you don't take my reimbursement logic, I would suggest that you modify when the stay-logic occurs. As it is, you only have to choose the category from the catalog for the lot to lose value. I suppose that's why Pescado put the magic wand into its own collection... people won't accidentally depreciate the lot when they are looking for something else.

2nd Jan 2013, 5:45 PM
No, I think I'm on board with the reimbursement. We could think of it like the seller is paying out closing costs or something. That happens, right? Anyways, no rush on this at all, I just wanted to get you the mesh and new texture in case you were moving faster on it that I was. ;)

3rd Jan 2013, 2:41 AM
Quatchi just had a thought that looks interesting. (He's a great sounding board.)

I wonder whether we could add the value of all of the stayed objects to the price of the for-sale sign? That way, the total value of the lot should remain constant. The main problem is that the value of all stayed objects may be larger than the highest possible price of an object. In that case, it may make sense to make a series of invisible moveable objects which will carry the additional price.

This avoids the pitfalls of the current method, but should still ensure that the family gets the full value for the lot.

3rd Jan 2013, 2:43 AM

From working with changing car pricing, I think the most expensive you can make an object is $32000, so if we are just talking the fixtures and built-ins we will be hard pressed to get to that limit, but doing a stay-everything will need another method.

3rd Jan 2013, 3:23 AM
Makes me wonder why we didn't come up with that idea earlier...

Anyway, we should be sure to thank him in the download thread.

From working with changing car pricing, I think the most expensive you can make an object is $32000, so if we are just talking the fixtures and built-ins we will be hard pressed to get to that limit, but doing a stay-everything will need another method.I must be lucky. My test lot ended up with fixtures costing $30,250... just under the wire. And I wasn't even using the most expensive fixtures!

So far, this is looking really good. My sim ended up with exactly the right amount of money on move-out and the lot ended up with the right furnishings.

I'm going to look into the delete code next. Then I'll look into fixture values > 0x7FFF.

4th Jan 2013, 7:46 PM
I updated the mesh and texture, but it doesn't look quite right. Could you take a look at it, please?

This contains the logic for objects with a total value <= $32,767. Play with it a bit and let me know what you think.


1) The moveable -> stayable code is executed each time that you go into live mode. This should handle both new objects and deleted objects. However, it won't handle objects like gifts, or those which are placed into a sim's inventory... at least until the user goes into build mode, then back into live mode. At this time, we don't have a strategy for those kinds of objects.

2) For some reason, deleted objects aren't handled the first time that you go into live mode. I found that I had to go live, build, live to get the correct lot valuation after deleting a stayable object. I'm still looking into this problem. [Fixed with next version]

3) The sign will show a sale value of the total value of all stayable objects on the lot. However, if you sell the sign, you'll only get $15. We'll need to warn the user about this, unless we hide the objects value in hidden objects instead. Since we'll want that logic for object values > $32,767 anyway, I think that's the right long-term solution.

4) For now, I've disabled depreciation on the sign. It's just too confusing, at least while I'm using the sign to store the object values. If we decide to hide the object values in hidden objects, then we can reenable depreciation.

5) I haven't done anything to handle multiple signs on a lot. We should probably make the first sign the one that contains the object values, and leave the rest as decorative only. We should also check whether the sign is the last one on the lot before running the stayable -> moveable logic. As it is now, they will probably fight each other. [Fixed with next version]

6) When the family moves out, the lot will have a value which is too low. That's because objects are not deleted by the game during move-out, but are deleted when the lot is entered for the first time. Once the lot is edited, the sign will be deleted and the lot value will be restored.

4th Jan 2013, 10:46 PM
I've change the mesh (and lowered the polys by half) and darkened the texture a slight big, moved the sign over in the tile while retaining any animations we may like to use. I unticked all the boxes for View, Kick, and Cry, because they all ended in the sign being kicked over and looking dumb. I also moved the sign to Gen Misc because it's not a decoration, and that's where a lot of 'cheat tools' end up. I've also made the darn thing recolorable with 2 subsets - the post and the sign, cuz people like that. This is also the first time I've been able to overcome my constant 'not recolorable' problem - yay for personal victory.

I did not see a sale value, is that debug only? I agree with disabling depreciation, it's silly for a little sign anyways. I hadn't even thought about multiple signs on a lot. I can't think of why anyone would do that, but it's good to be prepared for it. I'm not sure what you mean about the last point but it doesn't sound good.

5th Jan 2013, 1:29 AM
3) By "sale value", I meant: if I pick up the sign on my lot, it shows a value of $30,000+. However, if I delete the sign, I don't get an additional $30,000; I just get my $15 back. Just try picking up and deleting the sign and you'll see what I mean.

6) The last point (about the lot value) is similar to the problem that we see with the Stay-Things Shrub: the lot value after moveout doesn't include the cost of the stayable items. However, unlike the Stay-Things Shrub, the lot value will fix itself if you just edit and save the lot. This is a function of when the game actually gets around to deleting the objects on a lot. The game doesn't delete the furnishings as soon as the family moves out. Instead, it sets a flag. The next time that you enter the lot (whether it's to edit the lot or to move another family in), the game notices the flag and deletes all the furniture. At that time, the for-sale sign will be deleted and the lot value will be restored.

For my example lot, the lot value is $30000 after moveout and $60000 when I edit the lot.

The only other option would be to hook in to the move-out code somehow and reset the lot value at that time.

[Update:] The mesh still doesn't look right to me; the for sale sign is half the height that it used to be.

5th Jan 2013, 8:35 PM
I'm seeing something which is confusing and I wonder whether anyone can help?

When an object on the lot is deleted in buy mode, the object is still found by the Set To Next command. I've checked and "include disabled objects" is not checked in the Set To Next command. If I go into Live mode, then back into Buy mode, the object has (finally) disappeared from the object list.

Is there some way to ensure that my Set to Next does not get deleted objects? Is there a way to tell the game to delete all pending objects before proceeding? Is there some way to determine whether an object has been deleted, but has not yet been removed from the list of objects?

[Update:] I have solved the problem by ignoring all objects whose room < 0. Is there any reason why this would be a bad solution to my problem? Is there a better solution?

5th Jan 2013, 8:57 PM
Nope, I made its shorter to infringe less on the original mesh. All the House for Sale signs I've ever seen are never taller than your waist. I can make it taller again if you don't think it looks good.

5th Jan 2013, 9:34 PM
I've never seen a for-sale sign that was that short in real life. Sounds like this may vary by where you live. I'm fine with this height, if you like it this way.

I sort of miss the interactions. I was looking forward to seeing my sims cry when looking at the sign. I also thought that sims who didn't like someone in your family might come by and cheer when they saw the sign.

6th Jan 2013, 1:08 AM
I'll make it a tad taller, and I only disabled the interactions, I didn't remove them. We need to stop the 'kick it all the way over' part, but I do want the crying and the small kicking in it. Cheering sounds cool too.

6th Jan 2013, 4:27 AM
Here is a reference image of typical north american realestate for sale signs. Note the size of the person mowing the lawn relative to all the signs. Signs typically stand shoulder height or taller.

8th Jan 2013, 9:55 PM
OK, I've changed the sign so that values > $32K can be handled by hidden objects on the lot. As many objects as necessary will be spawned.

Notes (continued from post #31):

1) No change. Still doesn't handle gifts and inventories until user chooses Build or Buy then Live mode.

2) Resolved. Deleted objects are handled as soon as Live mode is entered.

3) Resolved. Hidden objects now hold the entire stayable objects value.

4) Partially resolved. Since we are no longer using the visible signs to store the stayable objects value, we should be able to reenable depreciation on the visible signs only.

5) Resolved. Multiple signs are now handled correctly. The first sign to be placed will make the objects stayable. The last sign to be deleted will make the objects moveable. There is no longer a duplication of effort or values. Signs can be deleted in any order.

6) No Change. I can't think of any way to get the sign deleted after the sims move out, other than to edit the lot.

Things that still need to be done:

7) Allow people to select categories, including All.

8) If a hidden sign finds that there is no sign visible on the lot, then make all objects moveable again and delete all hidden values. This is an unlikely occurrence, but should be included for completeness sake.

9) Ensure that people can't use the slot for anything except for the hidden objects which hold the stayable objects value. [Will be in next version]

10) Reenable interactions. Add crying and cheering interactions. [Phaenoh]

11) Given Quatchi's pictures, I think that it might be nice to make the sign a bit taller (Although I just can't believe how tall those real-life signs are... larger than a mailbox? That seems a bit much!). [Phaenoh]

12) Might be nice to have some visible indication that the stayable logic has been run. Perhaps the sign could change color, or give a sale price, or ...?

13) The mod needs some code cleanup. If possible, break into sub-BHAVs to document the code a bit, since it's fairly complex.

8th Jan 2013, 10:17 PM
I'll up the mesh height. Maybe not as tall as Quatchi's pictures, but I'll make it comparable to the mailbox. I'll also work on a texture for the sign when the stayable logic has run, maybe a SOLD sticker plastered over it? Or the real estate agent's phone number? Something. I'll work on it. For the code to get it to change, we should look at lamps or counters or other multistate objects. Though, as I recall, that might make recolors later harder.

I'll also look into fixing the cheering and crying. Having the sign get knocked over is a problem, but it isn't that hard to make new interactions that circumvent the Deviant Behavior (that also allows the sign to be steal-able, which would surely cause us more headaches.)

For the slot issue, you can have it check for a specific GUID. Echo made me a chair template that checked for more of itself. (Was working on stacking chairs)

11th Jan 2013, 4:30 AM
Another question:

I thought that I could create a tuning package for this mod by creating a new package with just the BCON and TRCN which control the categories of objects which are considered "built-in". Of course, both the BCON and TRCN have a Group ID of 0xFFFFFFFF. My understanding was that this is replaced in-game by the Group ID in the NREF record, so I replaced the Group ID in my tuning package with this new Group ID. However, the new values in the tuning package were not picked up.

Can someone spot what I'm doing wrong? Do I need to change all of the Group IDs in the main mod to have the Group ID from the NREF record? [Update: this works, but it isn't very elegant.]

2nd Oct 2014, 11:49 PM
I've uploaded this. http://www.modthesims.info/download.php?t=537238

I was so close to having pie menu options to either Keep Everything, or just Keep Fixtures, but I guess I had trouble with my grammar. Both of those runs of BHAVs works as the Go Live hook, but they don't work when I have a sim try to do it. I've left them in as Debug menu items if someone can take a look at where I went wrong in the 'Interaction - Set Fixtures' and 'Interaction - Set Everything' BHAVs.