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!
1978 gallons of pancake batter
Original Poster
#1 Old 7th Nov 2010 at 11:32 PM
Default Tutorial: Sims 3 Pure Scripting Modding
The Tutorial

The tutorial is located in the wiki: Sims 3 Pure Scripting Modding

Questions?

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

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
6 users say thanks for this. (Who?)
Advertisement
Test Subject
#2 Old 8th Nov 2010 at 1:47 PM
Thanks! It works perfectly. I was just wondering how to write a mod without custom objects and then you posted this ^^

And this tutorial seems to hint at the precise reason why the game crashes with some mods that use only a custom namespace name, without nesting it in an existing EA namespace (this topic ). So if you use only your own namespace, without putting it inside, lets say, Sims3.Gameplay, and don't use a static instantiator variable and a xml file to instantiate the class, then clicking on that custom object in game in buy mode will cause a crash to desktop when the game tries to create the object, because the object wasn't initialized. Because the game didn't know it was there, since the namespace of that object was not within Sims3 namespaces! Is that a correct reasoning? And the reason why nesting your namespace within EA namespaces does fix that problem, without the need of a xml file, is because the game seems to instantiate all objects by default within the Sims3 namespace, and within all child namespaces, if the objects have static components, so also the object within your nested namespace - even without the xml file. Is that correct? I simply can't live without knowing, why exactly something crashes and why a fix works, like in that case.

Anyway, awesome, informative tutorial.

"The past tempts us, the present confuses us and the future frightens us.. and our lives slip away, moment by moment, lost in that vast, terrible in-between"
One horse disagreer of the Apocalypse
#3 Old 8th Nov 2010 at 2:24 PM
I'd still like to know why it was only after LN that custom namespaces became a problem though.

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
1978 gallons of pancake batter
Original Poster
#4 Old 8th Nov 2010 at 4:41 PM
Quote: Originally posted by gladosrev2
And this tutorial seems to hint at the precise reason why the game crashes with some mods that use only a custom namespace name, without nesting it in an existing EA namespace{...}
I don't think it does.

Quote:
then clicking on that custom object in game in buy mode will cause a crash to desktop when the game tries to create the object, because the object wasn't initialized.{...}
No, the initializing of the static fields of a class is something that gets enforced by the framework. Initializing an object, aka an instance of the class, is the job of the non-static constructor(s) and thus completely unrelated. Since script classes for object mods need to be derived from GameObject, there's actually a shitload of other differences BTW.

What is actually different for a buymode object that already existed in the town when you loaded the game and an object that the game tries to create when you click on the thumbnail in buymode? Fetching the mesh, finding the assembly, and instantiating an object aren't different. That much seems certain. The BuildBuyMode stuff is mind-meltingly massive and wide-spread. Last time I browsed that code, I couldn't even find the point where the actual object gets created.

In the thread you linked, twallan speculated that the game might use the script class as a lookup value for some store stuff. That might be the case. All we know for certain is that the exception gets thrown in the unmanaged code, and that the devs at that point probably most definitely didn't safe-guard their code against "unexpected results".

Quote:
I simply can't live without knowing, why exactly something crashes and why a fix works, like in that case.
Then it'd probably be best to get yourself an EAxian coder (kidnapping might help) and hook him up to a car battery until he spills the beans. The unmanaged code is terra incognita for modders. The chance that we ever learn what is causing the crashing issue is less than miniscule.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#5 Old 24th Dec 2010 at 5:12 PM
Hi,

First off thanks for this tutorial. I'm wondering if during the first step, when you extract the game libraries, you should extract them from only the base game .packages or from the latest EP .packages?

Much thanks.
1978 gallons of pancake batter
Original Poster
#6 Old 25th Dec 2010 at 12:19 PM
Quote: Originally posted by silent_j
I'm wondering if during the first step, when you extract the game libraries, you should extract them from only the base game .packages or from the latest EP .packages?
Doesn't matter. As long as base game and EPs are on the same related patch level (you can check the code version of the S3SA resources in S3PE - current version is 0.2.0.128), the libraries are the same.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#7 Old 18th Mar 2011 at 4:04 AM
Hi Buzzler,

I just installed C# 2010 but my Reflector couldn't detect it. How do I fix it?
1978 gallons of pancake batter
Original Poster
#8 Old 18th Mar 2011 at 8:58 AM
Quote: Originally posted by Vondure
I just installed C# 2010 but my Reflector couldn't detect it. How do I fix it?
I don't know. What do you need that for anyway?

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#9 Old 18th Mar 2011 at 3:19 PM
How do I set a project's framework version to .NET Framework 2.0?
I can't seem to find that option anywhere in the New Project window.

