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!
Virtual gardener
staff: administrator
Original Poster
#1 Old 25th May 2019 at 5:43 PM
Default Mod not being instantiated
Hi guys!

So I've been working on my first pure mod ever, but somehow it doesn't ever want to get recognised in my game.

Things I did:
  • Making sure the Namespace + Class the instantiator is in in the code is the FNV64 hash of the XML resource
  • Also making sure kInstantiator is even a bool in the code
  • Commenting most of the code and create a simple "I am loaded" notification after WorldLoadfinished
  • Tried looking at some other people's Instantiator to see what I did wrong and couldn't figure it out.
  • Making sure the workflow on how to set it up is correct.
  • Empty cache packages

I THINK it's an instantiator issue that just doesn't want to get loaded/recognised and I'm not entirely sure where and why it isn't. Here's the test code I used:

Code:
using Sims3.Gameplay;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.UI.GameEntry;
using Sims3.Gameplay.Objects;


namespace Lyralei
{
    public class Ouroboros
    {
        [Tunable]
        protected static bool kInstantiator = false;

        static Ouroboros()
         {
            World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
         }
         public static void OnWorldLoadFinished(object sender, EventArgs e)
         {
             StyledNotification.Format format = new StyledNotification.Format("HELLO I AM WORKING", StyledNotification.NotificationStyle.kGameMessageNegative);
             StyledNotification.Show(format); 
         }
    }
}


I also attached the package file if needed
Attached files:
File Type: zip  lyraleiOuroboros.zip (2.3 KB, 10 downloads)
Advertisement
Space Pony
#2 Old 25th May 2019 at 5:55 PM
hey Lyralei,

your script runs when the world gets loaded. That doesnt mean that everything is in place after that. Give the game a sim minute or so by creating an alarm timer and then start your mesage.

this is what i would use in my OnWorldLoadFinished method

Code:
         
public static void OnWorldLoadFinished(object sender, EventArgs e)
{
      AlarmManager.Global.AddAlarm (5f, TimeUnit.Minutes, new AlarmTimerCallback (LoadMenuAfter_5_SimMinutes), "LoadUP", AlarmType.DeleteOnReset, null);
}

then your method to call
Code:
	
public static void LoadMenuAfter_5_SimMinutes()
{
             StyledNotification.Format format = new StyledNotification.Format("HELLO I AM WORKING", StyledNotification.NotificationStyle.kGameMessageNegative);
             StyledNotification.Show(format); 
}



Cheers and good luck


E: you can combine your message dialog into one line like so

Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("HELLO I AM WORKING", StyledNotification.NotificationStyle.kGameMessageNegative));
Virtual gardener
staff: administrator
Original Poster
#3 Old 25th May 2019 at 6:05 PM
... I did not think about the good old alarmmanager! Will give it a try and see how it goes And thanks for the super quick reply too!
Virtual gardener
staff: administrator
Original Poster
#4 Old 25th May 2019 at 6:29 PM
So I tried it, compiled it perfectly and all, but I noticed its not even loaded within the game itself. Like, this little popup screen before you click on a world ("Mod scripts found") Doesn't actually seem to even list it, so i do still think something is either wrong with my settings in VS or my instantiator just isn't properly being read

I also had the game set things up for half a simday just to be fully loaded, but no luck
Space Pony
#5 Old 25th May 2019 at 6:30 PM Last edited by Battery : 25th May 2019 at 6:50 PM.
try using a resource name for your xml

E. removed an option which was misleading

have to dig out my premade example file must be here somwhere


... just noticed your package file doesnt contain the key resource i think thats the problem entered the resource name which genereated the key resource after saving and it worked for me sorry for the confusion i caused

E2: im kinda redeemed since you still need the timer to get it to work so my ramblings at least contained some truth
Attached files:
File Type: 7z  lyraleiOuroboros.7z (2.7 KB, 11 downloads) - View custom content
Virtual gardener
staff: administrator
Original Poster
#6 Old 25th May 2019 at 6:50 PM
Haha I just realised we went after the same thing here! I just reloaded the page finding that you also were thinking about the _KEY resource solution I'll give it a try myself and hopefully it will work!

Thanks again for your help and the quick replies, I really appreciate it!
Space Pony
#7 Old 25th May 2019 at 6:52 PM
dont worry i was in the creepy forum lurker mode today anyways.

Oh and im interested in what you are cooking up Lyralei
Virtual gardener
staff: administrator
Original Poster
#8 Old 25th May 2019 at 7:02 PM
Ah, that seemed to do the job!

