Welcome to
Mod The Sims
Online: 2852
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: 47 (Who?), Viewed: 7567 times.
Search this Thread
Old 25th Apr 2012, 11:11 AM #26
Buzzler
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 dim4sim
I have all of the libraries unprotected, but for some unknown reason, I can't seem to get past the following error{...}
Time for the "fuel in the tank?" question.

It seems like Visual Studio still compiles against the original libraries. The altered libraries are located in the exact directory where the VS references point to, yes?

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 25th Apr 2012, 02:58 PM #27
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


All the libraries that are being referenced, should be the unprotected ones.
I may have reverted some common libraries like System and System.Xml. I am also using the standard mscorlib.

I will try to unlink the refs and link them again. I somehow doubt that it will help though.


Thanks.
Old 25th Apr 2012, 05:39 PM #28
Consort
Field Researcher

Join Date: Oct 2005
Posts: 340
Thanks: 3610 in 88 Posts
10 Achievements


Quote:
Originally Posted by dim4sim
and it doesn't like the [assembly: Tuning] line in AssemblyInfo.cs


put
using Sims3.SimIFace;
in assemblyinfo.cs
Old 25th Apr 2012, 06:24 PM #29
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


That should already be there. I will double check when I get home.

Also, not being a C# developer by profession, I am trying to understand why using Sims3.SimIFace is put into AssemblyInfo.cs but nothing else. What libraries belong in there, and what is the difference?


Thanks.
Old 26th Apr 2012, 11:29 AM #30
misukisu
Lab Assistant

Join Date: Aug 2005
Posts: 144
Thanks: 866 in 10 Posts
5 Achievements


The [assembly: Tuning] you added to your AssemblyInfo can be found in Sims3.SimIFace namespace. If you had not modified AssemblyInfo, then you would not have needed to add the using reference either.

The relation is similar than with the classes that you use in your code. Whenever you use a class, there must be a "using" reference to used namespace/class.
Old 26th Apr 2012, 03:16 PM #31
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Ah. That makes sense. In my VS2010 project, the assembly:Tuning actually throws errors. It still recognizes it inside of the class if I remove that line though.


*Edit: I was able to compile, although uncertain of actual success. I didn't get any of my alerts to show up, but I also noticed that my lib was not registering in ErrorTrap's list
Code:
Loaded Assemblies:
 NRaasErrorTrap: Version 51
 NRaasGoHere: Version 13
 NRaasMasterController: Version 82
 NRaasMasterControllerCheats: Version 79
 NRaasMasterControllerExpandedTattoo: Version 75
 NRaasMasterControllerIntegration: Version 79
 NRaasMasterControllerProgression: Version 78
 NRaasNoCD
 NRaasOverwatch: Version 53
 NRaasRegister: Version 55
 NRaasRelationshipPanel: Version 11
 NRaasSaver: Version 17
 NRaasSecondImage: Version 3
 NRaasStoryProgression: Version 216
 NRaasTraveler: Version 33
 ScriptCore
 SimIFace
 Sims3GameplayObjects
 Sims3GameplaySystems
 Sims3Metadata
 Sims3StoreObjects
 SimsMxSetCommunityLotBookType
 System
 System.Xml
 UI
 mscorlib

Am I missing something in terms of packaging? I also tried adding in an _XML file with a kInstantiator, and referenced it in my code. Is there anything else that I need?


Thanks.
Last edited by dim4sim : 27th Apr 2012 at 06:11 AM.
Old 27th Apr 2012, 05:29 PM #32
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Any insight?
Old 27th Apr 2012, 10:58 PM #33
Consort
Field Researcher

Join Date: Oct 2005
Posts: 340
Thanks: 3610 in 88 Posts
10 Achievements


The kInstatiator XML needs a fnv-hashed namespace.class instance set in the .package, referencing your dll. Re-read the pure scripting mod tutorial on that.

Is your tuning working now? Without tuning your dll is not loaded
Old 29th Apr 2012, 06:05 PM #34
Buzzler
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 Consort
Without tuning your dll is not loaded
It should still be loaded actually. It won't do anything without tuning, though.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 30th Apr 2012, 07:33 AM #35
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