I thought having Reflector integrated with C# will solve that issue, but I can't seem to get that working either.
1978 gallons of pancake batter
Original Poster
#10 Old 18th Mar 2011 at 3:53 PM
Quote: Originally posted by Vondure
How do I set a project's framework version to .NET Framework 2.0?
I can't seem to find that option anywhere in the New Project window.
That's because it isn't there. Change it afterwards. Project->{your project's name} properties... and then you should see it.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#11 Old 19th Mar 2011 at 6:24 AM
Thank you.

I'm missing three .dll files, would it be alright to continue? My core libraries only contained three S3SA files each.
I don't have TestGameplay.dll, TestObject.dll and Automation.dll.
1978 gallons of pancake batter
Original Poster
#12 Old 19th Mar 2011 at 7:17 AM
Quote: Originally posted by Vondure
I'm missing three .dll files, would it be alright to continue? My core libraries only contained three S3SA files each.
I don't have TestGameplay.dll, TestObject.dll and Automation.dll.
It's safe to continue without them, you don't need these.

Where did you read about these three dlls anyway? I thought all tutorials were updated now...

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#13 Old 19th Mar 2011 at 11:39 AM
At the beginning of your tutorial, there is a link leading to another page regarding game-compatible VS projects. Step 4 of this tutorial mentioned these .dll files, along with a screenshot. I also Google'd them and ended up onto another page that again mentioned them.

I have another question; I have nothing to worry about this warning, right?
1978 gallons of pancake batter
Original Poster
#14 Old 19th Mar 2011 at 11:56 AM
Thanks for the heads up regarding Sims_3:Creating_a_game_compatible_Visual_Studio_projectwiki. I'll see about changing that.

Quote:
I have another question; I have nothing to worry about this warning, right?
Damn, I was kinda waiting for that one. It's a known bug in Visual Studio that the "Do not reference mscorlib" thing does nothing. In VS2008 it at least worked most of the times, but in VS2010 it doesn't seem to do anything at all anymore.

I don't know whether projects compiled against the .NET mscorlib will work in the game; you're welcome to try. The only other "solution" is to go back to Visual Studio 2008.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#15 Old 19th Mar 2011 at 12:30 PM Last edited by Vondure : 19th Mar 2011 at 12:51 PM.
Damn, it would be a bummer if I had to go back to VS 2008.

But I'm not yet done with the project, because it won't produce the
appropriate .dll file. Everytime I build the solution, I get these errors:

As you can tell, I'm practically new with all of these; I felt all along that
this is somehow not really my calling. But what the heck, it's worth a shot.

How do I fix it?
1978 gallons of pancake batter
Original Poster
#16 Old 19th Mar 2011 at 10:39 PM
Quote: Originally posted by Vondure
Everytime I build the solution, I get these errors:{...}
I just tried to reproduce these errors, and I think you simply wrote
Code:
assembly: Tunable
in your code.

Change it to
Code:
[assembly: Tunable]
and you should be good to go.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#17 Old 20th Mar 2011 at 6:10 AM Last edited by Vondure : 20th Mar 2011 at 6:25 AM.
I have it typed in correctly. I'm sorry, I should have known better and posted screenshots of my project instead of having you blindly guess the problem.

Anyway, I found out that the cause was actually line 4 of AssemblyInfo.cs. It turns out that I simply typed in "Sims3.SimIFace;" leaving out the word 'using' before it. I guess I've gotten confused in your tutorial because the word 'using' is in a different font than "Sims3.SimIFace;". So I only copy-pasted the latter. If that makes sense. I fixed it.


Now, I'm getting another error; I think it's referring to that class called 'object' down on page 18:

The magic page 4 holds. I broke the rule.
1978 gallons of pancake batter
Original Poster
#18 Old 20th Mar 2011 at 11:47 AM
Quote: Originally posted by Vondure
I guess I've gotten confused in your tutorial because the word 'using' is in a different font than "Sims3.SimIFace;".
Fixed.

Quote:
Now, I'm getting another error; I think it's referring to that class called 'object' down on page 18:{...}
That means that VisualStudio actually did derefence mscorlib, or at least uses the /nostdlib compiler option. Try to add the mscorlib from TS3 once more or, if that doesn't work, untick the "Do not reference mscorlib" thing again.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Forum Resident
#19 Old 21st Mar 2011 at 11:16 AM
I use vs2010 and got it to work by editing the csproj. You just need to change the path to mscorlib from the default
to wherever you put the sims3 version of mscorlib. Or, if you don't have the reference to mscorlib in the .csproj file,
just paste the below in the <ItemGroup> where all the other <Reference Include= lines are located and edit the
<HintPath> as needed.

<Reference Include="mscorlib">
<HintPath>..\..\..\..\s3mod projects\simcore\mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
Test Subject
#20 Old 21st Mar 2011 at 4:54 PM
Quote: Originally posted by Buzzler
That means that VisualStudio actually did derefence mscorlib, or at least uses the /nostdlib compiler option. Try to add the mscorlib from TS3 once more or, if that doesn't work, untick the "Do not reference mscorlib" thing again.

I unticked the, "Do not reference mscorlib" checkbox, built the project, and it worked. I thought to myself that the default mscorlib file couldn't possibly work for TS3, otherwise there wouldn't be any point as to why we're even using the TS3 version of mscorlib. But to my surprise, the mod did work in-game. Is this normal? Or are there going to be side effects? Why are we using the TS3 version when the default mscorlib works out just fine?

Quote: Originally posted by lenglel
I use vs2010 and got it to work by editing the csproj. You just need to change the path to mscorlib from the default
to wherever you put the sims3 version of mscorlib. Or, if you don't have the reference to mscorlib in the .csproj file,
just paste the below in the <ItemGroup> where all the other <Reference Include= lines are located and edit the
<HintPath> as needed.

<Reference Include="mscorlib">
<HintPath>..\..\..\..\s3mod projects\simcore\mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>

Even though I solved my problem, I'd still wanna know:

How do I change the reference path within the .csproj?
Where is this "<ItemGroup>" and all of those other codes?

Please forgive me for asking a lot of questions but I'm really new to VS and all of these C sharp talks, so I find it very difficult to keep up.
I just started learning as soon as I posted in this thread(3 days ago). Any new information would go a long way.

And before I forget, thank you guys for helping me with my first script mod.

The magic page 4 holds. I broke the rule.
1978 gallons of pancake batter
Original Poster
#21 Old 21st Mar 2011 at 8:02 PM
Quote: Originally posted by Vondure
Why are we using the TS3 version when the default mscorlib works out just fine?
The mscorlib from TS3 is not the .NET mscorlib that Visual Studio uses by default; it's an altered mscorlib from the MONO portable framework. MONO implements .NET 2.0, so a library compiled against the .NET mscorlib should work ... most of the times. I honestly don't know in which ways the MONO mscorlib might differ or what it might not implement or what the EAxian devs stripped from it (apart from direct file access).

So, yeah, it will probably work if you don't go crazy and if you ever do something the TS3 mscorlib doesn't support, the compiled library hopefully won't link and stall your game instead of causing subtle borkedness. I for one would prefer to get Visual Studio to reference the TS3 mscorlib or at least manually compile against it.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Forum Resident
#22 Old 22nd Mar 2011 at 11:01 AM
Vondure: Just use a text editor like notepad++ to open and edit the file with the .csproj
extension. It's in the first subfolder of your projects folder in the vs2010 projects directory.
You'd need to change the path to point to wherever you extracted the ts3 mscorlib.
Test Subject
#23 Old 22nd Mar 2011 at 12:02 PM
Quote: Originally posted by Buzzler
The mscorlib from TS3 is not the .NET mscorlib that Visual Studio uses by default; it's an altered mscorlib from the MONO portable framework. MONO implements .NET 2.0, so a library compiled against the .NET mscorlib should work ... most of the times. I honestly don't know in which ways the MONO mscorlib might differ or what it might not implement or what the EAxian devs stripped from it (apart from direct file access).

So, yeah, it will probably work if you don't go crazy and if you ever do something the TS3 mscorlib doesn't support, the compiled library hopefully won't link and stall your game instead of causing subtle borkedness. I for one would prefer to get Visual Studio to reference the TS3 mscorlib or at least manually compile against it.

I will try to do that. I sure hope it doesn't crash my game. So far it's working alright for this particular mod, but I'll keep that in mind.

Quote: Originally posted by lenglel
Vondure: Just use a text editor like notepad++ to open and edit the file with the .csproj
extension. It's in the first subfolder of your projects folder in the vs2010 projects directory.
You'd need to change the path to point to wherever you extracted the ts3 mscorlib.

Is this correct?

The magic page 4 holds. I broke the rule.
Forum Resident
#24 Old 24th Mar 2011 at 1:33 AM
It might be correct for your setup, but mine has a lot of stuff yours doesn't.
I've got my simcore stuff outside the vs2010 hierarchy, that's why all my
hintpaths start with "..\..\..\..\s3modprojects\simcore\

The PropertyGroup sections get set up from within vs2010 when you
select your project's properties. The first ItemGroup is the source files
and the second is the references from the using statements at the top
of the source file. That's where the reference to the sims 3 version of
mscorlib goes.

Here's what mine looks like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9306C19F-3AA2-40AE-B7AC-A88EA19330B5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LWE4</RootNamespace>
<AssemblyName>LWE4</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\..\..\..\s3mod projects\simcore\mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ScriptCore">
<HintPath>..\..\..\..\s3mod projects\simcore\ScriptCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SimIFace">
<HintPath>..\..\..\..\s3mod projects\simcore\SimIFace.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3GameplayObjects">
<HintPath>..\..\..\..\s3mod projects\simcore\Sims3GameplayObjects.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3GameplaySystems">
<HintPath>..\..\..\..\s3mod projects\simcore\Sims3GameplaySystems.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3Metadata">
<HintPath>..\..\..\..\s3mod projects\simcore\Sims3Metadata.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System">
<HintPath>..\..\..\..\s3mod projects\simcore\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<HintPath>..\..\..\..\s3mod projects\simcore\System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UI">
<HintPath>..\..\..\..\s3mod projects\simcore\UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Test Subject
#25 Old 14th Jun 2011 at 5:34 PM
Quote: Originally posted by Buzzler
Damn, I was kinda waiting for that one. It's a known bug in Visual Studio that the "Do not reference mscorlib" thing does nothing. In VS2008 it at least worked most of the times, but in VS2010 it doesn't seem to do anything at all anymore.


You can use Visual C# Express. You just have to manually edit the .csproj file to make it see the right one.

For me, I have extract the necessary dlls to My Documents\Visual Studio 2010\Sims3dll. After you have told it not to use mscorlib (not totally useless checkmark), you exit Visual C# 2010. Then (assuming for this your project is named MyScript) you open the My Documents\Visual Studio 2010\MyScript\MyScript\MyScript.csproj with something like Notepad or Notepad++.

You will find a section looking like this.


<ItemGroup>
<Reference Include="ScriptCore">
<HintPath>..\..\..\Sims3dll\ScriptCore.dll</HintPath>
</Reference>
<Reference Include="SimIFace">
<HintPath>..\..\..\Sims3dll\SimIFace.dll</HintPath>
</Reference>
<Reference Include="Sims3GameplayObjects">
<HintPath>..\..\..\Sims3dll\Sims3GameplayObjects.dll</HintPath>
</Reference>
<Reference Include="Sims3GameplaySystems">
<HintPath>..\..\..\Sims3dll\Sims3GameplaySystems.dll</HintPath>
</Reference>
<Reference Include="Sims3Metadata">
<HintPath>..\..\..\Sims3dll\Sims3Metadata.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="UI">
<HintPath>..\..\..\Sims3dll\UI.dll</HintPath>
</Reference>
</ItemGroup>

You need to change it to include a reference to mscorlib and change the reference for System, System.Xml, and UI. It should look similar to this:


<ItemGroup>
<Reference Include="Mscorlib">
<HintPath>..\..\..\Sims3dll\mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ScriptCore">
<HintPath>..\..\..\Sims3dll\ScriptCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SimIFace">
<HintPath>..\..\..\Sims3dll\SimIFace.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3GameplayObjects">
<HintPath>..\..\..\Sims3dll\Sims3GameplayObjects.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3GameplaySystems">
<HintPath>..\..\..\Sims3dll\Sims3GameplaySystems.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sims3Metadata">
<HintPath>..\..\..\Sims3dll\Sims3Metadata.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System">
<HintPath>..\..\..\Sims3dll\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<HintPath>..\..\..\Sims3dll\SystemXml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UI">
<HintPath>..\..\..\Sims3dll\UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

This should fix any problems with the default mscorlib and Visual C# 2010.

I realize that is what the post above was trying to say. I am just trying to make it obvious for everybody what to edit.
Page 1 of 2
Back to top