Replies: 5 (Who?), Viewed: 188 times.
Test Subject
Original Poster
#1 Old 29th Jun 2020 at 2:43 AM
Default Differences between adding interactions to a custom and an existing object
I'm learning to add interactions to sims and objects from the tutorials in the forums and a few other people's mods, and I've been able to get an extremely simple dummy interaction into the game that I'm now going to increase the complexity of, but there's one thing I'm puzzled about.

In the tutorials I've seen and one of the other mods I've opened up as an example, the "Test", "Run", and "GetInteractionName" methods of the custom interactions are protected override methods. In the interaction I'm making, though, which is an interaction with the normal cheap computer instead of a custom object, making any methods protected instead of public gives me the error "cannot change access modifiers when overriding 'public' inherited member 'InteractionInstance.WHATEVER-METHOD()'". So I changed the access modifier to public and it looked fine, but I feel like that's a significant change to have made.

Code:
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Objects.Electronics;
using Sims3.SimIFace;
using Sims3.UI;

namespace lizcandor.ObjectInteractionTutorial
{
    public sealed class ObjectInteractionTutorialInteraction: Interaction<Sim,Computer>
    {
        public static readonly InteractionDefinition Singleton = new Definition();

        public override bool Run()
        {
            Actor.ShowTNSIfSelectable("Hello!", StyledNotification.NotificationStyle.kSimTalking);
            return true;
        }

        [DoesntRequireTuning]
        private sealed class Definition: InteractionDefinition<Sim, Computer, ObjectInteractionTutorialInteraction>
        {
            public override string GetInteractionName(Sim actor, Computer target, InteractionObjectPair iop)
            {
                return "Object Interaction Tutorial";
            }

            public override bool Test(Sim actor, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                return actor.SimDescription.ChildOrAbove;
            }
        }
    }
}


When I look in ILSpy all the other interactions on the computer also use public methods, so I assume I'm on the right track but not knowing why is needling at me.

So, my question: do the access modifiers of methods inherited from a class always have to match the base class? And if so, does anyone know why those modifiers would have been made protected in mods like this one or why it wasn't a problem there?
Advertisement
Virtual gardener
staff: administrator
#2 Old 29th Jun 2020 at 11:49 AM
Heya!

I had this problem as well when I was working on my sewing table's "Browse for Patterns" Interaction. Now one thing I noticed was that I needed to have the unprotected DLLs (See: https://github.com/Chain-Reaction/N.../Sims3/Compiler)

First thing I did notice was that you're using a regular interaction rather than the 'computer interaction'. 

Code:
    public class BrowseSewingDIY : Computer.ComputerInteraction
    
So for a computer, you can use this template:

Code:
namespace Sims3.Gameplay.Objects.Lyralei
{
    public class BrowseSewingDIY : Computer.ComputerInteraction
    {
        public sealed class Definition : InteractionDefinition<Sim, Computer, BrowseSewingDIY>
        {
            public override string GetInteractionName(Sim actor, Computer target, InteractionObjectPair iop)
            {
                    return Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatterns:InteractionName", new object[0]);
            }
            public override bool Test(Sim actor, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                return true;
            }
        }
        public static InteractionDefinition Singleton = new Definition();
         
        public override bool Run()
        {
            // EA Made a run function that is very dynamic. So this will always work and it's a great template to use! 
            base.StandardEntry();
            if(!base.Target.StartComputing(this, SurfaceHeight.Table, true))
            {
                base.StandardExit();
                return false;
            }
            base.Target.StartVideo(Computer.VideoType.Browse);
            base.BeginCommodityUpdates();
            base.AnimateSim("GenericTyping");
            bool flag = base.DoLoop(ExitReason.Default, LoopDel, null);
            base.EndCommodityUpdates(flag);
            base.Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
            base.StandardExit();
            return flag;
        }
        
