Replies: 6 (Who?), Viewed: 170 times.
Test Subject
Original Poster
#1 Old 2nd Jul 2021 at 9:23 AM Last edited by mbottle : 2nd Jul 2021 at 3:00 PM. Reason: Attempting to correctly show code
Default Help with Small Mod adding interaction to animation[code][/code]
Hi all,

I'm hoping someone can help. I am trying to figure out how to add an in-game interaction to go with an animation (like the interactions that go with the animation world animations posted by SweetSimmer).

I have watched every tutorial including the new ones by pudding face and read all the old ones. I am new to modding, so I am sure I am getting something wrong. I just want to be able to click on the sim and have them do the animation without animation player, I don't need buffs added or skills or the animation to go with an object. What will be the SS3A package (building the solution) is what my problem is, I get 7 errors which have mainly to do with syntax and the highlited bit of code below, which sharp develop says a) needs a semi-colon b) the ! is invalid and c) the add interaction line is invalid.

I am using sharp develop. Also for reference I understand all the parts after building the solution (the xml files, making the package file, making/adding the animation, etc). I just can't build the solution.

I apologize if this is in the wrong place or if I am somehow incorrectly posting this. Hopefully someone can assist. Thank you very much in advance.

using System;
using System.Collections.Generic;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;

namespace MPrimaMod
{
/// <summary>
/// Description of MyClass.
/// </summary>
public class PrimaD
{
[Tunable]
protected static bool kInstantiator = false;

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

foreach (sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>())
{
if (sim != null)
}
AddInteractions(sim);
}

private static void AddInteractions(sim sim)
{
simAddInteraction(PrimaDInteraction.singleton, true);
}
public class PrimaDInteraction : ImmediateInteraction<sim,sim>
{
public static readonly InteractionDefinition Singleton = new Definition();

public override bool Run()
{
StyledNotification.Show(new stylenotification.format("Prima Dance",StyledNotification.NotificationStyle.kGameMessagePositive))
return true;
}
public class Definition : InteractionDefinition<Sim,Sim,PrimaDInteraction>
{

public override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair iop)
{
return "Prima Dance Interaction";
}

public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{

if (actor.SimDescription.YAandUp)
{
if(actor==target)
}
return true;
}

return false;
}
}
Advertisement
Staff - Moderator
staff: moderator
#2 Old 2nd Jul 2021 at 2:21 PM
Hey there!
When posting code, if you use the [ code][ /code] (without spaces) tag, it will format the text properly as code so it's easier to read.

I'm not sure which parts are giving errors, but I did notice there should be a semi colon at the end of the line:
Code:
StyledNotification.Show(new stylenotification.format("Prima Dance",StyledNotification.NotificationStyle.kGameMessagePositive));


Other than that, I can't tell what the other issues are, but if you could highlight the sections giving the error, and exactly what error it's giving, that will help a lot
Field Researcher
#3 Old 2nd Jul 2021 at 3:01 PM
Zoe is correct,
there is a ; missing in the line above and the code tag helps the readability , however there are more issues

First lets look at your class

Here you are using the foreach loop outside a method which is not possible, it seems that you are missing the implementation of your OnWorldLoadFinished method , also your if statement does nothing without it having a instruction attached to it ( seems again that the scope is of)
Fix


Now i decided to fix the code and make comments so you can see were errors appeared

Test Subject
DELETED POST
Original Poster
2nd Jul 2021 at 3:11 PM
This message has been deleted by mbottle. Reason: Posted before question answered
Field Researcher
#4 Old 2nd Jul 2021 at 3:17 PM
Quote:
Originally Posted by mbottle
but when I try to do so and install, it says I need an updated net framework but I have the most recent (4.8 I think).

; expected (CS1002) :Line-35
A namespace cannot directly contain members such as fields or methods (CS0116) :Line-39
Expected class, delegate, enum, interface, or struct (CS1518) : Line-42
Invalid token '!=' in class, struct, or interface member declaration (CS1519) : Line-37
Invalid token '(' in class, struct, or interface member declaration (CS1519) – Line-35
Invalid token 'foreach' in class, struct, or interface member declaration (CS1519) Line-35
Invalid token 'return' in class, struct, or interface member declaration (CS1519):Line-73


Sims 3 needs the .Net2.0 Framework which is not included in verison 4 and above.
to get that framework type WindowsFeatures in your start menu and see if you have a checkmark on .Net Framework 3.5 (includes 2.0 and 3.0) if not check it,
I assume this is the problem
Test Subject
Original Poster
#5 Old 2nd Jul 2021 at 3:18 PM
HOLY MOLY OMGGGGGGGG I AM RUNNING BEHIND BUT SO FREAKING WORTH IT

Ahem, sorry. It worked because you are a genius, and also I save this example so that I can use it again in the future. I really am a) late and b) so grateful. And now I can test this all out later.

Thank you both, I can't say that enough.
Field Researcher
#6 Old 2nd Jul 2021 at 3:21 PM
Quote:
Originally Posted by mbottle
HOLY MOLY OMGGGGGGGG I AM RUNNING BEHIND BUT SO FREAKING WORTH IT

Ahem, sorry. It worked because you are a genius, and also I save this example so that I can use it again in the future. I really am a) late and b) so grateful. And now I can test this all out later.

Thank you both, I can't say that enough.



Im glad its fixed now, have fun starting your script modding journey, and good luck !
Staff - Moderator
staff: moderator
#7 Old 2nd Jul 2021 at 5:07 PM
(By the way, you put the code tags around the text that you want to display as code, just for future reference :p)
Back to top