Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Field Researcher
Original Poster
#1 Old 11th Mar 2009 at 5:39 AM
Default BHAV's! (Object error) Aspiration & Mood Mod
http://www.modthesims2.com/showthre...74&goto=newpost

You may want to read through some of the link above before being able to help. It is an oldish thread that I brainstormed with Nader, Echo and Tunaisafish for a while but couldnt seem to figure out the problem. So, I was advised to post here for some more brainstorming and package repair is possible.

I have a package and Im working on BHAV's for the first time. I wanted the object to have 2 options; Raise Needs and Raise Aspiration. I figured out how to do it (mostly) but for some reson it wonk work in my game, but it works in Tunaisafish's game. We have the same games installed and I always test my objects without other CC/hacks in the game.

The Raise Needs option works for me except when I try and make it raise needs for all sims on the lot. The Raise Aspiration function gives me an error no matter what I do. I want it to raise the aspirations for all the sims on the lot, but it just wont. (at least for me that is)

I need help and cant figure this stuff out for the life of me!

Because the downloads being down, It wont let me upload the package, but I will wait and upload it when I can. For the time being, its only suggestions. lol

~ ҉ SimArchitect ҉ ~
Advertisement
Me? Sarcastic? Never.
staff: administrator
#2 Old 11th Mar 2009 at 6:00 AM
Simple question, since I was just experiencing this with a desk and slots. Did you rebuy the object before testing? My current desk had an added slot and it required me to rebuy the object on the lot for the new slot to take effect.
Field Researcher
Original Poster
#3 Old 11th Mar 2009 at 6:20 AM
Hmm, I cant remember if I rebought it or not??? Ill give it a try in just a minute.

~ ҉ SimArchitect ҉ ~
Field Researcher
Original Poster
#4 Old 11th Mar 2009 at 7:08 AM
OMFG! It worked. You have got to be kidding me!!! All that bullsht and it was as simple as that! HA HA!

Thanks!

Though, I dont know if you can help, but in the "Raise Aspiration" BHAV I have one that is labled "Set to Next". It is what makes all the sims on the lot raise aspiration at the same time. But, I want to make the raise needs to make all sims needs raise. I put the function at the end of the list, but I dont know what to link it to and if it should have a true/false target of false, true, or error?

If you understand what im saying. Its hard to explain in words???

~ ҉ SimArchitect ҉ ~
Me? Sarcastic? Never.
staff: administrator
#5 Old 11th Mar 2009 at 5:58 PM
Awesome!

Don't know much about BHAV's, other than that they seem to be called in order. It is like a chain, and each one points to another, and you can't point back to the same one or you might be in a forever loop. At the end you have a flag that says it's the end.

So you have two values for each line in the BHAV: true (points to next one) and false (FFFC). When you reach the last one: true(FFFD) and false(FFFC). Which is Return True and Error in the drop down boxes.
Field Researcher
Original Poster
#6 Old 12th Mar 2009 at 12:07 AM
Quote: Originally posted by HugeLunatic
So you have two values for each line in the BHAV: true (points to next one) and false (FFFC). When you reach the last one: true(FFFD) and false(FFFC). Which is Return True and Error in the drop down boxes.


See, I figured that, but I have tried the "set to next" at the end with a return true and error (in the drop downs), but it dosent make all the sims on the lot needs raise. When I dont have the set to next BHAV, the seleted sims needs raise just like its supposed to, but when I ad the "set to next" it gives an error.

Heres the aspiration screenshot:


Heres the needs screenshot:


I have created the "set to next" in the raise needs BHAV, but it dosent work in game. Can you see what would need to be changed?

~ ҉ SimArchitect ҉ ~
Field Researcher
#7 Old 12th Mar 2009 at 1:23 AM
For "Raise Aspiration," I'm pretty sure that you have to have the stack object called first. Assign the literal 0 then Set to Next.
That'll make your first "Next" object Literal 1.
Then run all your other functions after that, ending with the want recalc. Have that point back to Set to Next like you do currently.

"Raise Needs" isn't working for everyone because all the "My Motive-etc" only reference the clicking Sim.
Your "Set To Next" function isn't pointing to anything so even if it does "pick" a new Sim (and I'm not sure it does), it just returns true and does nothing after that.
You can try pointing the "True" value back to line 0 maybe.