I am 90% sure that I am setting everything up correctly, but I can't seem to get even the simplest piece of code from firing off in the game. Here's my test case:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay.Actors;

namespace Dima
{
    public class Test
    {
        [Tunable]
        protected static bool kInstantiator = false;

        static Test()
        {
            World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);

        }

        private static void OnWorldLoadFinished(object sender, EventArgs e)
        {
            try
            {
                AcceptCancelDialog.Show("Say hello to my little world!");
            }
            catch (Exception exception)
            {
                ((IScriptErrorWindow)AppDomain.CurrentDomain.GetData("ScriptErrorWindow")).DisplayScriptError(null, exception);
            }

            
        }
    }
}

Tuning hashed to "Dima.Test".

If you see anything missing here, please let me know. Also, if there is a different/better alerting method that I can use, please let me know as well. I was trying to go through twallan's code to find out how to make the event tooltip, but I got a bit lost. I'll keep looking through it though. I will most likely need it eventually.


As for the inability to bind event before: I realized why it was coming back undefined--I was referencing an unprotected version of Sim3.SimIFace, which apparently breaks thing.
Another thing that I realized: the Unprotect script compiles for .NET 4.0, not 2.0. I don't know if this has much of an effect on things, but I changed it to recompile using 2.0.


Thanks for all the help guys.
Old 30th Apr 2012, 06:36 PM #36
Buzzler
1978 gallons of pancake batter



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

View My Journal


Hmm, the using System.Linq; part confuzzles me. LINQ is a .NET 3.0 feature (or 3.5?), so that should give you a compile error if you actually set your project to .NET 2.0.

Please attach your package and maybe your project folder, please.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 30th Apr 2012, 09:52 PM #37
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


@Buzzler: you were right--I forgot to switch over to .NET 2.0. I've set up the projects so many times already, I can barely keep track of which one I am working on.

I have tried every iteration that I can think of, of how to put things together. I am still not able to see the message box show. Is it possible that I am trying to create a message box before one exists?

Attached in the Project and the package that I am testing with.
Download - please read all instructions before downloading any files!
File Type: rar Test.rar (20.6 KB, 2 downloads) - View custom content
Description: VS 2008 Project folder and package
Old 30th Apr 2012, 10:21 PM #38
Buzzler
1978 gallons of pancake batter



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

View My Journal


Ok, works fine for me. Works fine as in "crashes the game". I assumed it'd do that from the start, because trying to show dialogs in the wrong context will do that for you. I'm baffled why it doesn't seem to do that for you. Do you maybe have a non-functional version of the mod lingering somewhere and thus overriding all your attempts?

That project is still compiled against the .NET libraries. I'd change that.

Try that instead of directly showing the dialog:
Code:
private static void OnWorldLoadFinished(object sender, EventArgs e)
{
    try
    {
        // AcceptCancelDialog.Show("This. is. OnWorldFinished!");
        StyledNotification.Format fmt = new StyledNotification.Format("Say hello to my little world", "Ok", StyledNotification.NotificationStyle.kDebugAlert);
        AlarmManager.Global.AddAlarm(1f, TimeUnit.Seconds, () => StyledNotification.Show(fmt), "hello world", AlarmType.NeverPersisted, null);
    }
    catch (Exception exception)
    {
        ((IScriptErrorWindow)AppDomain.CurrentDomain.GetData("ScriptErrorWindow")).DisplayScriptError(null, exception);
    }
}

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 30th Apr 2012, 10:55 PM #39
Consort
Field Researcher

Join Date: Oct 2005
Posts: 340
Thanks: 3610 in 88 Posts
10 Achievements


