View Full Version : Placeable Object ?
Kitabalibar
2nd Mar 2012, 11:37 AM
Hello everyone,
As some might have noticed, I am working on a Yoga Rug right now, and I would like to make it portable (ie you can put it in your sims' inventory, and put it out whenever you want).
Therefore I looked for the feature, thinking of the World Adventure Tent, I found that the IPlaceableObject class would give me this possibility. In fact, I can now place my rug in my inventory but i cannot place it back in the game once it is in the inventory: the action "place" shows up but do not work.
My guess would be that there might be a specific attribute in the package file that is required? But it seems quite weird as it is the same process as placing the rug in building mode... and that works fine.
So I am a bit lost here, after reading some EA code about placeable objects I still can't figure out what I can do....
Shimrod101
2nd Mar 2012, 02:50 PM
Presumably you can alter the OBJD on your object and make it portable, in the same fashion as the Portable Easel mod made by anak ponti.
cmomoney
2nd Mar 2012, 03:02 PM
Buzzler helped me with this a while ago:
To enable the object to go in inventories, it needs an ItemComponent. Simply call
Code:
base.AddComponent<ItemComponent>(ItemComponent.SimInventoryItem);
in the OnStartup() method. You may need to override HandToolAllowUserPickupOnCommunityLot() and some other HandToolAllow... methods (and make them return true) as well. The regular interactions don't show up when an object is in an inventory btw. That's what AddInventoryInteraction() is for.
Kitabalibar
3rd Mar 2012, 02:44 AM
Thanks for the suggestion Shimrod, but for some reason when I open the portable easel, it does not shows any script in my s3pe, which seems quite weird to me...
For the initialization, I had already done that, by following the "tent" object layout.
I'll try with a brand new object, just inheriting from the tent object, to see if the fact that my rug inherits from the Workout Bench is the problem.
here's my OnStartup function, maybe I am doing something wrong there...
public override void OnStartup()
{
base.AddInteraction(YogaBasic.Singleton);
base.AddInteraction(YogaAdvanced.Singleton);
base.AddInteraction(YogaIntermediate.Singleton);
base.AddComponent<ItemComponent>(new object[] { ItemComponent.SimInventoryItem });
base.AddFlags(GameObject.FlagField.DoesNotStack);
base.AddInteraction(PutInInventory.Singleton);
base.AddInteraction(IPlaceableObject_Place.Singleton);
base.AddInventoryInteraction(IPlaceableObject_Place.Singleton);
PlaceableObjectUtil.OnStartup(this);
}
Shimrod101
3rd Mar 2012, 06:50 AM
Thanks for the suggestion Shimrod, but for some reason when I open the portable easel, it does not shows any script in my s3pe, which seems quite weird to me...
There isn't any script in the mod, it's an override mod on the OBJD alone, so the default scripting on the easel is used. When viewing this OBJD in s3pe one can see at the bottom the TopicRating, where +Portable is added, also the LiveDraggingEnabled flag is set. It appears to me that these are the only alterations to EA's OBJD.
Anyway, OBJD's can be altered simply by hitting the Grid button in s3pe.
Buzzler
3rd Mar 2012, 06:21 PM
Kitabalibar, Tents, i.e. objects that implement the IPlacableObject interface, are special. They change their geometry state when they are picked up or placed using the related interaction.
Normal objects that go into inventories don't do that. They may have a pick up interaction, but to place them you just drag them out of the inventory and drop them in the world. Did you try that?
Thanks for the suggestion Shimrod, but for some reason when I open the portable easel, it does not shows any script in my s3pe, which seems quite weird to me...Scriptwise, the easel can already be put into inventories. Seems like it was supposed to be portable from the start. :)
Kitabalibar
5th Mar 2012, 08:27 AM
Do you suggest trying with the ICarriable instead?
For now, I implemented very standard function for the IPlaceableObject, similar to the cane for instance (generation)
public float CarryRouteToObjectRadius
{
get
{
return 0.7f;
}
}
public bool CanBePlacedOnOtherResidentialLots
{
get
{
return true;
}
}
public bool CanBePutInInventory
{
get
{
return true;
}
}
public bool CanBeStowedInWorld
{
get
{
return true;
}
}
public override bool HandToolAllowIntersection(IGameObject objectToIntersect, Matrix44 testMatrix, bool bThisObjectShifted)
{
return true;
}
public override bool HandToolAllowUserPickup()
{
return true;
}
public bool RouteToObject(Sim actor)
{
if (!actor.RouteToObjectRadius(this, 0.1f))
{
return false;
}
return true;
}
public bool Placed
{
get
{
return this.mPlaced;
}
set
{
this.mPlaced = value;
}
}
public bool BeingPlaced
{
get
{
return this.mBeingPlaced;
}
set
{
this.mBeingPlaced = value;
}
}
public void PostPlacedBehavior(Sim actor)
{
}
Buzzler
5th Mar 2012, 11:35 AM
ICarryable won't help that much, I think. That interface is for smaller objects like mugs and glasses. I'd say just enable the object to be dragged out of the inventory by the player. You probably need to override a couple of the HandToolAllow... methods for that.
birdyfly
5th Mar 2012, 04:04 PM
This thread might help you out as well: http://www.modthesims.info/showthread.php?t=457268&highlight=live
lorenrose1013 found out how to do it successfully. :)
Kitabalibar
6th Mar 2012, 02:01 AM
Thanks for the info buzzler and the link birdyfly.
I changed the objd to put the flag "livadraggingenabled" to true, and now it works. My problem is that now the "pump iron" interaction shows up, as I inherit from the "workout bench" How could I get rid of it?
Buzzler
6th Mar 2012, 08:28 AM
My problem is that now the "pump iron" interaction shows up, as I inherit from the "workout bench" How could I get rid of it?Do you need any of the interactions from the workout bench? If not, just remove the base.OnStartup(); call from your object's OnStartup() method.
Why derive your object from WorkoutBench in the first place?
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.