Detecting playables
#1 19-02-2017 
I'm working on a project that requires being able to differentiate between playable Sims and the non-playable Sims among community lot visitors. I feel like I know how, but I can't seem to remember, and nothing I see is sparking any memories. I've looked at some mods that do differentiate, but the things I find aren't working. Anyone have any ideas? Smile
gummilutt, proud to be a member of LeeFish since Jun 2013.

#2 19-02-2017 
Get 'person data - family number'. Negative family numbers belong to the fixed default maxis families that are associated with Social Groups, Dormies, (Down-)Townies, service sims, and the likes. Positive family numbers are the player-made families of playable sims!

Actually, there is also a global BHAV (0x000002FE - "Selectable: Is Sim Selectable?"), that tests if a sim is selectable or not. That routine does exactly the same as what I described above, by the way Big Grin

#3 19-02-2017 
That global is the one I tried, tried copying how you used it in your simulated sales but I couldn't get it to work. I'll study the global though, see if I can understand how it's checking and use that in my code. Thanks Smile

EDIT: I've tried everything I could think of, but no matter what setup I try for checking family number it either throws an error, or does nothing. If anyone happens to know how to set it up, I'd be most grateful.
(This post was last modified: 20-02-2017 01:28 AM by gummilutt.)

#4 20-02-2017 
Ok, so more help, then Big Grin

I suppose you're testing among all the sims that are presently at a lot, probably a comm lot, right? So you MUST have set up a "Set-to-Next Person" loop to find each individual. The variable that is updated by Set-to-Next, should be the one that you use as a parameter for the 0x02FE BHAV.

So, if you made something like:
---- 0x0002 Expression Local 0 := Set-to-Next person (It is mighty important that this reads "Person", and not "sim of any kind of family"...)
then the call would be:
---- 0x02FE Selectable: Is Sim Selectable? (Local 0)
and the outputs would be:
---- True goes to what the selectable sims are getting out of this.
---- False goes to what is done to the non-selectables.

It means that you do NOT convert Local 0 to some sim's person data or neighbor ID or whatever before feeding them to 0x02FE, because the BHAV does that for itself! Set-to-Next gives you an Object ID (*), which is exactly what the Selectable? test needs. So, just keep the Object ID the way it is supplied by Set-to-Next. If you need the Neighbor ID or Person Instance Number for anything AFTER the selectable test, then derive if *after* the test, but not before!

(*) As a reminder, the Object ID is an unpredictable number that only relates to the order in which objects are registered at the current lot - the first being the first object that was placed when the lot was built, and the last being the sim that just entered the lot. When Set-to-Next is set to look for Persons, therefor, it will get all sims that walk in.

I hope that this helps... Believe me, I know what you're going through, because I've been struggling with this myself at some point: there are multiple ways to address a sim, and it is not always clear which way is the right way for a specific BHAV. One BHAV wants the Object ID, another wants the Neighbor ID, and yet another needs the Person Instance Number. There is no indication as to what should be used at any point.

#5 20-02-2017 
Thank you, glad to hear I'm not the only one struggling with this stuff Dodgy Sometimes simantics can be so annoying!

It's not a guardian, it's an action bhav so I'm a bit hesitant about using set to next person. It's not supposed to go through all the sims on the lot, just check the Sim that is using the interaction. Does that make sense? Or will the game understand that the set to next person is just to see how the bhav would run if that Sim uses it?

I'm also not sure using the global checking for selectable Sim is helpful here, because that only checks if it's an active Sim. From what I understand from your simulated sales, it'll mark everyone as not selectable unless it's the Sim you are playing, and that means it's not differentiating between playables and townies among the background Sims. I want to differentiate between playables and non-playables for all Sims present on the lot, not just the Sim I'm playing. I'm guessing family number can be used, but not the way it's set up in the selectable-global. Or am I misunderstanding the global? Smile

#6 20-02-2017 
Oohhh, I'm sorry... I did make a mistake. But so do you.
I understand perfectly what you wanted to do, but first of all, I was missing information so I made some assumptions. And then I made an error in judgement.

First, do NOT make the mistake of thinking that Selectable and Active mean the same thing.
'Selectable' sims are all sims that *could* be active *if* you selected them. That means, all sims of the family that you are currently playing.
But there is always only *one* 'Active' sim: the one that you *have* actually selected; the one with the plumbob over its nugget!
It is important that you always remember this distinction, because misunderstandings come from using the wrong terms for these things.

But you are right that sims of other playable families are not 'selectable'. They are at best 'playable'.
And therefor, you are also right about the Global 0x02FE *not* being the right tool for the job.

Ok, so if the sim is trying to interact with something, the sim's ID (whichever form it takes) is supposed to be in Stack Object.
So the following should work:
---- 0x0002 Expression (Temp 0 := Stack Object ID's Family Number)
---- 0x0002 Expression (Temp 0 >= Literal 0x0000) (True is playable, False is Non-playable.)
And if Temp 0 is not a good choice, then use Temp 1, Temp 2 or a Local for all I care. As long as you don't abuse the Stack Object, it *should* be fine.

Also, do not make the mistake of thinking that you could do this in one Expression...
---- 0x0002 Expression (Stack Object ID's Family Number >= Literal 0x0000) is WRONG. THIS WILL NOT WORK! EVAH!!! Big Grin Wink

#7 20-02-2017 
Yes, you're right. As usual I wasn't clear enough in my first post, I'm sorry about that. And I agree, terminology is very important in these circumstances because it really matters, such fine distinctions that make the world of difference.

That's actually the exact setup I was trying, though I believe I used local and not temp. I'll try it again with temp and see if it works this time Smile Thanks, I really appreciate you taking the time to help me figure it out.

#8 21-02-2017 
I'm glad you agree on the importance of terminology here Smile

Using a Local should have been fine, unless you forgot to update the Local Var Count (up in the top right corner of Plugin View) for that specific BHAV. That count must be 1 higher than the highest Local that you actually use! If it isn't, the game will not understand and throw the kind of errors you've been having!

And don't you worry about my time. Time is limited for every person, not just for me. It's the way we USE that time, though, that makes it count. I prefer to use it helping people who like doing stuff that I like doing as well. I have fun spreading whatever I know about this game (which isn't actually that much, really Smile).


Sorry, that is a members only option