That should give you something to check out until the real brains get here
Retired Duck
retired moderator
#8 Old 12th Mar 2009 at 1:29 AM
Okay, start by looking at the first one. Start at line zero, and follow the green lines.

The first time through, line 0x2 sets the stack object to 0. Then, 0x3 runs a "set to next (person)". That means, "starting at the number currently in Stack Object, keep counting up until you reach an ID which represents a person object. Once you find one, set the Stack Object ID to that and return green. If you don't find one, return red." Because we set the Stack Object to 0 first, it will start searching from 0. So far so good?

So it counts up until it finds the first object which is a person, then returns green. That means that it will run line 4, then line 5. These lines work on the sim who is in the "Stack Object". Then the green line goes back to the "Set to next". That means that it's going to do the same thing as the first time round, except this time it's not starting from 0, it's starting from the ID of sim it previously found. That means that it won't find that sim again, it'll find the next sim. It'll then run the code on that sim.

It'll keep going round and round in a loop until the "Set to Next" can't find any more sims. Then it'll return red. The red exits the function with a "true" response, which ends the interaction.

In your second code sample, you've got a few issues.

Firstly, you're not setting the stack object to 0 the first time round. That means that the Set To Next will start counting at the ID of the object, and miss any sims with IDs lower than that.

Secondly, your code is manipulating "Me", not "Stack Object". Me is always* the sim who initiated the interaction, so this code will only ever affect the initiating sim, even if the Set To Next is working perfectly.

Thirdly, you're not looping the set to next. It's happening at the end of your code, and only happening once.

---
*Note - there are exceptions, but they're really rare!
Me? Sarcastic? Never.
staff: administrator
#9 Old 12th Mar 2009 at 1:58 AM
Wow. Glad you came to answer that question Echo, since it is way more than I know!

So?
stack object = variable which is set to zero at the beginning
set to next = the variable counter to continue looping the program?
Field Researcher
Original Poster
#10 Old 12th Mar 2009 at 2:36 AM
Quote: Originally posted by Neder
For "Raise Aspiration," I'm pretty sure that you have to have the stack object called first. Assign the literal 0 then Set to Next.
That'll make your first "Next" object Literal 1.
Then run all your other functions after that, ending with the want recalc. Have that point back to Set to Next like you do currently.

"Raise Needs" isn't working for everyone because all the "My Motive-etc" only reference the clicking Sim.
Your "Set To Next" function isn't pointing to anything so even if it does "pick" a new Sim (and I'm not sure it does), it just returns true and does nothing after that.
You can try pointing the "True" value back to line 0 maybe.


Thanks Nader! I

have tried that and it hasnt worked for me either.

Quote: Originally posted by Echo
Okay, start by looking at the first one. Start at line zero, and follow the green lines.

The first time through, line 0x2 sets the stack object to 0. Then, 0x3 runs a "set to next (person)". That means, "starting at the number currently in Stack Object, keep counting up until you reach an ID which represents a person object. Once you find one, set the Stack Object ID to that and return green. If you don't find one, return red." Because we set the Stack Object to 0 first, it will start searching from 0. So far so good?

So it counts up until it finds the first object which is a person, then returns green. That means that it will run line 4, then line 5. These lines work on the sim who is in the "Stack Object". Then the green line goes back to the "Set to next". That means that it's going to do the same thing as the first time round, except this time it's not starting from 0, it's starting from the ID of sim it previously found. That means that it won't find that sim again, it'll find the next sim. It'll then run the code on that sim.

It'll keep going round and round in a loop until the "Set to Next" can't find any more sims. Then it'll return red. The red exits the function with a "true" response, which ends the interaction.


God that was confusing...but made sense. (kinda?)

The Raise Aspiration function works just fine now. It fills everyones aspirations on the lot and gives no errors.

I will keep this noted though for future reference. Thanks!

Quote: Originally posted by Echo
In your second code sample, you've got a few issues.

Firstly, you're not setting the stack object to 0 the first time round. That means that the Set To Next will start counting at the ID of the object, and miss any sims with IDs lower than that.