      // Not necessary, but I'd do that though for any sim with a hate for electronics
        public void LoopDel(StateMachineClient smc, LoopData loopData)
        {
            if (base.Actor.HasTrait(TraitNames.AntiTV) && loopData.mLifeTime > Computer.kTechnophobeTraitMaximumChatTime)
            {
                base.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatternsHateComputers:InteractionName", new object[0]), StyledNotification.NotificationStyle.kSimTalking);
                base.Actor.AddExitReason(ExitReason.Finished);
            }
        }
    }

Since I think what goes wrong here as well, is that you're adding the interaction in a regular way, rather than it being a computer. The thing with the Computer interaction is that it's structured quite differently compared to a regular Game Object interaction. So the way you got it going right here, would totally have been correct and fine for, say, the teddy bear or any decorative item

Another note here btw, if you want to add a computer interaction, make sure to add the correct ITUN file for it as well (Else your sims can't sit down!)  And, instantiate the interaction globally like done here (Scroll to 'Applying Interactions to Game Objects': http://www.simlogical.com/ContentUp..._script_mod.pdf ) The ITUN file, just copy/paste this into a notepad and change the Interaction name of course

Code:
<?xml version="1.0"?>
<base>
   <Interaction name="Sims3.Gameplay.Objects.Lyralei.BrowseSewingDIY+Definition" />
   <Object name="Sims3.Gameplay.Objects.Electronics.Computer" />
   <CodeVersion name="BaseGame" considerCodeVersion="False" />
   <Current_Tuning>
      <Disallow DisallowAutonomous="False" DisallowUserDirected="False" DisallowPlayerSim="False" />
      <BaseAvailability>
         <AgeSpeciesAvail AgeSpeciesValue="T,Y,A,E" />
         <MotiveThreshold MotiveThresholdType="None" MotiveThresholdValue="0" MotiveBelowCheck="False" />
         <MoodThreshold MoodThresholdType="None" MoodThresholdValue="0" />
         <SkillThreshold SkillThresholdType="None" SkillThresholdValue="0" />
         <ExcludingTrait type="AntiTV" />
         <Occult OccultRestrictionType="Ignore" OccultTypes="0x0" OccultTypesHumanAllowed="True" />
         <CareerThreshold CareerThresholdType="Undefined" CareerThresholdValue="0" IncludePastCareers="False" />
         <Lot AllowNonGreetedSimsIfObjectOutside="False" AllowNonGreetedSimsIfObjectOutsideUserDirected="True" AllowGreetedSims="True" AllowOnCommunityLots="True" AllowOnAllLots="False" />
         <World RestrictionType="None" Types="" Names="" />
         <Room AllowInTombRoomAutonomous="False" AllowEvenIfNotAllowedInRoomAutonomous="False" />
         <Misc DisallowedIfPregnant="False" DisallowedFromInventory="False" />
      </BaseAvailability>
      <PosturePrecondition name="Sitting" value="1">
         <Check name="InFrontOfSurfaceForTarget" />
         <Check name="ChairScootedIntoSurface" />
      </PosturePrecondition>
      <PosturePrecondition name="Standing" value="1">
         <Check name="TargetInInventory" />
      </PosturePrecondition>
      <Check type="SelfRegarding" value="1.5" />
      <Check type="InappropriateForVisitor" value="0.5" />
      <Check type="All" value="0" />
      <Tradeoff name="BrowseWeb">
         <Localization autoGenerate="True" />
         <Time value="1" addRoute="True" />
         <Exit funExit="True" stressExit="False" interruptible="False" />
         <RouteLeadIn allowed="True" />
         <AskJoinInteraction joinable="False" />
         <AllowAutonomousReinforcement allowPraise="False" allowScold="False" />
         <ScoringFunction alwaysChooseBest="False" name="" specificCommodity="None" />
         <ActionTopic name="Action Read Newspaper" ActionTopicUnavailableAfterActionFinishes="False" />
         <Output>
            <Change type="Fun" advertised="20" locked="True" actual="20" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="BeMummy" advertised="-75" locked="True" actual="-75" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="TraitFairy" advertised="-75" locked="True" actual="-75" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="RoleCafeteriaWaiter" advertised="-200" locked="True" actual="-200" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="RoleLocationMerchant" advertised="-200" locked="True" actual="-200" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
         </Output>
      </Tradeoff>
   <Notes Notes="" DesignerNotes="" LastChange="" />
   </Current_Tuning>
</base&gt
So this one is a bit tougher than a regular Game Object, but I hope this helps!
Test Subject
DELETED POST
29th Jun 2020 at 9:56 PM
This message has been deleted by Lyralei. Reason: Cleaning the thread a little from accidental duplicated posts :)
Test Subject
#3 Old 29th Jun 2020 at 10:01 PM
Quote:
Originally Posted by SimShady19
[QUOTE=Lyralei]Heya!

I had this problem as well when I was working on my sewing table's "Browse for Patterns" Interaction. Now one thing I noticed was that I needed to have the unprotected DLLs (See: https://github.com/Chain-Reaction/N.../Sims3/Compiler)

First thing I did notice was that you're using a regular interaction rather than the 'computer interaction'. 

Code:
    public class BrowseSewingDIY : Computer.ComputerInteraction
    
So for a computer, you can use this template:

Code:
namespace Sims3.Gameplay.Objects.Lyralei
{
    public class BrowseSewingDIY : Computer.ComputerInteraction
    {
        public sealed class Definition : InteractionDefinition<Sim, Computer, BrowseSewingDIY>
        {
            public override string GetInteractionName(Sim actor, Computer target, InteractionObjectPair iop)
            {
                    return Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatterns:InteractionName", new object[0]);
            }
            public override bool Test(Sim actor, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                return true;
            }
        }
        public static InteractionDefinition Singleton = new Definition();
         
