|
Post by jacklegend13 on Jul 3, 2021 16:03:53 GMT -5
Idk if anyone has ever worked with object stacking before but from what I have gathered in testing it, you have to know the height of the object to slot them? That seems a bit defeating... Although Ive only worked with two objects so far, pallettes and moving boxes cc I grabbed off the net ATS4 I think was the creator. Pallet is EA poo haha. Anyways I figure you have to know the slot hash to place, not 100% sure how to get the slot array of an object yet so I test in game and grab it from there for now. And not 100% on getting object dimensions either. So that is probably my question. How do I get the height (Y axis or Up axis) of an object? and where do I get the slot array stored in an object? Heres my code and a pic of what I have so far... def stack_object(obj, parent, hash=1968627898, height=0.42578125): if obj is None: return zone_id = services.current_zone_id() translation = sims4.math.Vector3(0,height,0) orientation = sims4.math.Quaternion(0,0,0,1) transform = sims4.math.Transform(translation, orientation) slot_hash = hash level = parent.location.level routing_surface = SurfaceIdentifier(zone_id, level, SurfaceType.SURFACETYPE_OBJECT) location = obj.create_parent_location(parent, transform=transform, joint_name_or_hash=None, slot_hash=slot_hash, routing_surface=routing_surface) obj.location = location
|
|
|
Post by network on Jul 3, 2021 18:51:10 GMT -5
Maybe I've been doing it wrong but I've always just added slots in the s4s slot menu? Like add slot, name it the name of whatever slot size you need, open the mesh in blender to find the coords, enter the coords, done.
|
|
|
Post by o19 on Jul 4, 2021 1:56:34 GMT -5
How should this work for a shelf or a pallet? On a pallet one can usually place more than one item. In-game the items have slots and one can place something there (eg in a container), no matter which total height the item has. As network said the items need slots and with them you should be fine. Unless you want to do something different.
|
|
|
Post by jacklegend13 on Jul 4, 2021 6:05:21 GMT -5
Yeah thats all done when you use the game in live mode and build mode. I'm using python mode lol. I redid the slots for that pallet, had to and know the coord. etc but in programming if you want a function to operate dynamically, for any object, you want acess to where that info is stored in the object. An array. Thats what Im looking for. I didn't find anything yet, not in python so I had to create an array myself with those coord. plotted like so. This is both functions working together to stack a pallet and make it appear in game like you see above. Well a random stack anyways:
pallet_slots = [1968627903, 1968627891, 1968627902, 1968627900, 1968627897, 1968627890, 1968627899, 1968627901, 1968627896] pallet_slots_x = [-0.5, 0.0, 0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5] pallet_slots_z = [0.5, 0.5, 0.5, 0.0, 0.0, 0.0, -0.5,-0.5,-0.5] pallet_height = 0.26171875 box_slot = 1968627898 box_height = 0.42578125 parent_obj = None
def stack_object(obj, parent, hash=1968627898, translation=None): if obj is None: return zone_id = services.current_zone_id() orientation = sims4.math.Quaternion(0,0,0,1) transform = sims4.math.Transform(translation, orientation) slot_hash = hash level = parent.location.level routing_surface = SurfaceIdentifier(zone_id, level, SurfaceType.SURFACETYPE_OBJECT) location = obj.create_parent_location(parent, transform=transform, joint_name_or_hash=None, slot_hash=slot_hash, routing_surface=routing_surface) obj.location = location
def place_pallets(target, amount=None): global parent_obj if amount is None: amount = int(random.uniform(1, 5))
for i in range(amount): pallet = objects.system.create_object(9864548688675136184)
if pallet is not None: level = target.location.level translation = target.location.transform.translation orientation = target.location.transform.orientation orientation = sims4.math.Quaternion(orientation.x, orientation.y + random.uniform(-1.0, 1.0), orientation.z, orientation.w) pos = sims4.math.Vector3(translation.x + random.uniform(-2.0, 2.0), translation.y, translation.z + random.uniform(-2.0, 2.0)) zone_id = services.current_zone_id() routing_surface = SurfaceIdentifier(zone_id, level, SurfaceType.SURFACETYPE_WORLD) pallet.location = sims4.math.Location(sims4.math.Transform(pos, orientation), routing_surface) pallet.scale = 1 parent_obj = pallet
def place_stacked_pallet(target, amount=None): try: global parent_obj, pallet_slots, pallet_height global box_height, box_slot
place_pallets(target, 1) if amount is None: amount = 9
for i in range(amount): box = objects.system.create_object(13264424721853849121 + int(random.uniform(0, 5)))
if box is not None: level = parent_obj.location.level translation = sims4.math.Vector3(pallet_slots_x[i], pallet_height, pallet_slots_z[i]) orientation = parent_obj.location.transform.orientation zone_id = services.current_zone_id() routing_surface = SurfaceIdentifier(zone_id, level, SurfaceType.SURFACETYPE_WORLD) box.location = sims4.math.Location(sims4.math.Transform(translation, orientation), routing_surface) box.scale = 1 stack_object(box, parent_obj, pallet_slots[i], translation) stack_amount = int(random.uniform(1, 3)) parent = box for s in range(stack_amount): stack = objects.system.create_object(13264424721853849121 + int(random.uniform(0, 5))) stack.translation = sims4.math.Vector3(0, box_height, 0) stack_object(stack, parent, box_slot, stack.translation) parent = stack
except BaseException as e: error_trap(e)
|
|
|
Post by network on Jul 4, 2021 8:08:04 GMT -5
Python mode? Are you trying to write a mod that automatically stacks these items? I'm sorry but I'm lost.
EDIT: also your image doesn't display and if I go to the direct url it wants me to log in.
|
|
|
Post by o19 on Jul 4, 2021 14:14:31 GMT -5
In the EA code are a lot of references to "object_slots". It may be worth to try to use them, "get_slot_info() returns "slot_name_hash" and "slot_transform".
The height may not be needed, TS4 seems to calculate it based on the position of the stacked object to the position of the parent. Iterating through a pallet with objects to find a free slot may be some work.
Otherwise one may read the .package files and extract the slot information out of the rig type (0x8EAF13DE) while I think there is no Python package available to do this and it requires some effort to port it from S4PE (https://github.com/s4ptacle/Sims4Tools).
|
|
|
Post by jacklegend13 on Jul 5, 2021 7:31:48 GMT -5
In the EA code are a lot of references to "object_slots". It may be worth to try to use them, "get_slot_info() returns "slot_name_hash" and "slot_transform". The height may not be needed, TS4 seems to calculate it based on the position of the stacked object to the position of the parent. Iterating through a pallet with objects to find a free slot may be some work. Otherwise one may read the .package files and extract the slot information out of the rig type (0x8EAF13DE) while I think there is no Python package available to do this and it requires some effort to port it from S4PE (https://github.com/s4ptacle/Sims4Tools). Thank you. I'll have to work around that function to get the info I need. I know alot of you don't see the need for this but what I'm trying to do is save a stacked/slotted object as a deco item, saved to a text file and loaded anytime you want that same item placed without having to set it up again in build. Also if anyone has ever had to decorate a store/stock shelves you know how tedius this is in build, so I want code to do it for me. Would be even better if a sim as a night stocker would actually interact and stock the shelves but maybe I'll do something like that later
|
|
|
Post by o19 on Jul 5, 2021 15:30:06 GMT -5
One can save rooms in edit mode which is often a great help, at least when building something. One may store full shelves in the room to avoid python at all but you're likely not here to do it this way.
Placing the objects itself without parenting is simple but sims may not be able to use the placed items as routing may or may not file. Did you test this and can share some findings? To decorate things it should be fine.
It may be more easy to build things manually first in build mode and then use Python to fetch the item IDs and positions and store everything in a Python dict or JSON for later reference. I'd love to have some full cups on the bar and bottles and glasses even on empty tables for a waiter to remove them. It's always way too clean when one enters a lot.
|
|