Secondly, your code is manipulating "Me", not "Stack Object". Me is always* the sim who initiated the interaction, so this code will only ever affect the initiating sim, even if the Set To Next is working perfectly.

Thirdly, you're not looping the set to next. It's happening at the end of your code, and only happening once.

---
*Note - there are exceptions, but they're really rare!


As for this one. In the screenshot, when I take the last function in the list out, the funtion (in game) works perfect; it just dosent fill all the sims needs on the lot. ONLY the selected sim. When I place the "Set to Next" (Stack Object ID, person), it gives an error and dosent work for any sim on the lot.

If I wanted to make it work for all sims on the lot, does it need to loop back to the begining of the list, or does it need more than just the "set to next" funtion to work?

If you want, copy my pictures and write all over them to show it instead of using words. (If possible?)

~ ҉ SimArchitect ҉ ~
Field Researcher
Original Poster
#11 Old 12th Mar 2009 at 2:43 AM
Should it look like this:
(Raise Needs BHAV only)



Or should the Expression (Stack Object ID := Literal 0x0000) be at the top with the "Set to Next's" true target be linked to (Stack Object ID := Literal 0x0000)?

~ ҉ SimArchitect ҉ ~
Retired Duck
retired moderator
#12 Old 12th Mar 2009 at 4:01 AM
Quote: Originally posted by HugeLunatic
stack object = variable which is set to zero at the beginning
set to next = the variable counter to continue looping the program?
Exactly, yes. With the side note that "Stack Object" is a special kind of variable which has to hold the ID of an object in-game, and which you can treat as an object in other parts of the BHAV.



SimArchitect - The long description I gave you wasn't there to help you make the "Raise Aspiration" function work, because it already does. I wrote it so you can use logic to figure out how to fix your "Raise Motives" function.

It explains how Raise Aspiration works. Now think this through:
- That function works by running lines 4 and 5 for each sim on the lot
- The lines which run for each sim are happening after the set to next
- At the end of the lines for each sim to run, the true target loops back to the Set To Next line.
That should give you a good idea of how to fix the structure of your second BHAV.

Now think through this:
- The lines which run for each sim are setting values on the "Stack Object", rather than "Me". Your function is currently operating on "Me" (aka "My").
That should give you an idea of how to change your current instructions to work on sims other than the initiator.

I know it seems mean and unnecessary that I won't just tell you what lines to fix, but the thing about learning to code BHAVs is that you really have to understand the logic behind how they work, or the only thing you'll ever be able to do is copy existing BHAVs which someone else has written. If you really don't care about how it works, and you just want to maximize everyone's needs on the lot then you're never going to code BHAVs again, then I'll save you the trouble and just send you a completed BHAV to import... But that way you'll never really understand how it works, or how to write something similar but different for another kind of object.
Field Researcher
Original Poster
#13 Old 12th Mar 2009 at 4:43 AM Last edited by SimArchitect : 12th Mar 2009 at 4:53 AM.
Quote: Originally posted by Echo
The long description I gave you wasn't there to help you make the "Raise Aspiration" function work, because it already does. I wrote it so you can use logic to figure out how to fix your "Raise Motives" function.

It explains how Raise Aspiration works. Now think this through:
- That function works by running lines 4 and 5 for each sim on the lot
- The lines which run for each sim are happening after the set to next
- At the end of the lines for each sim to run, the true target loops back to the Set To Next line.
That should give you a good idea of how to fix the structure of your second BHAV.

Now think through this:
- The lines which run for each sim are setting values on the "Stack Object", rather than "Me". Your function is currently operating on "Me" (aka "My").
That should give you an idea of how to change your current instructions to work on sims other than the initiator.


Ok, so the "set to next" needs to be first!...right?

Then it needs to run each motive and then hit the stack object ID Literal 0x0 and send the target back up to set to next.

Im just afraid that it needs something above "set to next" because it looks like a loop to me?

Also, I dont understand the "Stack Object" and "Me" part. Are you talking about each motive or the "set to next". I looked at the instruction wizard when you click on the little hammer and wrench button for the "set to next" function. Do I need to change the "Stack Object" dropdown or the "person" dropdown?

I hope that makes sense?

Heres a screenshot of what I have changed so far:



