Replies: 13 (Who?), Viewed: 475 times.
Field Researcher
Original Poster
#1 Old 12th May 2020 at 5:28 PM Last edited by HobbesED : 15th May 2020 at 4:55 AM.
Default Displaying a variable's value in a BHAV?
This is probably a real basic/stupid question, but how do I display a variable's value in a BHAV?

I can use a prim 0024 Dialog(TextNotification) instruction to display text, but how do I display a variable's value?

It's mainly for development and debugging purposes and won't be used in the final mod, but I need to see the value returned in the variable. Unfortunately, I can't look at the code which generates the possible values since it's a compiled Maxis Lua script. Would I use a different instruction depending if the variable contained text or numeric data? What Simantic instruction(s) would I use and what would the format(s) be?

Thanks for any help!

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Advertisement
Instructor
#2 Old 12th May 2020 at 5:57 PM
Quote:
Originally Posted by HobbesED
I can use a prim 0024 Dialog(TextNotification) instruction to display text, but how do I display a variable's value?


"Local 0 is $Local:0"
etc

See - http://www.modthesims.info/showthread.php?t=140309

Just call me William, definitely not Who-Ward
Field Researcher
Original Poster
#3 Old 12th May 2020 at 11:22 PM
Quote:
Originally Posted by whoward69


Perfect. I'll give that a try. Thank you.

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Field Researcher
Original Poster
#4 Old 15th May 2020 at 5:06 AM Last edited by HobbesED : 15th May 2020 at 3:32 PM.
The BHAV I want to mod does not have any STR# types showing in the Resource List. How can I add the STR# resource type to that BHAV in SimPE so that when I use the prim 0x0024 Dialog(Text Notification) instruction, the PJSE Instruction wizard will allow me to select the message I wish to display?

EDIT: I've managed to add an STR# type to the BHAV, but now when I try to select the message to display, I get the message "No strings found (private). How do I make the strings I have defined able to be selected?
Screenshots

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Forum Resident
#5 Old 15th May 2020 at 4:39 PM
I'm going out on a limb here and assuming you are still looking at including 2nd aspirations in sim's Attraction Score, if so you are probably working with a global op-code which can only access texts from the global text list. You need to change the String Scope value to 'Global'.
Global op-codes can only access global texts, semi-globals can access semi-global and global texts, private op-codes can access all three.

I was thinking about your idea of including 2nd aspirations in sim's Attraction Score and realized you will need to add three extra calculations because you will need to compare both sim's secondary aspiration with the other sim's primary as well as comparing both secondary aspirations with each other.

I tried some experimenting today giving secondary to primary a weight of 25 (0x0019) and secondary to secondary a weight of 20 (0x0014), the attached file overrides global 0x03DA (Sim - Fake Into Family (Dorm)) which is not used by the game at all but it could be used by a mod so you probably shouldn't use it, this is just intended to give you some ideas.
Download - please read all instructions before downloading any files!
File Type: zip Attraction+2ndAspiration.zip (1.2 KB, 1 downloads)
Field Researcher
Original Poster
#6 Old 15th May 2020 at 5:56 PM
Chris, you are correct. That's what I'm working on.

What do I alter to change the STR# file to be seen by BHAV 402? I made the group numbers the same which didn't help. Sorry for being so dense but the relations between the types still confuses me.

Slightly modifying your AskRomanticInterest mod, I was able to verify (and display) that the Primary Aspiration value is 35 so that the attraction score changes between two Sims' Primary aspirations (except for Grilled Cheese) is +35, 0, or -35. "Like" is +35; "dislike" is -35. I've charted all 49 possibilities (7x7) so I know which aspirations like, dislike or are neutral to which other aspirations.

BHAV 402 doesn't have any string lists in it, so I need to be able to view the attraction score as I add in my code to take into account secondary aspirations to ensure that my code is working as planned. That's where I am running into the problem. The string list I'm using to display the attraction score and aspiration isn't being found. How do I make the STR# a global text list?

I was planning on storing Sim A's primary and secondary aspirations and Sim B's primary and secondary aspirations as local variables in BHAV 402 so that I could do the comparisons and then adjust the attraction score accordingly.

Once I get the display issue worked out, then it's simply a matter of my converting the pseudocode I have written into Simantics in BHAV 402 and testing it. The checks I'm doing remove the "dislike" -35 penalty (if it existed) when a secondary of one matches the primary of the other. This would be done because if your secondary is the same as the other's primary, then you can't dislike their primary because you have the same aspiration as your secondary. Then also checking one's secondary vs the other's primary for "like" & "dislike" and checking the secondary to secondary for "like" and "dislike".

Right now I have high hopes for this.

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Forum Resident
#7 Old 16th May 2020 at 5:18 AM
You will also need to extract the global text list to add your texts to, that's the text called 'Dialog prim string set', group 0x7FD46CD0, instance 0x0000012D
Screenshots
Instructor
#8 Old 16th May 2020 at 7:40 AM
Quote:
Originally Posted by HobbesED
I was able to verify (and display) that the Primary Aspiration value is 35 so that the attraction score changes between two Sims' Primary aspirations (except for Grilled Cheese) is +35, 0, or -35. "Like" is +35; "dislike" is -35. I've charted all 49 possibilities (7x7) so I know which aspirations like, dislike or are neutral to which other aspirations.


