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
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#1 Old 10th Nov 2010 at 5:19 PM
Default Tunable Menu
I want to be able to add/change the menu options for my object from a list in a XML. How would I do this? I looked at the way the Stereo does it, but that is way more complex than what I need, and I couldn't simplify it enough to work for me.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Advertisement
1978 gallons of pancake batter
#2 Old 10th Nov 2010 at 7:19 PM
Quote: Originally posted by cmomoney
I want to be able to add/change the menu options for my object from a list in a XML. How would I do this?
The pure scripting tutorial covers how to make your script tunable, add tunable variables to it and how the XML resource needs to be added. You can simply add more tunable variables to the code and script. The only difference to the tutorial code is that you'll actually use the variables, e.g. in the OnStartup() method or the InteractionDefinitions' Test() methods.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#3 Old 10th Nov 2010 at 9:52 PM
I understand how to make a script tunable and such. My problem is how to make a list in the xml, and how to use that list as strings for my menu choices.

Great tutorial, btw.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Top Secret Researcher
#4 Old 10th Nov 2010 at 10:42 PM
EA formatted XML Tables are pretty simple to implement.

You create a unique named XML file, and then use the XmlDbData.ReadData() function to retrieve the information.

XmlDbData data = XmlDbData.ReadData("MyUniquelyNameXMLFile");

Retrieve the XmlDbTable you are interested in (there could be multiple in the file. ie: The "Careers" file has a table for each individual career).

if (!data.Tables.TryGetValue("MyTable", out table)) return false;

From there, you run through each row in the table:

foreach(XmlDbRow row in table.Rows)
{
...
}

Finally, read the field you are looking for into a structure for later use.

string myfield = row.GetString("MyField", "");

sMyFields.Add(myfield);

When you want to use those values in your menu interaction, read the values from sMyFields and go from there.

----

Various examples of XML Table usage can be found in the Core, search for functions that start with the word "Parse" (ie: Career::ParseCareerData)

Cheers.

NRaas Industries: Sims 3 Mods for the Discerning Player, hosted by The Wikispaces.
1978 gallons of pancake batter
#5 Old 10th Nov 2010 at 11:03 PM
Quote: Originally posted by cmomoney
I understand how to make a script tunable and such. My problem is how to make a list in the xml, and how to use that list as strings for my menu choices.
Oh, I see. I didn't get it before. Is that for your pose box project? If so, I'd recommend to use an ObjectPickerDialog to present the possible choices.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#6 Old 11th Nov 2010 at 9:24 PM
twallan: Thanks. That's actually how I had been trying to do it, but I couldn't get it to work. And I still can't get it to work, even after you've explained it. I think I'm losing it at the "sMyFields.Add(myfield);" part. Either that or I'm not reading the values right. Can you explain that a little further? The EA examples use a Dictionary to store a bunch of stuff, which is confusing me because I only need one or two lists of strings.

Buzzler: That sounds like a good idea(and yes, it's for the pose box), but I can't even get the regular menu to work. I wouldn't know where to start with that.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Top Secret Researcher
#7 Old 11th Nov 2010 at 10:23 PM
Quote: Originally posted by cmomoney
I think I'm losing it at the "sMyFields.Add(myfield);" part. Either that or I'm not reading the values right. Can you explain that a little further?


The simplest method is to define sMyFields as follows:

public static List<string> sMyFields = new List<string>();

Place that line in one of your classes.


NRaas Industries: Sims 3 Mods for the Discerning Player, hosted by The Wikispaces.
Inventor
#8 Old 11th Nov 2010 at 10:47 PM
If you want a simple string list, you could add a tunable (or two) like this example from S3_0333406C_00000000_4D02F4BA2106FDD1_VenueAmbienceManager_0x4d02f4ba2106fdd1%%+_XML.xml:
Code:
    <kCocktailLoungeAmbienceSoundStrings value="bar_amb_lounge_lo, bar_amb_lounge_med, bar_amb_lounge_high">
      <!--Ambience sounds for Cocktail Lounge. From left to right is {low, medium, high} population ambiences.-->
    </kCocktailLoungeAmbienceSoundStrings>


This should then make the strings "bar_amb_lounge_lo", "bar_amb_lounge_med" and "bar_amb_lounge_high" available in the variable kCocktailLoungeAmbienceSoundStrings. In the class it looks like this:

Code:
[TunableComment("Ambience sounds for Cocktail Lounge. From left to right is {low, medium, high} population ambiences."), Tunable]
public static string[] kCocktailLoungeAmbienceSoundStrings;


Once you have the strings, you could add your interactions based on whether or not something is in the list.

If you want to use a single interaction function to handle similar interactions that are only different depending on one or two variables, take a look at:
Sims3.Gameplay.Abstracts.Door+DEBUG_OpenClose

I found it quite helpful as an example to create interactions that take arguments and can handle them.
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#9 Old 15th Nov 2010 at 3:05 PM
Thanks everybody. I still was not able to get the XMLTable to work, I was able to get the menu to work using velocitygrass's suggestion(although XMLTables seem like the more efficient way).

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
1978 gallons of pancake batter
#10 Old 15th Nov 2010 at 5:56 PM
Quote: Originally posted by cmomoney
Thanks everybody. I still was not able to get the XMLTable to work, I was able to get the menu to work using velocitygrass's suggestion(although XMLTables seem like the more efficient way).
Show your code, I say.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#11 Old 15th Nov 2010 at 10:05 PM
The 'not working' or the 'working' one? Because I don't have the 'not working' one, I would have to try then FAIL again, lol.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
1978 gallons of pancake batter
#12 Old 16th Nov 2010 at 3:09 PM
Quote: Originally posted by cmomoney
The 'not working' or the 'working' one? Because I don't have the 'not working' one, I would have to try then FAIL again, lol.
So you don't want to use the XMLTable stuff anymore?

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#13 Old 16th Nov 2010 at 5:10 PM
Oh yeah, I would much rather use the XMLTable and the ObjectPickerDialog. I just don't have the broken code anymore, so to post it I'll have to write it wrong again. But I will if I have to(to get it working the way I want).

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
1978 gallons of pancake batter
#14 Old 16th Nov 2010 at 7:59 PM
Quote: Originally posted by cmomoney
Oh yeah, I would much rather use the XMLTable and the ObjectPickerDialog.
The XML format you'd like to use, would be a good start. And you probably use some sort of generic interaction to put your data to use. That might be of interest, too.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
˙uʍop ǝpᴉsdn ǝɹ,noʎ 'oN
Original Poster
#15 Old 30th Nov 2010 at 12:06 AM
The XML format I would like to use is this:
Code:
<CmoPoseBox>
<Pose>
  <AnimationName></AnimationName>
  <ClipName></ClipName>
  <PathName></PathName>
</Pose>
<Pose>
  <AnimationName>animName</AnimationName>
  <ClipName>a_clipName_x</ClipName>
  <PathName>pathName</PathName>
</Pose>
</CmoPoseBox>


For testing, I was just using a ShowTNS message to see if it worked.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Back to top