Quote: Originally posted by Echo
I know it seems mean and unnecessary that I won't just tell you what lines to fix, but the thing about learning to code BHAVs is that you really have to understand the logic behind how they work, or the only thing you'll ever be able to do is copy existing BHAVs which someone else has written. If you really don't care about how it works, and you just want to maximize everyone's needs on the lot then you're never going to code BHAVs again, then I'll save you the trouble and just send you a completed BHAV to import... But that way you'll never really understand how it works, or how to write something similar but different for another kind of object.


No, its not mean or unnecessary. I really do want to learn how to do it. I just get so confused at parts. As a mattter of fact, I will probably attempt the BHAV's again after I finish this task. Its hard and confusing for me, but I actually have fun and want to learn more about it. lol

~ ҉ SimArchitect ҉ ~
Retired Duck
retired moderator
#14 Old 12th Mar 2009 at 5:00 AM
Much closer!

- When the set to next returns red, you want the interaction to end, so make its red line (false target) point to "True".

- The last line is setting the stack object back to 0 every time through the loop. You don't want that, it would get stuck looping to the same sim forever. You want to set the Stack Object to 0 before you enter the loop (which you have done - line 0x0) but then you don't need to set it to 0 again.

- Regarding the Me/Stack Object thing, you might like to try reading this:
http://www.modthesims2.com/showthread.php?t=212101
for a proper explanation. Basically what I'm saying though is that all those lines with stuff like "My Motive Energy := 0x64" should be "Stack Object's Motive Energy := 0x64".
Field Researcher
Original Poster
#15 Old 12th Mar 2009 at 5:15 AM
Quote: Originally posted by Echo
Much closer!

- When the set to next returns red, you want the interaction to end, so make its red line (false target) point to "True".

- The last line is setting the stack object back to 0 every time through the loop. You don't want that, it would get stuck looping to the same sim forever. You want to set the Stack Object to 0 before you enter the loop (which you have done - line 0x0) but then you don't need to set it to 0 again.


I figured out how to make the motives "Stack Objects motive Energy"!

Ok, so I removed the last funtion in the list and made the motive fun target to the "set to next".

Do the first and second function both need to have a false taget of "return true"? It seems kinda wrong???

Current:

~ ҉ SimArchitect ҉ ~
Retired Duck
retired moderator
#16 Old 12th Mar 2009 at 5:19 AM
Quote: Originally posted by SimArchitect
I figured out how to make the motives "Stack Objects motive Energy"!
Well done! :D

Quote: Originally posted by SimArchitect
Do the first and second function both need to have a false taget of "return true"? It seems kinda wrong???
Technically the 0x0 line should have a false target of error, but it's basically impossible for that line to ever return red, so it won't actually matter.

Try it in game.
Field Researcher
Original Poster
#17 Old 12th Mar 2009 at 5:50 AM Last edited by SimArchitect : 12th Mar 2009 at 7:05 AM.
Quote: Originally posted by Echo
Try it in game.


YAY! It worked with no errors and no problems!

Now on to the next project!

I think I will do some more reasearch on BHAV's before I get started. lol

Actually during this process I wanted to change Treegs sim changer so it could make witches to. (I had the previous one) I changed it and worked with the BHAV's and it worked in game first try...then I found out he made a batter one. lol

THANKS SO MUCH ECHO!!! Also thanks to Tunaisafish, Nader, Inge, and Huge Lunatic for helping me.

PS: If 0x64 is 100, then what makes the score the lowest possible? Aspiration/Needs wise?? Or is it 0 makes it the lowest? But what about negatives?

~ ҉ SimArchitect ҉ ~
Retired Duck
retired moderator
#18 Old 12th Mar 2009 at 6:08 AM
Quote: Originally posted by SimArchitect
If 0x64 is 100, then what makes the score the lowest possible? Aspiration/Needs wise?? Or is it 0 makes it the lowest? But what about negatives?
0 is dead center. -100 (0xFF9C) is lowest.
Field Researcher
Original Poster
#19 Old 12th Mar 2009 at 6:36 AM
Thanks!

Now I can make the object lower scores too. Just for fun...lol

~ ҉ SimArchitect ҉ ~
Me? Sarcastic? Never.
staff: administrator
#20 Old 12th Mar 2009 at 6:45 AM
Back to top