This may be of interest - http://cyjon.net/node/86

Just call me William, definitely not Who-Ward
Field Researcher
Original Poster
#9 Old 16th May 2020 at 5:05 PM
Quote:
Originally Posted by whoward69
This may be of interest - http://cyjon.net/node/86

Thanks! Cyjon's Study of Chemistry is a great resource. I've studied it in depth over the years. Unfortunately where he said he braved the Lua script to come up with some of his assertions, I've been unable to get into that Lua script and verify his findings as the script is compiled and not in a readable form even in SimPE. I had a previous post here asking about how to read a Lua script and didn't get responses on how to do that. It seems that the TS2 Lua scripts are at a level that even after 15 years, very few people have managed to crack them, especially when they are compiled. I tried reaching out to Cyjon but haven't received a response. I've also gone to the Lua site, downloaded and tried different software to look at that attraction script but none of them presented a view that I found understandable.

So I can only go by what I'm observing in the game as the aspirations change even though it differs from what Cyjon posted.

Quote:
Originally Posted by Chris Hatch
You will also need to extract the global text list to add your texts to, that's the text called 'Dialog prim string set', group 0x7FD46CD0, instance 0x0000012D

I'm such a moron, Chris. I don't know how I actually missed seeing that. As soon as I clicked and changed that to Global, my Dialog messages became available. I should be able to view the values now. Whack me over the head... Duh! THANKS!!!

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Field Researcher
Original Poster
#10 Old 20th May 2020 at 4:28 AM
Quote:
Originally Posted by Chris Hatch
I'm going out on a limb here and assuming you are still looking at including 2nd aspirations in sim's Attraction Score, if so you are probably working with a global op-code which can only access texts from the global text list. You need to change the String Scope value to 'Global'.
Global op-codes can only access global texts, semi-globals can access semi-global and global texts, private op-codes can access all three.

I was thinking about your idea of including 2nd aspirations in sim's Attraction Score and realized you will need to add three extra calculations because you will need to compare both sim's secondary aspiration with the other sim's primary as well as comparing both secondary aspirations with each other.

I tried some experimenting today giving secondary to primary a weight of 25 (0x0019) and secondary to secondary a weight of 20 (0x0014), the attached file overrides global 0x03DA (Sim - Fake Into Family (Dorm)) which is not used by the game at all but it could be used by a mod so you probably shouldn't use it, this is just intended to give you some ideas.

I've gotten the mod coded now and have started testing it. The actual weights it'll have are in flux pending how my testing goes.

Is there a way to make my own unique BHAV (like the 0x03DA) and call it from an established BHAV or will I need to insert my code directly into an existing BHAV?

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Forum Resident
#11 Old 20th May 2020 at 1:36 PM
Yes, the example I gave you does exactly that. Since you are calling it from a global you can only use a global op-code.
There is a lot of global op-codes never used by the game that you could override (in A&N I have replaced most of them with useful ones). In SimPE to confirm one isn't used open Tools > PJSE > Simantics Resource Finder, select the Calls To OpCode option and set at least From: BHAV, set all three if you want to be really sure. Type in (or paste) the Instance of the op-code into the Op-Code box, all other settings are correct for global op-codes as default, choose the search button then go and make a cup of coffee because it can take quite a while.
Alternatively just use a higher instance value than has been used but that may conflict with a lot of other mods, for your own game it'd pay to run the Hack Conflict Detector after placing it into your download folder so at least it'll work conflict free for you.
Field Researcher
Original Poster
#12 Old 22nd May 2020 at 4:34 AM
I found an issue which required restructuring the code a bit. So I have to restart my testing from the beginning.
A couple of questions however...
1) How do I display a Sim's name in a "Text Notification" command? I have the nID as a Param but how do I get from that to $Name or $Fullname?

2) I'm using SimPE 0.73.44.37511 (QA) and in PJSE > Simantics Resource Finder, if I select the OBJF box, SimPE crashes right after I press the search button. If I select the TTAB box, I get multiple popup error boxes "Error trying to open the Freetime objects.package" and the Fun With Pets objects.package. (I'm running UC.) I can click "Ok" and it continues, though. Do I need a different version of SimPE for those to work? The search does work fine with only the BHAV box checked.

3) Chris - what unused BHAV number would be one that wouldn't overlap with one you've used in your mods?

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Forum Resident
#13 Old 22nd May 2020 at 1:47 PM
1) Easiest to assign another Local to the Param and use $NeighborLocal:X. You could set the current Object Id to the Param and use $Neighbor but that would only allow you to display the name of one sim.

2) The SimPE version doesn't matter, in Extra -> Preferences -> File Table deselect the Objects for Basegame and every EP/SP except your highest (M&G). SimPE correctly tells you they are unused unless game version = x but then uses them anyway if they are 'Ticked'.

3) 0x03DA (Sim - Fake Into Family (Dorm)) is still used by the game including A&N.
Field Researcher
Original Poster
#14 Old 24th May 2020 at 10:54 PM
Chris, I sent you a PM with a link to my BHAV beta-code in it. It seems to me to be working, but I'd like your feedback on it if you wouldn't mind.

Thanks!

All of my Conversions, Creations and Stories may be found here:
HobbesED's Conversions and Creations
Back to top