Welcome to
Mod The Sims
Online: 2577
News:
Have an account? Sign in:
pass:
If you don't have an account, why not sign up now? It's free!
Other sites: SimsWiki
Reply  Replies: 29 (Who?), Viewed: 9292 times.
Search this Thread
Old 18th Feb 2011, 08:03 PM DefaultTutorial: Sims 3 Localized Coding #1
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


The Tutorial

The tutorial is located in the wiki: Tutorial:Sims_3_Localized_Codingwiki

Questions

If you have questions concerning the tutorial, this thread is the place to ask them.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
2 users say thanks for this.
[ Click here to view a longer list ]
Old 18th Feb 2011, 08:58 PM #2
cmomoney
Who wants to play video games?



Join Date: Dec 2008
Posts: 1,695
Thanks: 71932 in 85 Posts
25 Achievements


Another good one, Buzzler. Keep up the good work.

"Part of being a mesher is being persistent through your own confusedness" - HystericalParoxysm
Have you seen my Simple E Modern Bed @Leefish
| (• ◡•)| (❍ᴥ❍ʋ) [◕ ‿ ◕]
Old 25th Mar 2011, 12:00 AM #3
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


I'm new at modding and I'm getting errors about cannot change access modifiers when I copy the code given in the tutorial and try to build it to get the dll. I set up the Assembly file as shown in the Tutorial:Sims 3 Pure Scripting Modding .

This is my code in my SayHello class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.SimIFace;
using Sims3.UI;


namespace Enirei
{
class SayHello : ImmediateInteraction<Sim, Sim>
{
public static readonly InteractionDefinition Singleton = new Definition();

public override bool Run()
{
string message = Localization.LocalizeString("Enirei/LocalizedMod/SayHello:Message", new object[] { base.Target });
base.Actor.ShowTNSIfSelectable(message, StyledNotification.NotificationStyle.kSimTalking);
return true;
}

[DoesntRequireTuning]
private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, SayHello>
{
public override string GetInteractionName(Sim a, Sim target, InteractionObjectPair interaction)
{
return Localization.LocalizeString("Enirei/LocalizedMod/SayHello:InteractionName", new object[0]);
}
public override string[] GetPath(bool isFemale)
{
return new string[] { Localization.LocalizeString(isFemale, "Enirei/LocalizedMod/SayHello:Path", new object[0]) };
}
public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}

}
}

I changed TwoBTech to Enirei since that was the namespace I was using.

Any help or suggestions that could be given would be greatly appreciated. Thanks.
Any help that could be gi
Old 25th Mar 2011, 12:04 AM #4
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Enirei, change the access modfiers of the overridden methods from public to protected and it should compile.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 25th Mar 2011, 04:11 AM #5
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


Thanks
Old 25th Mar 2011, 07:02 PM #6
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


Another thing is happening that I'm not sure about. I make the stbl file and add it to the package as in the tutorial. I put the package in to test it but I don't seem to have the say hello interaction. I look at the preview for the stbl file and it shows this:
Unknown1: 0x0000
Unknown2: 0x0000
Unknown3: 0x00000000
Key: 0xEFCFE0322BC7EB08 = Value: 'Say Hello'
Key: 0x233597618807DF5A = Value: '{MA.Whiny}{FA.Grumpy} Interactions'
Key: 0x7E6CB1745A6AB764 = Value: 'Hello, {0.SimName}!'

Again, any help/suggestions would be greatly appreciated.
Old 25th Mar 2011, 07:22 PM #7
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


The FNV64 hash of "Enirei/LocalizedMod/SayHello:Message" is 0x3345B37043CBFBB2. I don't see that listed. When you change the string keys, e.g. from "TwoBTech/LocalizedMod/SayHello:Message" to "Enirei/LocalizedMod/SayHello:Message", you need to change that in the text file as well, not only in the code.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 25th Mar 2011, 08:14 PM #8
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


Oops. I had typed and retyped that part, when I re-pasted it, I forgot to change it again. Saved the package and noticed something when I looked at the STBL file. It says:
Error reading resource 220557DA:00000000:06F1866BA6BEEEC3
Front-end Distribution: 10-1104-1243
Library Distribution: 10-1104-1243