        public override bool Run()
        {
            // EA Made a run function that is very dynamic. So this will always work and it's a great template to use! 
            base.StandardEntry();
            if(!base.Target.StartComputing(this, SurfaceHeight.Table, true))
            {
                base.StandardExit();
                return false;
            }
            base.Target.StartVideo(Computer.VideoType.Browse);
            base.BeginCommodityUpdates();
            base.AnimateSim("GenericTyping");
            bool flag = base.DoLoop(ExitReason.Default, LoopDel, null);
            base.EndCommodityUpdates(flag);
            base.Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
            base.StandardExit();
            return flag;
        }
        
      // Not necessary, but I'd do that though for any sim with a hate for electronics
        public void LoopDel(StateMachineClient smc, LoopData loopData)
        {
            if (base.Actor.HasTrait(TraitNames.AntiTV) && loopData.mLifeTime > Computer.kTechnophobeTraitMaximumChatTime)
            {
                base.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatternsHateComputers:InteractionName", new object[0]), StyledNotification.NotificationStyle.kSimTalking);
                base.Actor.AddExitReason(ExitReason.Finished);
            }
        }
    }

Since I think what goes wrong here as well, is that you're adding the interaction in a regular way, rather than it being a computer. The thing with the Computer interaction is that it's structured quite differently compared to a regular Game Object interaction. So the way you got it going right here, would totally have been correct and fine for, say, the teddy bear or any decorative item

Another note here btw, if you want to add a computer interaction, make sure to add the correct ITUN file for it as well (Else your sims can't sit down!)  And, instantiate the interaction globally like done here (Scroll to 'Applying Interactions to Game Objects': http://www.simlogical.com/ContentUp..._script_mod.pdf ) The ITUN file, just copy/paste this into a notepad and change the Interaction name of course

Code:
<?xml version="1.0"?>
<base>
   <Interaction name="Sims3.Gameplay.Objects.Lyralei.BrowseSewingDIY+Definition" />
   <Object name="Sims3.Gameplay.Objects.Electronics.Computer" />
   <CodeVersion name="BaseGame" considerCodeVersion="False" />
   <Current_Tuning>
      <Disallow DisallowAutonomous="False" DisallowUserDirected="False" DisallowPlayerSim="False" />
      <BaseAvailability>
         <AgeSpeciesAvail AgeSpeciesValue="T,Y,A,E" />
         <MotiveThreshold MotiveThresholdType="None" MotiveThresholdValue="0" MotiveBelowCheck="False" />
         <MoodThreshold MoodThresholdType="None" MoodThresholdValue="0" />
         <SkillThreshold SkillThresholdType="None" SkillThresholdValue="0" />
         <ExcludingTrait type="AntiTV" />
         <Occult OccultRestrictionType="Ignore" OccultTypes="0x0" OccultTypesHumanAllowed="True" />
         <CareerThreshold CareerThresholdType="Undefined" CareerThresholdValue="0" IncludePastCareers="False" />
         <Lot AllowNonGreetedSimsIfObjectOutside="False" AllowNonGreetedSimsIfObjectOutsideUserDirected="True" AllowGreetedSims="True" AllowOnCommunityLots="True" AllowOnAllLots="False" />
         <World RestrictionType="None" Types="" Names="" />
         <Room AllowInTombRoomAutonomous="False" AllowEvenIfNotAllowedInRoomAutonomous="False" />
         <Misc DisallowedIfPregnant="False" DisallowedFromInventory="False" />
      </BaseAvailability>
      <PosturePrecondition name="Sitting" value="1">
         <Check name="InFrontOfSurfaceForTarget" />
         <Check name="ChairScootedIntoSurface" />
      </PosturePrecondition>
      <PosturePrecondition name="Standing" value="1">
         <Check name="TargetInInventory" />
      </PosturePrecondition>
      <Check type="SelfRegarding" value="1.5" />
      <Check type="InappropriateForVisitor" value="0.5" />
      <Check type="All" value="0" />
      <Tradeoff name="BrowseWeb">
         <Localization autoGenerate="True" />
         <Time value="1" addRoute="True" />
         <Exit funExit="True" stressExit="False" interruptible="False" />
         <RouteLeadIn allowed="True" />
         <AskJoinInteraction joinable="False" />
         <AllowAutonomousReinforcement allowPraise="False" allowScold="False" />
         <ScoringFunction alwaysChooseBest="False" name="" specificCommodity="None" />
         <ActionTopic name="Action Read Newspaper" ActionTopicUnavailableAfterActionFinishes="False" />
         <Output>
            <Change type="Fun" advertised="20" locked="True" actual="20" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="BeMummy" advertised="-75" locked="True" actual="-75" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="TraitFairy" advertised="-75" locked="True" actual="-75" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="RoleCafeteriaWaiter" advertised="-200" locked="True" actual="-200" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
            <Change type="RoleLocationMerchant" advertised="-200" locked="True" actual="-200" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />
         </Output>
      </Tradeoff>
   <Notes Notes="" DesignerNotes="" LastChange="" />
   </Current_Tuning>
</base&gt
So this one is a bit tougher than a regular Game Objects

So I think i found my problem,I dont know how to edit the Xml files im not really sure what to do.
Test Subject
Original Poster
#4 Old 30th Jun 2020 at 5:34 AM
Quote:
Originally Posted by SimShady19
[QUOTE=SimShady19]
So I think i found my problem,I dont know how to edit the Xml files im not really sure what to do.

By how to edit XML files, do you mean how to open them from/add them to packages in S3PE? If so, this might be the information you're looking for if you haven't seen it already!

Lyralei: You're right, those are exactly the things I was doing wrong I fought with this until like 1AM before understanding I needed to use a ComputerInteraction and give it an ITUN, and then spent another 3 hours thinking I made the ITUN wrong because sims just wouldn't go sit at the computer before realizing I once again did not do my localization. And now it works! Success!
Virtual gardener
staff: administrator
#5 Old 30th Jun 2020 at 9:52 AM
That's great to hear! :D I see you got that regular "Program till the end of the night" thing going on too :p But nice! 



with XML/ITUN related things, it's always something like an unfinished bracket or something so painfully obvious but also not :p
Test Subject
Original Poster
#6 Old 30th Jun 2020 at 3:24 PM
Quote:
Originally Posted by Lyralei
I see you got that regular "Program till the end of the night" thing going on too :p 

I'm discovering that modding this game can be more addictive than actually playing it The problem-solving imperative just...sinks its teeth into you...
Back to top