The plan is, which I know is going to take forever, to create a custom world which would be a bit like WA and it's Quests, but instead, have more of a storyline in it. Getting the script to figure out the worldID is going to be fun but I did find some helpful function classes for this within ILspy because EA must be in some way know what is a custom world and how to load these. So currently this script is just going to be a world info outputer, and from there I'll try building a more complex script! it's going to take a while though but so far i got pretty far, as well with the different resource types between Custom worlds and existing worlds in general and outputting sims data so you don't necessarily need to include a 'save' file if one would want to export a world with sims

So hopefully it will be helpful not only on an entertaining base but also for world creators
Space Pony
#9 Old 25th May 2019 at 7:06 PM
That sounds interesting

makes notes for ideas to steal

cant wait to see the mod when its near finished or finished

Again good luck Lyralei !
Virtual gardener
staff: administrator
Original Poster
#10 Old 25th May 2019 at 8:24 PM
@battery Hrm So in my own project and saving it isn't really working at all despite us having the same code.

I noticed in your assembly Or well, architecture type you were using 86x. So I tried switching to this as well. But I get the feeling you have an entirely different way of setting these things up then what's explained in all these tutorials :P

I also noticed that we had some different assembly types set up, so I checked out of using yours does the job but that also seemed to not work that well.

(This is by the way how I set things up, I also use 2008: http://simswiki.info/wiki.php?title..._Studio_project )
Space Pony
#11 Old 25th May 2019 at 10:26 PM Last edited by Battery : 25th May 2019 at 11:36 PM.
heres a screen of my settings

oh and my setup is almost the same just for my sleek and cool fast loading sharpdevelop (shameless plug)

but joke aside most important are the net 2.0 and non referencing of the mscorlib.dll oh and something i tend to forget is to edit the assembly info ( adding Simiface and the tunable attribute that is. I have set it to x86 since Sim3 cant make use of x64 instructions anyway so you might even get some performance out of that(although that gain should be neglectable)


I have attached a solution file you probably could just load into visual studio, and fingers crossed, should work out of the box (well you still need to rewire the references yourself)

E: after looking at your dll again i havent seen the using directives you have to include them to the assembly to get your constructor called with the Tunable attribute. I have attached a screenshot of what to do add to your assemblyinfo file

also see Additional Preparations In Visual Studio a bit unfortunate that this isnt listet in the startup tutorial you linked
Screenshots
Attached files:
File Type: 7z  Sims3EmptyProject.7z (2.6 KB, 11 downloads) - View custom content
Virtual gardener
staff: administrator
Original Poster
#12 Old 26th May 2019 at 12:08 PM Last edited by Lyralei : 26th May 2019 at 12:26 PM.
So, turns out... Either my 2008 Visual studio is just borked or the world of building dll's got sliiiightly upgraded to a point where 2008s was too outdated. I tried it with the visual 2017 version that I own to script stuff for Unity (And honestly, prefer because... Dark mode FTW :D), followed the exact same setup as that tutorial, also added your assembly thingies as well as setting the platform type to 86x (Mind you, I did all this in VS 2008 as well, the exact same way) But... somehow, magically it's working!

On another note, I wonder if it would be worth creating a general guide to properly set up things for also the newer versions of visual studio, or update the one I linked just to make it easier for the more beginner programmers.

Thanks again for your help I think this thread, in general, can be a good one for desperate people thinking it's their XML instantiator but actually just their build. Or even VS in this case.

EDIT:
I'm getting to the conclusion that there was something that isn't/wasn't properly exported in the code. Once I uncommented my code, S3PE actually gave me a valid error in its previewer:

Code:
ExportedTypes: Error reading Value: Exception has been thrown by the target of an invocation.
DefinedTypes: Error reading Value: Exception has been thrown by the target of an invocation.


So I would probably have to debug a little in order to figure out what is causing it but it doesn't seem to be necessarily a building issue per se. Quite interesting though!
Space Pony
#13 Old 26th May 2019 at 12:38 PM
Quote: Originally posted by Lyralei
So, turns out... Either my 2008 Visual studio is just borked or the world of building dll's got sliiiightly upgraded to a point where 2008s was too outdated. I tried it with the visual 2017 version that I own to script stuff for Unity (And honestly, prefer because... Dark mode FTW :D), followed the exact same setup as that tutorial, also added your assembly thingies as well as setting the platform type to 86x (Mind you, I did all this in VS 2008 as well, the exact same way) But... somehow, magically it's working!

On another note, I wonder if it would be worth creating a general guide to properly set up things for also the newer versions of visual studio, or update the one I linked just to make it easier for the more beginner programmers.

Thanks again for your help I think this thread, in general, can be a good one for desperate people thinking it's their XML instantiator but actually just their build. Or even VS in this case.

EDIT:
I'm getting to the conclusion that there was something that isn't/wasn't properly exported in the code. Once I uncommented my code, S3PE actually gave me a valid error in its previewer:

Code:
ExportedTypes: Error reading Value: Exception has been thrown by the target of an invocation.
DefinedTypes: Error reading Value: Exception has been thrown by the target of an invocation.


So I would probably have to debug a little in order to figure out what is causing it but it doesn't seem to be necessarily a building issue per se. Quite interesting though!


Hey Lyralei yeah we could make a newer quick start guide and maybe even include an empty example project. (Since it took just above 10 posts to fix the simple setup to work)
The Visual studio stuff is weird, guess i made the right choice by not chosing visual studio after all >)
Virtual gardener
staff: administrator
Original Poster
#14 Old 30th May 2019 at 11:59 AM
Sort of irrelevant to the thread, but I tweaked the tutorial a tiny bit by making it so that people know they could just use the latest VS version of they want by adding 'VS2012 or later'

About that error it was me derping a little by trying to parse in an integer in a string by forgetting to use a .ToString(). S3PE didn't like that.
Virtual gardener
staff: administrator
Original Poster
#15 Old 19th Sep 2019 at 8:56 PM Last edited by Lyralei : 19th Sep 2019 at 9:39 PM.
So the issue seems to have come back to me when I made a new script. I decided to look at this thread again and do the same thing (Except for changing the alarm name) but the notification won't be triggered somehow.

Code:
using System;
using Sims3.Gameplay.Interfaces;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay.Abstracts;
using Lyralei;

namespace Lyralei
{
    public class SnowAdditions
    {
        [Tunable]
        protected static bool kInstantiator = false;

        SnowAdditions()
        {
           World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
        }
       

        private static void OnWorldLoadFinished(object sender, EventArgs e)
        {
        	AlarmManager.Global.AddAlarm(5f, TimeUnit.Minutes, new AlarmTimerCallback(LoadNotificationAfter_5_SimMinutes), "LoadLyraleiSnowModAlarm", AlarmType.DeleteOnReset, null);
//           
        }
        
        public static void LoadNotificationAfter_5_SimMinutes()
        {
        	Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("HELLO SNOW", StyledNotification.NotificationStyle.kGameMessageNegative));
        }
    }
}