@dim4sim If you want to test your VS setup, here's a mod as a vs2008 project http://www.modthesims.info/showpost...506&postcount=9, here's a vs2010 project http://www.modthesims.info/showthread.php?t=473623. I think you just have to do the references by hand.
Might be of help if you want to see something you compile appear in the game.
The learning curve of achieving that can be quite brutal
Old 1st May 2012, 04:04 AM #40
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Thanks for the project links Consort. I tried compiling your code (just the part that is binding and showing the Notice), and still nothing. Absolutely nothing happens in my game.
Is it possible that something is not compiling right because I am on a Win7 64bit? All other mods work for me, but not ones that have been compiled on my own machine.

Also, I noticed something that happens only to my dlls: when you look at the S3SA, after the refs, it says "Type: Dima.Test", which is the Namespace.Class. I checked at least 4 other mods and none of them have that.


Thanks.


Edit: I got something to work! Finally!
I started clearing the scriptCache on every update. I'm surprised that I hadn't thought of it before. Perhaps I can finally make some progress. Also, it may have had to do with the fact that I was keeping S3PE open between runs.
Last edited by dim4sim : 10th May 2012 at 04:39 PM.
Old 17th May 2012, 05:01 PM #41
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Hey Buzzler,

I've been studying your Chuck Norris mod, and I was wondering if I you would mind me borrowing your event delegation setup. Also, I have a few questions as to why certain things are done the way they are, such as defining something as null, then checking to see if that thing is null, and setting it, as opposed to just setting something right away. My first guess would be to eliminate room for error so that everything could be caught in the try block. I would imagine that the Sims3 codebase isn't the most stable of things, so expect the unexpected, right?

Also, is there any way to share the base library between several libraries? Maybe compile into a DLL and import in another script mod? The only thing that I would expect in that scenario is that, if I change the base library from one mod to another, and they have the same hash value, they will replace each other unpredictably.


Thanks.
Old 17th May 2012, 09:11 PM #42
Buzzler
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 dim4sim
I've been studying your Chuck Norris mod, and I was wondering if I you would mind me borrowing your event delegation setup.
Go ahead. Just remember to change the namespace.

Quote:
Also, I have a few questions as to why certain things are done the way they are, such as defining something as null, then checking to see if that thing is null, and setting it, as opposed to just setting something right away.
Not sure what you mean. Could you give me an example, please.

Quote:
Also, is there any way to share the base library between several libraries? Maybe compile into a DLL and import in another script mod?
Yes, that's possible. I actually planned to do that for while now. I wouldn't put it into another package, though. Just a different S3SA resource.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 18th May 2012, 12:40 AM #43
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Aside: Forgot to mention: I'm back now. I took a bit of time of to gather my thoughts, play some games, sleep, and relax.


If someone were to create a shared library, such as the one that you have, would it need to have different hash values, to prevent overriding? I think that it would be great to have a MTS.Common.dll that could be supported by various volunteers--I sure would.


Quote:
Go ahead. Just remember to change the namespace.

Yea, I'll do this for now, and expand on it later, once I have a better grasp on things.

Quote:
Not sure what you mean. Could you give me an example, please.

In TwoBTech.Roundhouse.Interactions.KickScum, inside the InRabbitHole method, there is the following:
Code:
AlarmTimerCallback callback = null;
...
try {
  if (callback == null)
  {
    callback = delegate {
      base.Actor.AddExitReason(ExitReason.Finished);
    };
  }
  ...
}
...

Why not just assign it straight away?
I was also going to ask you about that delegate line, but after some reading today, I now know that it's an anonymous function. Finally, something I can relate to.


Thanks again for all the help.
Old 18th May 2012, 11:28 AM #44
Buzzler
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 dim4sim
If someone were to create a shared library, such as the one that you have, would it need to have different hash values, to prevent overriding? I think that it would be great to have a MTS.Common.dll that could be supported by various volunteers--I sure would.
Well, the point of having a *shared* library would be to have the game only load it once, right? So, the instance id should be the same. Every mod that relies on it, should come with it. Having it multiple times wouldn't matter, as the game would still only load it once. You'd have to be careful about updating/changing it, of course.