Source: mscorlib
Assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Exception has been thrown by the target of an invocation.
----
Stack trace:
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at s3pi.WrapperDealer.WrapperDealer.WrapperForType(String type, Int32 APIversion, Stream s)
at s3pi.WrapperDealer.WrapperDealer.GetResource(Int32 APIversion, IPackage pkg, IResourceIndexEntry rie, Boolean AlwaysDefault)
at S3PIDemoFE.MainForm.browserWidget1_SelectedResourceChanged(Object sender, ResourceChangedEventArgs e)
----

Source: mscorlib
Assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Unable to read beyond the end of the stream.
----
Stack trace:
at System.IO.__Error.EndOfFile()
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadUInt64()
at StblResource.StblResource.Parse(Stream s)
at StblResource.StblResource..ctor(Int32 APIversion, Stream s)
----
Any help/suggestions?
Thanks for being patient with me.
Old 25th Mar 2011, 08:30 PM #9
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Now that is interesting. I've seen that a couple times and reported it to Peter Jones, but since I was unable to re-enact it and nobody seemed to have these issues, I thought the cause was my computer. Seems like it's a general issue after all. You might want to report that over at Simlogical. Since the issue can't be provoked, Peter probably won't be able to do much about it unless he stumbles over it by chance. Still, is the right thing to tell him.

The solution is pretty simple, though. Just delete the resource and add a fresh one in its place.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 25th Mar 2011, 09:25 PM #10
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


The thing is that I've gotten this result after deleting and adding a fresh one multiple times... T.T I seem to have bad luck with modding.

Question: how come in your Clean House for everyone mod you don't have an stbl file, instead an itun and and xml?
Old 25th Mar 2011, 09:36 PM #11
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by Enirei
The thing is that I've gotten this result after deleting and adding a fresh one multiple times... T.T I seem to have bad luck with modding.
Whoa, seriously? Off you go to Simlogical to report that error and upload the exact files (package and stbl) to re-enact that error! You can also upload them here (package and source txt file) and I'll have a look if there's a workaround.

Quote:
Question: how come in your Clean House for everyone mod you don't have an stbl file, instead an itun and and xml?
I don't need string tables in that mod, because I'm using strings the game already has. The ITUN is the interactions's tuning; the XML is for instantiating the mod and a couple tunable values to configurate the mod without having to change the code.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 25th Mar 2011, 10:56 PM #12
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


Okay. I just created an account with Simlogical. Should I post it under sp3e downloads and support?

Here's a zip with my package, my text file, and my stbl file. Thanks.
Download - please read all instructions before downloading any files!
File Type: zip Enirei_SayHello.zip (3.5 KB, 5 downloads) - View custom content
Old 26th Mar 2011, 07:48 AM #13
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by Enirei
Okay. I just created an account with Simlogical. Should I post it under sp3e downloads and support?
Seems like the right place, yes. Make sure to post the error message from above as well.

Quote:
Here's a zip with my package, my text file, and my stbl file. Thanks.
Hmm, I can't re-enact that error as always. I delete the STBL resource, then create the new one (actually I imported the STBL) and it's there without error. What are you doing exactly?

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 26th Mar 2011, 05:14 PM #14
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


I create a new resource, set it as an STBL, the group 0x0 and the instance 0x06F1866BA6BEEEC3. Then I do "replace" with the STBL that I created.

Okay. I just tried it as importing the STBL and not doing the replace and it seemed to work just fine for building the package. Also, if I decide I want to do the replace function on the STBL I did the import on, it works fine... So it seems to not like me if I do a replace on an empty STBL resource. Weird.

I can't seem to find the interaction anywhere now when I load the game. Further testing in this area is needed.
Last edited by Enirei : 26th Mar 2011 at 06:10 PM.
Old 26th Mar 2011, 05:29 PM #15
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by Enirei
Perhaps there's a bug with the replace function?
That may very well be the case.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 26th Mar 2011, 06:24 PM #16
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


I posted it to Simlogical. My testing seems to show it does not like doing a Replace on an empty STBL file created by Add Resource. When I did the import and then wanted to replace that file later on, it worked fine. Though as of right now I can't find the new interaction within the pie menu. T.T Mod creating does not agree with me it seems.