The XML is all fine and is called "Lyralei.SnowAdditions" and the S3SA file is called "LyraleiSnowAdditions" (Used to be Lyralei.SnowAdditions). Any idea what it might be? It's really weird this keeps returning to me.

Edit forgot to say, the instance IDs of the XML and S3SA are both the same. Group is also 0x0. I tried importing everything in a new package too but no luck
Space Pony
#16 Old 20th Sep 2019 at 2:43 PM
Hey Lyralei,
the names of the files dont matter in facto they dont even need a name. Whats important is that the fnv64 hased name matches your Namespcace.Mainclass as a name.
So your xml should have the Instance 0x458F603AFABB4969 ( if Lyralei is your namespace and SnowAdditions is your main startup class). If that was not the error see if you might have a remnant assembly with the same namespace.class two entries will cancel each other out.
If all that doesnt fix the problem you could upload it so that i can have a look at it if you want.
Virtual gardener
staff: administrator
Original Poster
#17 Old 20th Sep 2019 at 4:11 PM
Huh so... in this case changing:
Code:
        SnowAdditions()
        {
           World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
        }


into"

Code:
static SnowAdditions()
        {
           World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
        }


Did the trick... I guess given how all the other methods are static, I probably should've tried doing that in the first place :P
Space Pony
#18 Old 20th Sep 2019 at 4:37 PM
Quote: Originally posted by Lyralei
Huh so... in this case changing:
Code:
        SnowAdditions()
        {
           World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
        }


into"

Code:
static SnowAdditions()
        {
           World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
        }


Did the trick... I guess given how all the other methods are static, I probably should've tried doing that in the first place :P



Well yeah didnt even look at that
Virtual gardener
staff: administrator
Original Poster
#19 Old 21st Sep 2019 at 3:36 PM
I somehow missed your previous reply totally! but it was good to know I wasn't the only one Thanks though for helping!
Back to top