- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Help with Small Mod adding interaction to animation[code][/code]
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Help with Small Mod adding interaction to animation[code][/code]
Replies: 6 (Who?), Viewed: 215 times.
#1
2nd Jul 2021 at 9:23 AM
Last edited by mbottle : 2nd Jul 2021 at 3:00 PM.
Reason: Attempting to correctly show code
Posts: 22
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
#2
2nd Jul 2021 at 2:21 PM
Posts: 562
Thanks: 3597 in 11 Posts
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:
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
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
Space Pony
#3
2nd Jul 2021 at 3:01 PM
Posts: 433
Thanks: 792 in 6 Posts
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
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
Code:
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); }
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
Code:
public class PrimaD { [Tunable] protected static bool kInstantiator = false; static PrimaD() { World.sOnWorldLoadFinishedEventHandler += OnWorldLoadFinished; } static void OnWorldLoadFinished(object sender, EventArgs e) //Was not declared before { foreach (sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>()) { if (sim != null) //AddInteractions(sim); was not in scope of if (sim != null) { AddInteractions(sim); } } } }
Now i decided to fix the code and make comments so you can see were errors appeared
Code:
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.sOnWorldLoadFinishedEventHandler += OnWorldLoadFinished; } static void OnWorldLoadFinished(object sender, EventArgs e) { foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>()) // you are using the type Sim here so its capital S, recommend using something else for the current object like cSim { if (sim != null) { AddInteractions(sim); } } } private static void AddInteractions(Sim sim) //the type Sim has a capital S, id recommend to use another name for the parameter so you wont get confused { sim.AddInteraction(PrimaDInteraction.Singleton, true); //Missing the . for resolving the class member access, also Singleton with capital S } public class PrimaDInteraction : ImmediateInteraction<Sim,Sim> //Again you need to supply the type sim so capital S { public static readonly InteractionDefinition Singleton = new Definition(); // i recommend using another name for definition not an error though public override bool Run() { StyledNotification.Show(new StyledNotification.Format("Prima Dance",StyledNotification.NotificationStyle.kGameMessagePositive)); //the missing ; Zoe mentioned, also wrong name and capitalization 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.YoungAdultOrAbove) //YAandUp is not part of the Sims3 codebase use YoungAdultOrAbove { if(actor==target) // had no instruction in scope moved return true there { return true; } } return false; } } } } }
Space Pony
#4
2nd Jul 2021 at 3:17 PM
Posts: 433
Thanks: 792 in 6 Posts
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
#5
2nd Jul 2021 at 3:18 PM
Posts: 22
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.
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.
Space Pony
#6
2nd Jul 2021 at 3:21 PM
Posts: 433
Thanks: 792 in 6 Posts
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 !
#7
2nd Jul 2021 at 5:07 PM
Posts: 562
Thanks: 3597 in 11 Posts
(By the way, you put the code tags around the text that you want to display as code, just for future reference :p)
Who Posted
|