Quote:
In TwoBTech.Roundhouse.Interactions.KickScum, inside the InRabbitHole method, there is the following:{...}
Huh? What do you use for decompiling? I just looked at the .dll with ILSpy and Reflector and both show this:
Code:
base.Target.AddAlarm(90f, TimeUnit.Minutes, delegate {
            base.Actor.AddExitReason(ExitReason.Finished);
        }, "Kicking Scum Finished Alarm", AlarmType.AlwaysPersisted);
(That should be the related line anyway.)

And the original is this
Code:
base.Target.AddAlarm(90f, TimeUnit.Minutes, () => base.Actor.AddExitReason(ExitReason.Finished), "Kicking Scum Finished Alarm", AlarmType.AlwaysPersisted);
The () => ... part is a lambda expression and means the same as the delegate{...} part.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Old 18th May 2012, 06:49 PM #45
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


That's weird--I'm using Reflector as well. I will try to open it up with ILSpy to see what I get.

On a tangent, I wanted to ask some questions about Alarms (feel free to point me to a Wiki):
-AlarmTypes: does NeverPersisted run once, and an AlwaysPersisted run a poller? Better yet, what are the differences between the different AlarmTypes?
-If a Sim Minute == a regular second, does a Sim Second (TimeUnit.Seconds) == 1/60 second, or 16.667 milliseconds?


Thanks
Old 18th May 2012, 07:20 PM #46
twallan
Top Secret Researcher

Join Date: Jun 2009
Posts: 1,646
2 Achievements


"AlwaysPersisted" means the alarm is saved to the save-file and restored the next time you load the game.

"NeverPersisted" means the alarm is never saved to the save-file, and requires that you restart it via code when the game loads up.

To run a repeating alarm you need to use AddAlarmRepeating or AddAlarmDay.

----

As for times smaller than a sim-minute : I'm not certain how they are handled by the game. Perhaps another user can elaborate on them.


NRaas Industries: Sims 3 Mods for the Discerning Player, hosted by The Wikispaces.
Old 7th Jun 2012, 06:59 PM #47
dim4sim
Original Poster

Lab Assistant

Join Date: Jun 2011
Posts: 73
Thanks: 364 in 6 Posts
5 Achievements


Hey Buzzler,

I have a question: in your framework, when you go to bind the interactions, why do you need to execute the command on all GameObjects?

Code:
foreach (GameObject obj2 in Sims3.Gameplay.Queries.GetObjects<GameObject>())
{
  this.ApplyInteractions(obj2);
}


Actually, the questions is two-fold:
-do you have to attach the interaction to every single instance of the GameObject that you are working with?
-why do you need to try to attach to EVERY GameObject, regardless of its type?


I was just looking at this in greater detail because I am trying to understand how to correctly implement the ReplaceInteractions method. Right now, it is very similar in code to the AddInteractions, which will need to change in order to accomodate for the additional steps needed in a replacement.


Thanks
Old 8th Jun 2012, 04:55 PM #48
Buzzler
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 dim4sim
in your framework, when you go to bind the interactions, why do you need to execute the command on all GameObjects?
What I store in the InteractionManager class is a dictionary with type keys and List<InteractionDefinition> values for the interactions to be added and a dictionary with type keys and List<type> values for the interactions to be removed.

The ApplyInteractions() method gets called for each GameObject and will in turn call RemoveInteractions() and AddInteractions().
- RemoveInteractions checks if a matching key is found in the mRemoveInteractions dictionary and if so, will remove interactions (by type) for each type in the value.
- AddInteractions checks if a matching key is found in the mAddInteractions dictionary and if so, will add all interactions in the value unless the respective interaction is already there. It will not add the interaction if the types don't match (and the target object isn't of a sub type of the given type).

I just iterate over every GameObject and then determine the action to take. That action may be to do nothing.

The reason why I do that for all GameObjects is that I assume it'd take longer to iterate over each dictionary's keys and only query the given types. Right now I have _one_ loop that iterates over a pretty large collection. The alternative would be to have quite a lot of loops that iterate over collections that may or may not be smaller.

Robot Armed With Down Comforter Levels Apartment Building, Holds Mayor Hostage.
Reply


Section jump:


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