- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Pure script mod tuts/examples for TS3
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Pure script mod tuts/examples for TS3
Replies: 20 (Who?), Viewed: 3813 times.
#1
5th Dec 2010 at 3:24 AM
Posts: 34
Pure script mod tuts/examples for TS3
I was wondering if there were some pure scripting tuts other than the one on this site which doesn't help with wanting to add interactions to an item. I don't want to create a new item, but add an interaction to an existing item. I have successfully created a new item with the extra interaction but I'd rather do it through pure scripting and just need a little help. Thanks.
Advertisement
#2
5th Dec 2010 at 10:34 AM
@kjmarket: The pure scripting tutorial will guide you up to the point you want to add your interaction. Adding interactions to an existing object (i.e. all existing objects of a certain kind) is pretty simple.
First I suggest you make a method for the actual adding. That goes like that:
Call that method for all objects of that type in your OnWorldLoadFinished() method like that:
For objects you buy in the catalog, you might want to add an EventListener to handle them too:
That event only gets raised for objects that are bought in the catalog while you edit the lot of an active household (and from registers? not sure). For long-lasting objects like RabbitHole objects it's usually sufficient to only add the interaction once after loading the game. For sims you need a listener for EventTypeId.kSimInstantiated. For objects that get instantiated without an event being raised, you can sometimes use an alarm. I wouldn't use really short alarm cycles (shorter than ~10 minutes), though. "Event-less" objects that shall have the interaction directly after instantiation, can be a toughie. ServingContainer objects probably can't be properly handled without an OBJK override and that's something you shouldn't do without giving it some serious thought.
HTH
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
First I suggest you make a method for the actual adding. That goes like that:
Code:
private static void AddInteractions(GameObjectOfChoice obj) { foreach (InteractionObjectPair pair in obj.Interactions) { if (pair.InteractionDefinition.GetType() == YourInteraction.Singleton.GetType()) { return; } } obj.AddInteraction(YourInteraction.Singleton); }
Call that method for all objects of that type in your OnWorldLoadFinished() method like that:
Code:
foreach (GameObjectOfChoice obj in Sims3.Gameplay.Queries.GetObjects<GameObjectOfChoice>()) { AddInteractions(obj); }
For objects you buy in the catalog, you might want to add an EventListener to handle them too:
Code:
and in your OnWorldLoadFinished() method you addprivate static EventListener sObjectBoughtListener; private static ListenerAction OnObjectBought(Event e) { GameObjectOfChoice obj = e.TargetObject as GameObjectOfChoice; if (obj != null) { AddInteractions(obj); } return ListenerAction.Keep; }
Code:
sObjectBoughtListener = EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(OnObjectBought));
That event only gets raised for objects that are bought in the catalog while you edit the lot of an active household (and from registers? not sure). For long-lasting objects like RabbitHole objects it's usually sufficient to only add the interaction once after loading the game. For sims you need a listener for EventTypeId.kSimInstantiated. For objects that get instantiated without an event being raised, you can sometimes use an alarm. I wouldn't use really short alarm cycles (shorter than ~10 minutes), though. "Event-less" objects that shall have the interaction directly after instantiation, can be a toughie. ServingContainer objects probably can't be properly handled without an OBJK override and that's something you shouldn't do without giving it some serious thought.
HTH
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
#3
5th Dec 2010 at 10:43 AM
Posts: 902
Thanks: 32120 in 20 Posts
I see Buzzler has covered everything, but since I've already put this together, I'll just post so that you (and others) have a concrete example (including the object interaction).
Code:
public static void AddHotTubInteractions(HotTubBase obj) { // check if the interaction isn't already on the object foreach (InteractionObjectPair pair in obj.Interactions) { if (pair.InteractionDefinition.GetType() == TurnOffHottub.Singleton.GetType()) { return; } } obj.AddInteraction(TurnOffHottub.Singleton); } // This is sent for every member of the household protected static ListenerAction OnObjectBought(Event e) { HotTubBase targetObject = e.TargetObject as HotTubBase; if (targetObject != null) { AddHotTubInteractions(targetObject); } return ListenerAction.Keep; } public static void OnWorldLoadFinishedHandler(object sender, EventArgs e) { Notify("OnWorldLoadFinishedHandler"); List<HotTubBase> tubs = new List<HotTubBase>(Sims3.Gameplay.Queries.GetObjects<HotTubBase>()); foreach (HotTubBase tub in tubs) { if (tub != null) { AddHotTubInteractions(tub); } } EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(VelocitygrassSims3Mod.OnObjectBought)); } // Turn off lights and jets on hot tubs public sealed class TurnOffHottub : ImmediateInteraction<Sim, HotTubBase> { // Fields public static readonly InteractionDefinition Singleton = new Definition(); // Methods public override bool Run() { if (base.Target.IsLightOn()) base.Target.TurnOffLights(); if (base.Target.AreJetsOn()) base.Target.StopJetFX(false); return true; } // Nested Types [DoesntRequireTuning] public sealed class Definition : ActorlessInteractionDefinition<Sim, HotTubBase, VelocitygrassSims3Mod.TurnOffHottub> { // Methods public override string GetInteractionName(Sim a, HotTubBase target, InteractionObjectPair interaction) { return "Turn off"; } public override bool Test(Sim a, HotTubBase target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return target.IsLightOn() || target.AreJetsOn(); } } }
#4
8th Dec 2010 at 1:38 AM
Posts: 34
Ok, I did soem work and ran into some problems. What I wanted was to add an interaction to the Fireworks. Here is what I have and the errors. The underlines parts are where the errors report. Any help, tips, or suggestions are appreciated.
Error 1 The name 'Notify' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 51 13 KJ.Sims3.Fireworks
Error 2 The best overloaded method match for 'KJFireworks.KJFinale.AddFireworkInteractions(Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms)' has some invalid arguments C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 58 21 KJ.Sims3.Fireworks
Error 3 Argument '1': cannot convert from 'System.Collections.Generic.List<Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms>' to 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 58 45 KJ.Sims3.Fireworks
Error4 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'RouteToLauncher' and no extension method 'RouteToLauncher' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 97 34 KJ.Sims3.Fireworks
Error 5 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'LaunchAndPushWatching' and no extension method 'LaunchAndPushWatching' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 107 29 KJ.Sims3.Fireworks
Error 6 The name 'CarrySystem' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 120 17 KJ.Sims3.Fireworks
Error 7 The name 'CarrySystem' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 121 17 KJ.Sims3.Fireworks
Error 8 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'mCurrentState' and no extension method 'mCurrentState' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 137 47 KJ.Sims3.Fireworks
Error 9 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms.FireworkState' is inaccessible due to its protection level C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 137 82 KJ.Sims3.Fireworks
Code:
using System; using System.Collections.Generic; using System.Text; using Sims3.SimIFace; using Sims3.Gameplay.Objects.Miscellaneous; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.EventSystem; using Sims3.Gameplay.Autonomy; namespace KJFireworks { public class KJFinale { [Tunable] protected static bool kInstantiator = false; [Tunable, TunableComment("The number of Big Booms required for a finale.")] private static int kNumBoomsForFinale; //static KJFinale(); //public KJFinale(); public static void AddFireworkInteractions(FireworksBigBooms obj) { // check if the interaction isn't already on the object foreach (InteractionObjectPair pair in obj.Interactions) { if (pair.InteractionDefinition.GetType() == LaunchFinale.Singleton.GetType()) { return; } } obj.AddInteraction(LaunchFinale.Singleton); } // This is sent for every member of the household protected static ListenerAction OnObjectBought(Event e) { FireworksBigBooms targetObject = e.TargetObject as FireworksBigBooms; if (targetObject != null) { AddFireworkInteractions(targetObject); } return ListenerAction.Keep; } public static void OnWorldLoadFinishedHandler(object sender, EventArgs e) { Notify("OnWorldLoadFinishedHandler"); List<FireworksBigBooms> bangs = new List<FireworksBigBooms>(Sims3.Gameplay.Queries.GetObjects<FireworksBigBooms>()); foreach (FireworksBigBooms bang in bangs) { if (bang != null) { AddFireworkInteractions(bangs); } } EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(KJFireworks.KJFinale.OnObjectBought)); } private sealed class LaunchFinale : Interaction<Sim, FireworksBigBooms> { // Fields private List<FireworksBigBooms> mReservedFireworks = new List<FireworksBigBooms>(); public static readonly InteractionDefinition Singleton = new Definition(); // Methods private void ReserveFireworks() { foreach (FireworksBigBooms booms in base.Actor.Inventory.FindAll<FireworksBigBooms>(true)) { if (booms != base.Target) { this.mReservedFireworks.Add(booms); if (this.mReservedFireworks.Count >= (KJFinale.kNumBoomsForFinale - 1)) { break; } } } foreach (FireworksBigBooms booms2 in this.mReservedFireworks) { base.Actor.Inventory.TryToRemove(booms2); } } protected override bool Run() { if (this.mReservedFireworks.Count == 0) { this.ReserveFireworks(); } if (!base.Target.RouteToLauncher(base.Actor)) { foreach (FireworksBigBooms booms in this.mReservedFireworks) { base.Actor.Inventory.TryToAdd(booms); } return false; } base.StandardEntry(); base.BeginCommodityUpdates(); base.Target.LaunchAndPushWatching(KJFinale.kNumBoomsForFinale, base.Actor); foreach (FireworksBigBooms booms2 in this.mReservedFireworks) { booms2.Destroy(); } base.EndCommodityUpdates(true); base.StandardExit(); return true; } protected override bool RunFromInventory() { this.ReserveFireworks(); CarrySystem.PickUpFromSimInventory(base.Actor, base.Target); CarrySystem.PutDownOnFloor(base.Actor); return this.Run(); } // Nested Types public sealed class Definition : InteractionDefinition<Sim, FireworksBigBooms, KJFireworks.KJFinale.LaunchFinale> { protected override string GetInteractionName(Sim a, FireworksBigBooms target, InteractionObjectPair interaction) { return "Launch Finale"; } // Methods protected override bool Test(Sim a, FireworksBigBooms target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { int num = a.Inventory.AmountIn<FireworksBigBooms>(); if ((num == 0) || (target.mCurrentState != FireworksBigBooms.FireworkState.Idle)) { return false; } if (a.Inventory.Contains(target)) { return (num >= KJFinale.kNumBoomsForFinale); } return (num >= (KJFinale.kNumBoomsForFinale - 1)); } } } } }
Error 1 The name 'Notify' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 51 13 KJ.Sims3.Fireworks
Error 2 The best overloaded method match for 'KJFireworks.KJFinale.AddFireworkInteractions(Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms)' has some invalid arguments C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 58 21 KJ.Sims3.Fireworks
Error 3 Argument '1': cannot convert from 'System.Collections.Generic.List<Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms>' to 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 58 45 KJ.Sims3.Fireworks
Error4 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'RouteToLauncher' and no extension method 'RouteToLauncher' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 97 34 KJ.Sims3.Fireworks
Error 5 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'LaunchAndPushWatching' and no extension method 'LaunchAndPushWatching' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 107 29 KJ.Sims3.Fireworks
Error 6 The name 'CarrySystem' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 120 17 KJ.Sims3.Fireworks
Error 7 The name 'CarrySystem' does not exist in the current context C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 121 17 KJ.Sims3.Fireworks
Error 8 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' does not contain a definition for 'mCurrentState' and no extension method 'mCurrentState' accepting a first argument of type 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms' could be found (are you missing a using directive or an assembly reference?) C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 137 47 KJ.Sims3.Fireworks
Error 9 'Sims3.Gameplay.Objects.Miscellaneous.FireworksBigBooms.FireworkState' is inaccessible due to its protection level C:\Users\KJMarket\Desktop\Games\s3mod\Script Mods\KJ.Sims3.Fireworks\Class1.cs 137 82 KJ.Sims3.Fireworks
#5
8th Dec 2010 at 11:02 AM
Posts: 902
Thanks: 32120 in 20 Posts
Error 1: Sorry about that. Just delete the notify line. I have a function in my code to print out messages.
Error 9: To be able to access all functions/members you should disassemble the Sims3GameplayObjects.dll and reassemble with all family, assembly and private level access changed to public. This might also be the reason for the "does not exist" errors.
Error 9: To be able to access all functions/members you should disassemble the Sims3GameplayObjects.dll and reassemble with all family, assembly and private level access changed to public. This might also be the reason for the "does not exist" errors.
#6
8th Dec 2010 at 11:00 PM
Posts: 34
Not quite sure how to dissassemble and reassemble that file. COuld you give me the general idea?
#7
9th Dec 2010 at 12:02 PM
Last edited by Digitalchaos : 9th Dec 2010 at 12:47 PM.
Posts: 591
Thanks: 2585 in 9 Posts
Error 1: [RESOLVABLE]
Notify("OnWorldLoadFinishedHandler"); -> SimpleMessageDialog.Show("", "OnWorldLoadFinishedHandler");
Add: using Sims3.UI;
Error 2 & 3: [RESOLVABLE]
if (bang != null) { AddFireworkInteractions(bangs); } -> if (bang != null) { AddFireworkInteractions(bang); }
Error 4/5/8: [UNRESOLVABLE]
These are private members, nothing outside of the FireworksBigBooms class can call them
- I don't recommend doing that, because you would have to supply everyone with the dlls that you changed (i.e. they would have to override their game dlls for that to work [A CORE MOD!!])
Error 6 & 7: [RESOLVABLE]
Add: using Sims3.Gameplay.ActorSystems;
Error 9 (same as for 4/5/8): [RESOLVABLE]
Add:
Notify("OnWorldLoadFinishedHandler"); -> SimpleMessageDialog.Show("", "OnWorldLoadFinishedHandler");
Add: using Sims3.UI;
Error 2 & 3: [RESOLVABLE]
if (bang != null) { AddFireworkInteractions(bangs); } -> if (bang != null) { AddFireworkInteractions(bang); }
Error 4/5/8: [UNRESOLVABLE]
These are private members, nothing outside of the FireworksBigBooms class can call them
Quote: Originally posted by velocitygrass
To be able to access all functions/members you should disassemble the Sims3GameplayObjects.dll and reassemble with all family, assembly and private level access changed to public. This might also be the reason for the "does not exist" errors. |
Error 6 & 7: [RESOLVABLE]
Add: using Sims3.Gameplay.ActorSystems;
Error 9 (same as for 4/5/8): [RESOLVABLE]
Add:
Quote:
public enum FireworkState { Idle, Lit, ActiveFailure, ActiveSuccess, Finished } |
#8
9th Dec 2010 at 1:22 PM
Posts: 902
Thanks: 32120 in 20 Posts
Quote:
- I don't recommend doing that, because you would have to supply everyone with the dlls that you changed (i.e. they would have to override their game dlls for that to work [A CORE MOD!!]) |
That's not true. You do not need to use those changed .dlls for anything other than compiling your .dll.
See: http://ts3.tscexchange.com/index.php?topic=3963.0
Quote:
Not quite sure how to dissassemble and reassemble that file. COuld you give me the general idea? |
The core modding tutorial should have all you need. The relevant part is how to get the ildasm.exe and ilasm.exe.
The steps then are:
1) disassemble using ildasm.exe
2) in the resulting .il file replace " private ", " family ", " assembly " each with " public "
3) use that changed .il file and reassemble
Then reference against those changed .dlls.
#9
9th Dec 2010 at 9:40 PM
Last edited by Digitalchaos : 9th Dec 2010 at 9:55 PM.
Posts: 591
Thanks: 2585 in 9 Posts
Quote: Originally posted by velocitygrass
That's not true. You do not need to use those changed .dlls for anything other than compiling your .dll |
That is only true for compiling the dll (not actually using it in someone's game)...
The private members are still private in the core dlls, and the game will not be able to make use of them, outside of their containing class.
When someone uses that in their game, the game should crash; but more than often, the object either becomes unuseable or other errors occur behind the scene that interferes with the useability of the object.
I know this for a fact because I have, heavily, experimented in this area when developing my own mods.
To put it succinctly:
You should be able to compile the dll...but it probably won't be useable in someone's game.
#10
9th Dec 2010 at 10:11 PM
Last edited by kjmarket : 9th Dec 2010 at 10:22 PM.
Posts: 34
Thanks for the continued help guys. It's not often these days you can ask questions ona message board without being verbally assaulted and called a noob. It is much appreciated. All but 4 errors are now fixed thanks to you guys. Unfortunatley the unresolvable ones are still there and the fix you posted DigitalChaos didnt work, though probably because I needed to change soemthing somewhere else and failed to. Giving Velocity's idea a try, though I am curious which one of you is right about it being a core mod or not, though my better judement tells me it is.
Edit. Not trying it now. Had the window open a while and hadnt refreshed to see your reply. Hmm what now I wonder. I guess what I should ask is whether I can accomplish adding an interaction to the fireworks as I want to, or not?
Edit. Not trying it now. Had the window open a while and hadnt refreshed to see your reply. Hmm what now I wonder. I guess what I should ask is whether I can accomplish adding an interaction to the fireworks as I want to, or not?
#11
9th Dec 2010 at 10:42 PM
Last edited by velocitygrass : 9th Dec 2010 at 10:52 PM.
Posts: 902
Thanks: 32120 in 20 Posts
Quote:
I know this for a fact because I have, heavily, experimented in this area when developing my own mods. |
I haven't had a problem with this approach at all. I've done this in my own mods, which work in game without including modified game .dlls.
Since I found the tip on Twallan's board, I just checked the code of the MasterController, which also accesses private members (and which definitely is a mod that is widely used).
Are you sure your problems didn't have other causes? Did you always try this in the context of more complicated mods or did you ever do a simple proof of concept mod that does nothing except accessing a private or protected member?
Quote:
I guess what I should ask is whether I can accomplish adding an interaction to the fireworks as I want to, or not? |
If the access level is the only problem, it should work. I have to admit, I didn't look too closely at the code. I'll see if I can try it out tomorrow or over the weekend. Heading off to bed now...
#12
10th Dec 2010 at 5:54 AM
Posts: 34
Ok, well I decided to put off doing this until I get another response so I decided to make a cloned object, which I've done before, and everythign went fine until the end. Two errors with this block of code.
Error 1 - The best overloaded method match for 'Sims3.Gameplay.Abstracts.GameObject.StartOneShotFunction(Sims3.Gameplay.Function, Sims3.Gameplay.Abstracts.GameObject.OneShotFunctionDisposeFlag)' has some invalid arguments C:\Users\KJMarket\Desktop\Games\s3mod\Fireworks\KJ.Sims3.Fireworks\Class1.cs 258 21 KJ.Sims3.Fireworks
Error 2 - Argument '1': cannot convert from 'Sims3.UI.Function' to 'Sims3.Gameplay.Function' C:\Users\KJMarket\Desktop\Games\s3mod\Fireworks\KJ.Sims3.Fireworks\Class1.cs 258 47 KJ.Sims3.Fireworks
-
This is EXACTLY how the code in the dll is yet it gives me errors so I'm thinking soemthing somewhere else must be off. Ideas?
Code:
private void PlayFireworkFX(bool isFailure) { if (this.mFireworkFX == null) { this.mFireworkFX = new List<VisualEffect>(); } if (isFailure) { base.StartOneShotFunction(new Function(this.AnimateFailure), GameObject.OneShotFunctionDisposeFlag.OnDispose); } else { this.StartFX("ep1FireWorksFx"); } }
Error 1 - The best overloaded method match for 'Sims3.Gameplay.Abstracts.GameObject.StartOneShotFunction(Sims3.Gameplay.Function, Sims3.Gameplay.Abstracts.GameObject.OneShotFunctionDisposeFlag)' has some invalid arguments C:\Users\KJMarket\Desktop\Games\s3mod\Fireworks\KJ.Sims3.Fireworks\Class1.cs 258 21 KJ.Sims3.Fireworks
Error 2 - Argument '1': cannot convert from 'Sims3.UI.Function' to 'Sims3.Gameplay.Function' C:\Users\KJMarket\Desktop\Games\s3mod\Fireworks\KJ.Sims3.Fireworks\Class1.cs 258 47 KJ.Sims3.Fireworks
-
This is EXACTLY how the code in the dll is yet it gives me errors so I'm thinking soemthing somewhere else must be off. Ideas?
#13
10th Dec 2010 at 7:27 PM
Last edited by velocitygrass : 10th Dec 2010 at 8:28 PM.
Posts: 902
Thanks: 32120 in 20 Posts
Okay, I tried the code from your first try and got it to work. Apart from making everything public in the .dlls as described earlier and using those changed .dll in the VS project to compile and the things that Digitalchaos already mentioned, I had to add the following changes:
1) add [assembly: Tunable] before the namespace
2) add the constructor which adds the OnWorldLoadFinishedEventHandler:
3) change the four occurrences of "protected override" into "public override"
The "Launch Finale" interaction appeared on an placed fireworks thing, though not from the inventory.I wonder if this needs to be set in the tuning file. I have no experience with that, but I'll take a look and see if that can be fixed too.
Found it. You just need to do AddInventoryInteraction in addtion to AddInteraction:
1) add [assembly: Tunable] before the namespace
2) add the constructor which adds the OnWorldLoadFinishedEventHandler:
Code:
static KJFinale() { Sims3.SimIFace.World.OnWorldLoadFinishedEventHandler += new EventHandler(KJFinale.OnWorldLoadFinishedHandler); }
3) change the four occurrences of "protected override" into "public override"
The "Launch Finale" interaction appeared on an placed fireworks thing, though not from the inventory.
Found it. You just need to do AddInventoryInteraction in addtion to AddInteraction:
Code:
obj.AddInteraction(LaunchFinale.Singleton); obj.AddInventoryInteraction(LaunchFinale.Singleton);
#14
10th Dec 2010 at 7:49 PM
Posts: 1,728
Quote: Originally posted by kjmarket
This is EXACTLY how the code in the dll is yet it gives me errors so I'm thinking soemthing somewhere else must be off. Ideas? |
The "Function" class exists in two different namespaces, and the compiler is choosing the wrong one.
Simply use the full qualifier "Sims3.Gameplay.Function" in place of "Function" in your code.
NRaas Industries: Sims 3 Mods for the Discerning Player, hosted by The Wikispaces.
#15
10th Dec 2010 at 8:53 PM
Last edited by kjmarket : 10th Dec 2010 at 11:30 PM.
Posts: 34
Velocity, I made the changes and will dissassemble the dll and see what happens.
EDIT - Can't do it because I can't find all those files after installing the .net 2.0 sdk. Can't locate the ildasm files for some reason.
Twallan, after some tweaks I got rid of the error. Had to do with using lines I think. So I got it compiled and done the way the tut says to and it crashes when I click it in buy debug. I've done this before but some update or soemthing made it stop working so I made it again. Guess it's time to start over. Blah. Hmmm.
EDIT - Can't do it because I can't find all those files after installing the .net 2.0 sdk. Can't locate the ildasm files for some reason.
Twallan, after some tweaks I got rid of the error. Had to do with using lines I think. So I got it compiled and done the way the tut says to and it crashes when I click it in buy debug. I've done this before but some update or soemthing made it stop working so I made it again. Guess it's time to start over. Blah. Hmmm.
#16
10th Dec 2010 at 11:11 PM
Posts: 902
Thanks: 32120 in 20 Posts
Quote:
Can't do it because I can't find all those files after installing the .net 2.0 sdk. Can't locate the ildasm files for some reason. |
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ildasm.exe
I believe this came with Visual Studio 2008 Express, but if you don't find it there, you might have to install the Windows SDK.
#17
10th Dec 2010 at 11:26 PM
Last edited by kjmarket : 10th Dec 2010 at 11:49 PM.
Posts: 34
I know its not in the same place. A full system search didnt find it and the windows location didnt exist. Mine were int he same place as yours. I'll reinstall.
Edit
After reinstalling I was able to find them.
Edit
After reinstalling I was able to find them.
#18
11th Dec 2010 at 2:58 AM
Last edited by kjmarket : 11th Dec 2010 at 4:52 AM.
Posts: 34
EDIT 5,327
Got it working. No interaction from inventory but its working perfectly when I put it on the ground. Only thing left is a few tweaks and figuring out the inventory problem. Thanks for the help guys and any further help you provide.
Im really surprised it worked like that. Its like you trick it into thinking the game's dll is public when it isnt, yet it can use it even though it's not. Confusing. All I know is it works without my altered game dll being packaged.
Got it working. No interaction from inventory but its working perfectly when I put it on the ground. Only thing left is a few tweaks and figuring out the inventory problem. Thanks for the help guys and any further help you provide.
Im really surprised it worked like that. Its like you trick it into thinking the game's dll is public when it isnt, yet it can use it even though it's not. Confusing. All I know is it works without my altered game dll being packaged.
#19
11th Dec 2010 at 9:03 AM
Posts: 902
Thanks: 32120 in 20 Posts
I'm glad you got it working
For the inventory problem you just need to do AddInventoryInteraction in addtion to AddInteraction:
For the inventory problem you just need to do AddInventoryInteraction in addtion to AddInteraction:
Code:
After adding this, I got the interaction on the object in inventory as well.
obj.AddInteraction(LaunchFinale.Singleton); obj.AddInventoryInteraction(LaunchFinale.Singleton);
#20
11th Dec 2010 at 1:49 PM
Quote: Originally posted by kjmarket
Im really surprised it worked like that. Its like you trick it into thinking the game's dll is public when it isnt, yet it can use it even though it's not. |
Quote: Originally posted by velocitygrass
For the inventory problem you just need to do AddInventoryInteraction in addtion to AddInteraction:{...} |
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Test Subject
#21
11th Dec 2010 at 9:47 PM
Posts: 39
Quote: Originally posted by velocitygrass
That's not true. You do not need to use those changed .dlls for anything other than compiling your .dll. See: http://ts3.tscexchange.com/index.php?topic=3963.0 The core modding tutorial should have all you need. The relevant part is how to get the ildasm.exe and ilasm.exe. The steps then are: 1) disassemble using ildasm.exe 2) in the resulting .il file replace " private ", " family ", " assembly " each with " public " 3) use that changed .il file and reassemble Then reference against those changed .dlls. |
I think this should be made into a wiki entry as it would really help people who want to be able to make mods that may need to do core modding things.
Thanks to twallan
Who Posted
|