Quick Reply
Search this Thread
Lab Assistant
Original Poster
#1 Old 20th May 2010 at 12:10 AM Last edited by PigiePower : 23rd May 2010 at 12:41 AM.
Default Piggy Bank? [Sloved]
Hellos, i currently have a object that a family member can deposit some money into. The problem is that if you switch households the savings in the object is transferd to the next household. is there anyway i could make the savings per-household?

Smile tomorow will be worse.
1978 gallons of pancake batter
#2 Old 20th May 2010 at 6:58 AM
@PigiePower: The object should already do that for you. You probably made the savings static, so all objects of that kind share the savings. Delete the static modifier and you should be good to go. If that's not the case, show your code.

And if you didn't thinkt of it, you should override the OnDispose() callback function, so the savings in the piggy bank get added to the household it belongs to when it gets destroyed/sold. Maybe write the test function of the refund interaction so that only sims belonging to the same household as the piggy bank pass.

BTW: Does it behave like a real piggy bank? So that the actual savings are a mystery until you destroy it?
Lab Assistant
Original Poster
#3 Old 20th May 2010 at 9:26 PM Last edited by PigiePower : 20th May 2010 at 11:07 PM. Reason: Upadate
Yes, i have a static modifier i'l remove it now and get back. Thank you for mentioning the OnDispose()! That would be bad loseing all your sims savings when you sell it. xD The money in the piggybank is a mystery until the user instucts the sim to take the money out.

EDIT:
so i tried adding the onDispose, and removed the "static". Now the Compiler gives me these errors

Smile tomorow will be worse.
1978 gallons of pancake batter
#4 Old 21st May 2010 at 4:54 AM
Quote: Originally posted by PigiePower
The money in the piggybank is a mystery until the user instucts the sim to take the money out.

Piggy banks with a hole on the bottom to take the money out without the need to crush the piggy bank with a hammer are for wussies!

Quote:
Now the Compiler gives me these errors

I can't really make sense of this without knowing your code. Seems like modOne.Main is static, too. It didn't occur to me that such a thing was even possible. I can't think of a reason to make a whole class static, though. Or is modOne a variable?
Lab Assistant
Original Poster
#5 Old 21st May 2010 at 4:47 PM
oops i forgot the code here it is, mind that i'm very new to C#and the first class is based on Kolipoki's tut.

Smile tomorow will be worse.
1978 gallons of pancake batter
#6 Old 21st May 2010 at 8:20 PM
Ok, instead of

Code:
moneySaved += 10;
write
Code:
Target.moneySaved += 10;
Interaction is a class, too, and the objects instanced from this class can exist independent from the Main class' objects. So inside the Interaction class there's no way to know which object's moneySaved field is meant unless you explicitely specify it.


Same here in the Dispose() method (I never can remember which one is with the "On" and which one is without...):
Code:
base.Actor.Household.FamilyFunds += moneySaved;
There's no Actor at this point, so this won't compile either. Use
Code:
base.GetOwnerLot().Household.FamilyFunds += moneySaved;

BTW:
Code:
base.Actor.ShowTNSIfSelectable("The current balacne is:" + moneySaved.ToString(), StyledNotification.NotificationStyle.kMessage, ObjectGuid.InvalidObjectGuid, base.Actor.ObjectId);
Are you possibly using an outdated code base? The kMessage NotificationStyle was dropped with V1.6.6 IIRC.
Lab Assistant
Original Poster
#7 Old 23rd May 2010 at 12:41 AM
Thank you! Thank you! Thank you! The Piggy bank now works thanks to you, i made the changes and updated my game and now it works great ^^

Smile tomorow will be worse.
1978 gallons of pancake batter
#8 Old 23rd May 2010 at 10:48 AM
Good to hear it worked out. I think it's really a nice idea. Deserves to be fleshed out. Like when grandma comes to visit, she automatically puts 10ยง in the piggy bank. But something like that is at least an intermediate project.

Despite the issue being sloved you're still going to slove the typos as well, right? I mean "balacne" sounds like a really serious skin disease.
Back to top