Thanks for your patience.
Old 26th Mar 2011, 07:44 PM #17
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by Enirei
Though as of right now I can't find the new interaction within the pie menu.
I just looked at your code in Reflector. You only have the interaction, but it just sits there and doesn't get used. The point of the localized coding tutorial is not to get you started in script modding, but to get you started in writing localized code *after* you started script modding. Please refer to Tutorial:Sims_3_Object_Moddingwiki to see how an interaction gets added to an object.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 26th Mar 2011, 08:36 PM #18
Enirei
Field Researcher

Join Date: Dec 2009
Posts: 368
Thanks: 2592 in 12 Posts
9 Achievements

View My Journal


gack! I thought I was forgetting something. Thanks.
Old 9th Apr 2011, 10:38 PM #19
jtravers88
Lab Assistant

Join Date: Oct 2004
Posts: 115
Thanks: 17 in 1 Posts
4 Achievements


The tutorials for pure scripting are great.

What I can't find a clue on how to do is dictating what submenu in the pie menu that an interaction should go.

For instance, the Say Hello example defaults to the main menu when clicking a target sim. How would you specify that you want your interaction button to appear under Friendly, Mean, Funny, or Romantic?

I can't see anything in any xml or the core that gives a clue how to do this.

It's probably something simple...
Old 9th Apr 2011, 11:19 PM #20
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by jtravers88
How would you specify that you want your interaction button to appear under Friendly, Mean, Funny, or Romantic?
You can do that with the GetPath() method. If you want an interaction to show up under "Friendly" for example, you make GetPath() return new string[]{"Friendly"}; Localized of course, since this is the localized coding Q&A thread you're in.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 9th Apr 2011, 11:38 PM #21
jtravers88
Lab Assistant

Join Date: Oct 2004
Posts: 115
Thanks: 17 in 1 Posts
4 Achievements


Quote:
Originally Posted by Buzzler
You can do that with the GetPath() method. If you want an interaction to show up under "Friendly" for example, you make GetPath() return new string[]{"Friendly"}; Localized of course, since this is the localized coding Q&A thread you're in.


I knew GetPath probably had something to do with it. But I couldn't find an example of "Friendly" or "Romantic" anywhere in this fnc declaration of any definition.

Thanks I'll try that out.
Last edited by jtravers88 : 9th Apr 2011 at 11:54 PM.
Old 9th Apr 2011, 11:52 PM #22
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Quote:
Originally Posted by jtravers88
I knew GetPath probably had something to do with it. But I couldn't find an example of "Friendly" or "Romantic" anywhere in this part of any definition.
You will hardly find any hardcoded strings in the game code anyway. The Friendly/Mean/etc. paths belong to the social interactions. These are parsed and built from an XML resource and use a single blueprint interaction. You will not find a Chat interaction in the code for example.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 10th Apr 2011, 02:08 AM #23
jtravers88
Lab Assistant

Join Date: Oct 2004
Posts: 115
Thanks: 17 in 1 Posts
4 Achievements


Quote:
Originally Posted by Buzzler
You will hardly find any hardcoded strings in the game code anyway. The Friendly/Mean/etc. paths belong to the social interactions. These are parsed and built from an XML resource and use a single blueprint interaction. You will not find a Chat interaction in the code for example.


Friendly and Friendly... don't work.

It adds a new selection to the top level of the pie menu, even if identical to the Friendly that already exists.

Twallan puts two interactions under the Friendly... in his woohooer mod. Gauge Attraction and Check Attraction. So far I haven't tracked down what causes it.
Old 10th Apr 2011, 02:33 PM #24
Buzzler
Original Poster

1978 gallons of pancake batter



Join Date: May 2006
Posts: 2,211
Thanks: 28085 in 74 Posts
22 Achievements

View My Journal


Yeah, I ran into that a couple times myself.

Try
Code:
new string[]{ CommodityData.Get(str).GetChangeToneText() }

str can be "Friendly", "Insulting", "Funny" or "Amorous" for your purpose.

("Friendly" + Localization.Ellipsis) might work as well, but it would be better to use localized code from the start.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 7th Sep 2011, 10:34 AM #25
smochina4000
Test Subject

Join Date: Jan 2006
Posts: 32


How can I make a mod like "Driving cars cost money" ,"cell phones cost money"? It is possible? Thank you!
Reply


Section jump:


Powered by MariaDB Some icons by http://dryicons.com.