- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- [update: new progress] Making a functioning library
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- [update: new progress] Making a functioning library
Posts: 562
Thanks: 3599 in 11 Posts
What I have managed to get working so far is by using the BookStoreRegister as a base, added a "Take Out Book" interaction, the list of books shows up, and the selected book gets copied into the sim's inventory.
This is the code:
using System; using System.Collections.Generic; using System.Text; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Autonomy; using Sims3.SimIFace; using Sims3.UI; using Sims3.Gameplay.Objects.Miscellaneous; using Sims3.Gameplay.Abstracts; using Sims3.Gameplay.Objects.RabbitHoles; using Sims3.Gameplay.Objects.Register; using Sims3.Gameplay.Interfaces; using Sims3.Gameplay.Skills; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.TuningValues; using Sims3.Gameplay.Core; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Objects.Alchemy; using Sims3.Gameplay.Roles; namespace Sims3.Gameplay.Objects.Register.Zoeoemod { class LibraryRegister : BookStoreRegister { public sealed class TakeOutBook : Interaction<Sim, LibraryRegister> { public static readonly InteractionDefinition Singleton = new Definition(); protected override bool Run() { Book book = null; book = (GetSelectedObject() as Book); if (book == null) { return false; } Actor.ShowTNSIfSelectable("Working! - " + book.Title.ToString(), StyledNotification.NotificationStyle.kSimTalking); GetBook(Actor, book); return true; } private static string GetBook(Sim actor, Book book) { IGameObject gameObject = null; string result; gameObject = book.Clone(); result = (gameObject as Book).Data.Title; if (!actor.Inventory.TryToAdd(gameObject)) { gameObject.Destroy(); return null; } return result; } [DoesntRequireTuning] private sealed class Definition : InteractionDefinition<Sim, LibraryRegister, TakeOutBook> { protected override string GetInteractionName(Sim actor, LibraryRegister target, InteractionObjectPair interaction) { return "Take Out Book"; } protected override bool Test(Sim actor, LibraryRegister target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { List<Book> booksOnMyLot = GetBooksOnLot(target, justFirst: true, noDuplicates: false); if (booksOnMyLot.Count <= 0||isAutonomous) { return false; } return true; } public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List<ObjectPicker.TabInfo> listObjs, out List<ObjectPicker.HeaderInfo> headers, out int NumSelectableRows) { NumSelectableRows = 1; headers = new List<ObjectPicker.HeaderInfo>(); listObjs = new List<ObjectPicker.TabInfo>(); headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 250)); List<ObjectPicker.RowInfo> list = new List<ObjectPicker.RowInfo>(); GreyedOutTooltipCallback greyedOutTooltipCallback = null; List<Book> booksOnMyLot = GetBooksOnLot(parameters.Target as LibraryRegister, justFirst: false, noDuplicates: true); foreach (Book item3 in booksOnMyLot) { if (!(item3 is BookAlchemyRecipe) && !(item3 is BookFish) && !(item3 is BookRecipe)&&!(item3 is SheetMusic) && item3.TestReadBook(parameters.Actor as Sim, parameters.Autonomous, ref greyedOutTooltipCallback)) { List<ObjectPicker.ColumnInfo> list2 = new List<ObjectPicker.ColumnInfo>(); ResourceKey objectDescKey = new ResourceKey(ResourceUtils.XorFoldHashString32("book_standard"), 23466547u, 1u); ThumbnailKey thumbnail = new ThumbnailKey(objectDescKey, ThumbnailSize.Medium, ResourceUtils.HashString32(item3.Data.GeometryState), ResourceUtils.HashString32(item3.Data.MaterialState)); MedicalJournalData medicalJournalData = item3.Data as MedicalJournalData; if (medicalJournalData != null) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, medicalJournalData.GetTitle((item3 as MedicalJournal).mOwner, medicalJournalData.CurrentEdition))); } else { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, item3.Data.Title)); } ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(item3, list2); list.Add(item); } } ObjectPicker.TabInfo item2 = new ObjectPicker.TabInfo("Coupon", Localization.LocalizeString("Ui/Caption/ObjectPicker:Books"), list); listObjs.Add(item2); } } } public static List<Book> GetBooksOnLot(GameObject target, bool justFirst, bool noDuplicates) { List<Book> list = new List<Book>(); if (target == null) { return list; } Lot lot = target.LotCurrent; Book[] objects = Queries.GetObjects<Book>(); Book b; for (int i = 0; i < objects.Length; i++) { b = objects[i]; if (b.GetOwnerLot() == lot && (justFirst || !noDuplicates || !list.Exists((Book toTest) => toTest.BookId == b.BookId))) { list.Add(b); if (justFirst) { return list; } } } return list; } public override void OnStartup() { base.OnStartup(); base.AddInteraction(TakeOutBook.Singleton); } } }
My next step (which I've been struggling with) is getting the "Buy" animation/ social interaction to take place before the book can be chosen. I used the ShoppingRegister class as a guide, and worked out that it has the interaction that you click on (Buy), which creates (instantiates?) another interaction in the Run function:
protected override bool Run() { Sim simInRole = Target.CurrentRole.SimInRole; InteractionInstance instance = BuyItemsWithRegister.BuyItemsSingleton.CreateInstance(simInRole, Actor, Actor.InheritedPriority(), base.Autonomous, base.CancellableByPlayer); Actor.InteractionQueue.PushAsContinuation(instance, mustRun: true); return true; }
And this BuyItemsWithRegister interaction is derived from the BuyWithRegister social interaction, which I think is what I need.
The BuyItemsWithRegister has the "mRegister.ShowShoppingDialog(Actor);" in the PostAnimation Function, which is the actual shopping menu, for buying and selling, which I don't want. So my thought was that
I could create an AskForBook interaction using the same format as the BuyItemsWithRegister, and instead of the ShoppingDialogue thing, I would then put my code for the list of books menu, and creating the selected book. The AskForBook interaction is called/created/instantiated (sorry, don't know the technical terms) from the Run function in the TakeOutBook interaction which is in the code above, and is the one you click on, which is a reflection of the BuyItemsWithRegister interaction being initiated from the Buy interaction (hope this makes sense).
However, when I tried this it did not work at all. Nothing happened when I clicked on "Take Out Book".
This is the code for that:
using System; using System.Collections.Generic; using System.Text; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Autonomy; using Sims3.SimIFace; using Sims3.UI; using Sims3.Gameplay.Objects.Miscellaneous; using Sims3.Gameplay.Abstracts; using Sims3.Gameplay.Objects.RabbitHoles; using Sims3.Gameplay.Objects.Register; using Sims3.Gameplay.Interfaces; using Sims3.Gameplay.Skills; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.TuningValues; using Sims3.Gameplay.Core; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Objects.Alchemy; using Sims3.Gameplay.Roles; namespace Sims3.Gameplay.Objects.Register.Zoeoemod { class LibraryRegister : BookStoreRegister { protected sealed class TakeOutBook : Interaction<Sim, LibraryRegister> { public static readonly InteractionDefinition Singleton = new Definition(); protected override bool Run() { Sim simInRole = Target.CurrentRole.SimInRole; InteractionInstance instance = AskForBook.AskForBookSingleton.CreateInstance(simInRole, Actor, Actor.InheritedPriority(), base.Autonomous, base.CancellableByPlayer); Actor.InteractionQueue.PushAsContinuation(instance, mustRun: true); return true; } [DoesntRequireTuning] private sealed class Definition : InteractionDefinition<Sim, LibraryRegister, TakeOutBook> { protected override string GetInteractionName(Sim actor, LibraryRegister target, InteractionObjectPair interaction) { return "Take Out Book"; } protected override bool Test(Sim actor, LibraryRegister target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { List<Book> booksOnMyLot = GetBooksOnLot(target, justFirst: true, noDuplicates: false); if (booksOnMyLot.Count <= 0 || isAutonomous) { return false; } return true; } } } public class AskForBook : BuyWithRegister { public class AskForBookDefinition : DefinitionBase<AskForBook> { public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List<ObjectPicker.TabInfo> listObjs, out List<ObjectPicker.HeaderInfo> headers, out int NumSelectableRows) { NumSelectableRows = 1; headers = new List<ObjectPicker.HeaderInfo>(); listObjs = new List<ObjectPicker.TabInfo>(); headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 250)); List<ObjectPicker.RowInfo> list = new List<ObjectPicker.RowInfo>(); GreyedOutTooltipCallback greyedOutTooltipCallback = null; List<Book> booksOnMyLot = GetBooksOnLot(parameters.Target as LibraryRegister, justFirst: false, noDuplicates: true); foreach (Book item3 in booksOnMyLot) { if (!(item3 is BookAlchemyRecipe) && !(item3 is BookFish) && !(item3 is BookRecipe) && !(item3 is SheetMusic) && item3.TestReadBook(parameters.Actor as Sim, parameters.Autonomous, ref greyedOutTooltipCallback)) { List<ObjectPicker.ColumnInfo> list2 = new List<ObjectPicker.ColumnInfo>(); ResourceKey objectDescKey = new ResourceKey(ResourceUtils.XorFoldHashString32("book_standard"), 23466547u, 1u); ThumbnailKey thumbnail = new ThumbnailKey(objectDescKey, ThumbnailSize.Medium, ResourceUtils.HashString32(item3.Data.GeometryState), ResourceUtils.HashString32(item3.Data.MaterialState)); MedicalJournalData medicalJournalData = item3.Data as MedicalJournalData; if (medicalJournalData != null) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, medicalJournalData.GetTitle((item3 as MedicalJournal).mOwner, medicalJournalData.CurrentEdition))); } else { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, item3.Data.Title)); } ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(item3, list2); list.Add(item); } } ObjectPicker.TabInfo item2 = new ObjectPicker.TabInfo("Coupon", Localization.LocalizeString("Ui/Caption/ObjectPicker:Books"), list); listObjs.Add(item2); } } public static readonly AskForBookDefinition AskForBookSingleton = new AskForBookDefinition(); public override void PostAnimation() { Run(); } protected override bool Run() { Book book = null; book = (GetSelectedObject() as Book); if (book == null) { return false; } Actor.ShowTNSIfSelectable("Working! - " + book.Title.ToString(), StyledNotification.NotificationStyle.kSimTalking); GetBook(Actor, book); return true; } } private static string GetBook(Sim actor, Book book) { IGameObject gameObject = null; string result; gameObject = book.Clone(); result = (gameObject as Book).Data.Title; if (!actor.Inventory.TryToAdd(gameObject)) { gameObject.Destroy(); return null; } return result; } public static List<Book> GetBooksOnLot(GameObject target, bool justFirst, bool noDuplicates) { List<Book> list = new List<Book>(); if (target == null) { return list; } Lot lot = target.LotCurrent; Book[] objects = Queries.GetObjects<Book>(); Book b; for (int i = 0; i < objects.Length; i++) { b = objects[i]; if (b.GetOwnerLot() == lot && (justFirst || !noDuplicates || !list.Exists((Book toTest) => toTest.BookId == b.BookId))) { list.Add(b); if (justFirst) { return list; } } } return list; } public override void OnStartup() { base.OnStartup(); base.AddInteraction(TakeOutBook.Singleton); } } }
I also tried adding base.AddInteraction(AskForBook.AskForBookSingleton);
but that actually meant the pie menu did not even show up anything when the register was clicked on!
So in conclusion, please help!
But seriously, if anyone could help, give some advice, I'd really appreciate it. I hope I made sense with explaining it, and if it would help for me to upload the package with one of the working/not working versions, or screenshots, let me know.
Posts: 437
Thanks: 5334 in 22 Posts
The reason pushing the interaction instance doesn't work is because it's relying on GetSelectedObjects() where there are no objects to select. The PopulatePieMenuPicker method only serves to populate an object picker dialog that is run when the interaction is selected from the pie menu; since you are no longer selecting that interaction from the pie menu, that dialog is no longer called and no object is selected.
Instead, you will need to call the object picker dialog directly from within the Run() method. To do this, copy in your existing code from PopulatePieMenuPicker, declaring listObjs, headers, and numSelectableRows as local variables within the Run() method rather than as parameters. Then, replace this:
Book book = null; book = (GetSelectedObject() as Book); if (book == null) { return false; }
With this:
List<ObjectPicker.RowInfo> selectedObjects = ObjectPickerDialog.Show([String title for your dialog box -- preferably localized!], Localization.LocalizeString("Ui/Caption/Global:Accept"), Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel"), listObjs, headers, numSelectableRows); if (selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { return false; }
This should work as intended. Let me know if you run into any more problems; I'll keep an eye on this post
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
I did what you said, however in game when I click Take Out Book, my sim just resets and I get an NRaas ErrorTrap script error for my sim
Here is my new full code:
using System; using System.Collections.Generic; using System.Text; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Autonomy; using Sims3.SimIFace; using Sims3.UI; using Sims3.Gameplay.Objects.Miscellaneous; using Sims3.Gameplay.Abstracts; using Sims3.Gameplay.Objects.RabbitHoles; using Sims3.Gameplay.Objects.Register; using Sims3.Gameplay.Interfaces; using Sims3.Gameplay.Skills; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.TuningValues; using Sims3.Gameplay.Core; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Objects.Alchemy; using Sims3.Gameplay.Roles; namespace Sims3.Gameplay.Objects.Register.Zoeoemod { class LibraryRegister : BookStoreRegister { protected sealed class TakeOutBook : Interaction<Sim, LibraryRegister> { public static readonly InteractionDefinition Singleton = new Definition(); protected override bool Run() { Sim simInRole = Target.CurrentRole.SimInRole; InteractionInstance instance = AskForBook.AskForBookSingleton.CreateInstance(simInRole, Actor, Actor.InheritedPriority(), base.Autonomous, base.CancellableByPlayer); Actor.InteractionQueue.PushAsContinuation(instance, mustRun: true); return true; } [DoesntRequireTuning] private sealed class Definition : InteractionDefinition<Sim, LibraryRegister, TakeOutBook> { protected override string GetInteractionName(Sim actor, LibraryRegister target, InteractionObjectPair interaction) { return "Take Out Book"; } protected override bool Test(Sim actor, LibraryRegister target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { List<Book> booksOnMyLot = GetBooksOnLot(target, justFirst: true, noDuplicates: false); if (booksOnMyLot.Count <= 0 || isAutonomous) { return false; } return true; } } } public class AskForBook : BuyWithRegister { public class AskForBookDefinition : DefinitionBase<AskForBook> { } public static readonly AskForBookDefinition AskForBookSingleton = new AskForBookDefinition(); public override void PostAnimation() { Run(); } protected override bool Run() { int numSelectableRows = 1; InteractionInstanceParameters parameters = new InteractionInstanceParameters(); List<ObjectPicker.HeaderInfo> headers = new List<ObjectPicker.HeaderInfo>(); List < ObjectPicker.TabInfo> listObjs = new List<ObjectPicker.TabInfo>(); headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 250)); List<ObjectPicker.RowInfo> list = new List<ObjectPicker.RowInfo>(); GreyedOutTooltipCallback greyedOutTooltipCallback = null; List<Book> booksOnMyLot = GetBooksOnLot(parameters.Target as LibraryRegister, justFirst: false, noDuplicates: true); foreach (Book item3 in booksOnMyLot) { if (!(item3 is BookAlchemyRecipe) && !(item3 is BookFish) && !(item3 is BookRecipe) && !(item3 is SheetMusic) && item3.TestReadBook(parameters.Actor as Sim, parameters.Autonomous, ref greyedOutTooltipCallback)) { List<ObjectPicker.ColumnInfo> list2 = new List<ObjectPicker.ColumnInfo>(); ResourceKey objectDescKey = new ResourceKey(ResourceUtils.XorFoldHashString32("book_standard"), 23466547u, 1u); ThumbnailKey thumbnail = new ThumbnailKey(objectDescKey, ThumbnailSize.Medium, ResourceUtils.HashString32(item3.Data.GeometryState), ResourceUtils.HashString32(item3.Data.MaterialState)); MedicalJournalData medicalJournalData = item3.Data as MedicalJournalData; if (medicalJournalData != null) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, medicalJournalData.GetTitle((item3 as MedicalJournal).mOwner, medicalJournalData.CurrentEdition))); } else { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, item3.Data.Title)); } ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(item3, list2); list.Add(item); } } ObjectPicker.TabInfo item2 = new ObjectPicker.TabInfo("Coupon", Localization.LocalizeString("Ui/Caption/ObjectPicker:Books"), list); listObjs.Add(item2); string title = "Choose Book:"; List<ObjectPicker.RowInfo> selectedObjects = ObjectPickerDialog.Show(title, Localization.LocalizeString("Ui/Caption/Global:Accept"), Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel"), listObjs, headers, numSelectableRows) ; if (selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { return false; } Actor.ShowTNSIfSelectable("Working! - " + book.Title.ToString(), StyledNotification.NotificationStyle.kSimTalking); GetBook(Actor, book); return true; } } private static string GetBook(Sim actor, Book book) { IGameObject gameObject = null; string result; gameObject = book.Clone(); result = (gameObject as Book).Data.Title; if (!actor.Inventory.TryToAdd(gameObject)) { gameObject.Destroy(); return null; } return result; } public static List<Book> GetBooksOnLot(GameObject target, bool justFirst, bool noDuplicates) { List<Book> list = new List<Book>(); if (target == null) { return list; } Lot lot = target.LotCurrent; Book[] objects = Queries.GetObjects<Book>(); Book b; for (int i = 0; i < objects.Length; i++) { b = objects[i]; if (b.GetOwnerLot() == lot && (justFirst || !noDuplicates || !list.Exists((Book toTest) => toTest.BookId == b.BookId))) { list.Add(b); if (justFirst) { return list; } } } return list; } public override void OnStartup() { base.OnStartup(); base.AddInteraction(TakeOutBook.Singleton); } } }
PS, I am planning on localizing the strings once I get the base of my mod done, but that's another journey for another day
Posts: 437
Thanks: 5334 in 22 Posts
Thank you! And yes, I'm finding it a lot easier to understand the game code this time round I did what you said, however in game when I click Take Out Book, my sim just resets and I get an NRaas ErrorTrap script error for my sim |
Can you upload the error?
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
-- Script Errors -- Object:Name: May HawleyType: Sims3.Gameplay.Actors.SimObject id: 0x7742009f15ed9160Position: (154.9410, 15.4965, 73.7489)Room id: 0Level: 0Flags: InWorld, IsUsedLot: Sims3.Gameplay.Core.LotLot Name:Lot Address: Beachfront Street, 5IsValid: TrueWorld: UserCreatedOnVacation: FalseSeason: SummerPosture: Sims3.Gameplay.Actors.Sim+StandingPostureHousehold: HawleyLotHome:Active Actor SimDescription:Name: May HawleyAge: YoungAdultGender: FemaleSimDescriptionId: 5710002013521797296LotHomeId: 9860068878451067936HomeWorld: UserCreatedProper GenealogyValid: TrueSpecies: HumanHousehold: HawleyOccult: NoneAlien: 0Career: School: Lot:Address: Mill Street, 1Skill Photography: 0Skill Social Networking: 0Trait LonerTrait PerfectionistTrait Hopeless RomanticTrait ProperTrait Equestrian Interactions: 1: AskForBook Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition UserDirectedCounter: 4Sim-Time: Sun. at 12:40 PMStart-Time: 07/14/2019 15:53:41PreLoadup-Time: 07/14/2019 15:55:15Loadup-Time: 07/14/2019 15:55:24Log-Time: 07/14/2019 15:57:51 System.NullReferenceException: A null value was found where an object instance was required. #0: 0x00003 ldfld.o in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstanceParameters:get_Target () () #1: 0x00028 call in Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook:Run () () #2: 0x000d7 callvirt in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstance:RunInteractionWithoutCleanup () () #3: 0x00344 callvirt in Sims3.Gameplay.ActorSystems.Sims3.Gameplay.ActorSystems.InteractionQueue:ProcessOneInteraction () () #4: 0x00118 callvirt in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:DoInteraction () () #5: 0x00013 call in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:Simulate () () #6: 0x00027 leave.s in ScriptCore.ScriptCore.ScriptProxy:Simulate () () Object:Name: May HawleyType: Sims3.Gameplay.Actors.SimObject id: 0x7742009f15ed9160Position: (154.9410, 15.4965, 73.7489)Room id: 0Level: 0Flags: InWorld, IsUsedLot: Sims3.Gameplay.Core.LotLot Name:Lot Address: Beachfront Street, 5IsValid: TrueWorld: UserCreatedOnVacation: FalseSeason: SummerPosture: Sims3.Gameplay.Actors.Sim+StandingPostureHousehold: HawleyLotHome:Active Actor SimDescription:Name: May HawleyAge: YoungAdultGender: FemaleSimDescriptionId: 5710002013521797296LotHomeId: 9860068878451067936HomeWorld: UserCreatedProper GenealogyValid: TrueSpecies: HumanHousehold: HawleyOccult: NoneAlien: 0Career: School: Lot:Address: Mill Street, 1Skill Photography: 0Skill Social Networking: 0Trait LonerTrait PerfectionistTrait Hopeless RomanticTrait ProperTrait Equestrian Interactions: 1: AskForBook Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition UserDirectedCounter: 5Sim-Time: Sun. at 12:40 PMStart-Time: 07/14/2019 15:53:41PreLoadup-Time: 07/14/2019 15:55:15Loadup-Time: 07/14/2019 15:55:24Log-Time: 07/14/2019 15:57:51 System.NullReferenceException: A null value was found where an object instance was required. #0: 0x00003 ldfld.o in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstanceParameters:get_Target () () #1: 0x00028 call in Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook:Run () () #2: 0x000d7 callvirt in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstance:RunInteractionWithoutCleanup () () #3: 0x00344 callvirt in Sims3.Gameplay.ActorSystems.Sims3.Gameplay.ActorSystems.InteractionQueue:ProcessOneInteraction () () #4: 0x00118 callvirt in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:DoInteraction () () #5: 0x00013 call in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:Simulate () () #6: 0x00023 callvirt in ScriptCore.ScriptCore.ScriptProxy:Simulate () () Object:Name: May HawleyType: Sims3.Gameplay.Actors.SimObject id: 0x7742009f15ed9230Position: (162.5000, 15.4999, 91.5000)Room id: 0Level: 0Flags: InWorld, IsUsedLot: Sims3.Gameplay.Core.LotLot Name:Lot Address: Mill Street, 1IsValid: TrueWorld: UserCreatedOnVacation: FalseSeason: SummerPosture: Sims3.Gameplay.Actors.Sim+StandingPostureHousehold: HawleyLotHome:Active Actor SimDescription:Name: May HawleyAge: YoungAdultGender: FemaleSimDescriptionId: 5710002013521797296LotHomeId: 9860068878451067936HomeWorld: UserCreatedProper GenealogyValid: TrueSpecies: HumanHousehold: HawleyOccult: NoneAlien: 0Career: School: Lot:Address: Mill Street, 1Skill Photography: 0Skill Social Networking: 0Trait LonerTrait PerfectionistTrait Hopeless RomanticTrait ProperTrait Equestrian Interactions: 1: Take Out Book Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+TakeOutBook+Definition Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+TakeOutBook+Definition UserDirectedCounter: 6Sim-Time: Sun. at 12:41 PMStart-Time: 07/14/2019 15:53:41PreLoadup-Time: 07/14/2019 15:55:15Loadup-Time: 07/14/2019 15:55:24Log-Time: 07/14/2019 15:58:20 System.NullReferenceException: A null value was found where an object instance was required. #0: 0x00007 callvirt in Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+TakeOutBook:Run () () #1: 0x000d7 callvirt in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstance:RunInteractionWithoutCleanup () () #2: 0x00344 callvirt in Sims3.Gameplay.ActorSystems.Sims3.Gameplay.ActorSystems.InteractionQueue:ProcessOneInteraction () () #3: 0x00118 callvirt in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:DoInteraction () () #4: 0x00013 call in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:Simulate () () #5: 0x00027 leave.s in ScriptCore.ScriptCore.ScriptProxy:Simulate () () Loaded Assemblies:00909141186213707468569206119209105436836654536141563014772344118565176681067335391536239468226596744555568479594819809870214830780050842155007792493845558128828074957500536858471AniNoFridgeShoppingLibraryModNRaasAntiMagicScroll: Version 9NRaasCareer: Version 87NRaasCupcake: Version 5NRaasDebugEnabler: Version 54NRaasErrorTrap: Version 100NRaasMasterController: Version 132NRaasMasterControllerCheats: Version 132NRaasMasterControllerExpandedTattoo: Version 122NRaasMasterControllerIntegration: Version 132NRaasMover: Version 28NRaasOverwatch: Version 118NRaasPortraitPanel: Version 33NRaasRegister: Version 80NRaasStoryProgression: Version 265NRaasStoryProgressionPopulation: Version 267NRaasTraveler: Version 82NRaasWoohooer: Version 128RealJamResortTowerRugScriptCoreSimAddonToPosePlayerSimIFaceSims3.Gameplay.Objects.CmoPoseBoxSims3GameplayObjectsSims3GameplaySystemsSims3MetadataSims3StoreObjectsStoreObjectsBakersStationStoreObjectsCraftersConsignmentStoreObjectsHotTubGrottoGeoStoreObjectsMillWheelStoreObjectsPhoneTableMidCModsuiteStoreObjectsStaircaseLandingMansionStoreObjectsTeaSetStoreObjectsTractorStoreObjectsTreeOfProsperitySystemSystem.XmlUIgranthesOMSPicarusallsorts.SalvageJunkyardObjectsicarusallsorts.ServeMealsmscorlibtalkingted
Posts: 437
Thanks: 5334 in 22 Posts
Not sure how to upload the file so I copied all of it here |
Ah, I see. Take out your local variable "parameters" in the Run() method, then change all references to that variable to instead reference the properties of the AskForBook interaction instance.
For example, this:
List<Book> booksOnMyLot = GetBooksOnLot(parameters.Target as LibraryRegister, justFirst: false, noDuplicates: true);
Should become this:
List<Book> booksOnMyLot = GetBooksOnLot(this.Target as LibraryRegister, justFirst: false, noDuplicates: true);
Hopefully, then it will at least run without throwing a script error
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Posts: 437
Thanks: 5334 in 22 Posts
Ah thank you, I'm going to bed now but I'll have a go tomorrow. Could you explain why it has to be like that? |
I assume you know how inheritance works in C#? Well, in this case, AskForBook "is-a" BuyWithRegister, which "is-a" SocialInteraction, which "is-a" Interaction, which "is-a" InteractionInstance. Any type that "is-a" InteractionInstance, including AskForBook, contains a number of properties defining the actor of the interaction, the target, and some additional tuning information, all of which are assigned when the instance is instantiated (usually, instantiation happens when the option is clicked in the pie menu, but AskForBook is instantiated when TakeOutBook is run). For example, if you were to say within AskForBook:
public void Method() { Sim sim = this.Actor; }
What you are saying is, "regardless of how many AskForBook instances are in existence, when this method runs, I want to access the assigned 'Actor' property of whichever instance of AskForBook called the method, and assign that value to this new variable of type Sim that I'm creating called 'sim.'"
Now, that's all well and good, but how are these InteractionInstance properties assigned a value in the first place? Well, the game creates an InteractionInstanceParameters object with all the necessary values that is passed to an interaction definition, which contains code to test if the interaction is valid, among other housekeeping items. If everything checks out, an "empty" instance of the interaction associated with that definition is created, and the game copies the values within the InteractionInstanceParameters object into the interaction instance proper.
All of this is a long-winded way of saying that the InteractionInstanceParameters object you created within the AskForBook interaction instance is unnecessary, and because you didn't put values into it like the game does, the game got confused trying to access a "Target" property that contained no value -- that's what the script meant when it said "a null value was found where an object instance was required." Instead, you can just refer to the instance's own properties using the "this" keyword.
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
So take 3:
Whether my sim is on the same lot as the register or not, I can click Take Out Book, and my sim has the AskToTakeBook interaction going (the interaction in the queue in top right corner switches to the bookstore clerk sim), but doesn't actually carry out the social interaction. The Choose Book menu shows up, and if I pick a book, the right book is put into my sim's inventory.
However if I click cancel, and if my sim is on a different lot to the register, the game crashes. The mini dump file says "The thread tried to read from or write to a virtual address for which it does not have the appropriate access." And the text doc:
[Build info]
Application: Sims3
BuildTime: 2015-1-6-0801
BuildUser: Unknown
BuildHost: Unknown
BuildConfig: Release
BuldVersion: 0.2.0.32
Commandline: C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\TS3.exe
[System info]
Computer name: LAPTOP-N647JD4N
Computer DNS name: LAPTOP-N647JD4N
User name: zoesk
EA_PLATFORM: Windows on X86
OS name: Windows Vista
OS version number: 6.2.9200
OS service pack:
Debugger present: no
CPU count: 4
Processor type: x86
Processor level: 6
Processor revision: 40457
Memory load: 72%
Total physical memory: 8077 Mb
Available physical memory: 2257 Mb
Total page file memory: 10765 Mb
Available page file memory: 2617 Mb
Total virtual memory: 4095 Mb
Free virtual memory: 2367 Mb
[Application info]
Language: C++
Compiler: Microsoft Visual C++ compiler, version 1400
App path: C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\TS3.exe
App version: 0.2.0.32
[Exception info]
date: 2019-07-15
time: 10.45.43
type: ACCESS_VIOLATION reading address 0x00000048
address: 0x00d89169 "C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\TS3.exe":0x0001:0x00988169
[Call stack]
C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\TS3.exe
0x00d89169
[Stack data]
0019f250 |<00>00 00 00 bc 04 3e 00 80 a0 d8 00 f4 26 fa 8f | ......>......&.. |
0019f260 | 80 dc c4 76 cc d7 29 f9 b0 f2 19 00 67 88 c4 76 | ...v..).....g..v |
0019f270 | 00 29 9b 01 b0 f2 19 00 9d 89 c3 76 00 29 9b 01 | .).........v.).. |
0019f280 | a9 89 c3 76 3c 26 fa 8f 0f 00 00 00 01 00 00 00 | ...v<&.......... |
0019f290 | 80 a0 d8 00 69 bd 74 77 84 f2 19 00 74 f2 19 00 | ....i.tw....t... |
0019f2a0 | ec f3 19 00 80 dc c4 76 0f a1 d8 00 0c 10 ee 01 | .......v........ |
0019f2b0 | 5b a1 d8 00 bc 04 3e 00 01 00 00 00 80 a0 d8 00 | [.....>......... |
0019f2c0 | 0f 00 00 00 14 f3 19 00 0c 10 ee 01 f0 31 93 03 | .............1.. |
0019f2d0 | d4 f2 19 00 bc 04 3e 00 0f 00 00 00 00 00 00 00 | ......>......... |
0019f2e0 | 00 00 00 00 00 00 00 00 00 00 00 00 1b bf c4 76 | ...............v |
0019f2f0 | bc 04 3e 00 0f 00 00 00 00 00 00 00 00 00 00 00 | ..>............. |
0019f300 | 01 00 00 00 cd ab ba dc 80 a0 d8 00 0f 00 00 00 | ................ |
0019f310 | 01 00 00 00 fc f3 19 00 ea 83 c4 76 80 a0 d8 00 | ...........v.... |
0019f320 | bc 04 3e 00 0f 00 00 00 00 00 00 00 00 00 00 00 | ..>............. |
0019f330 | 70 27 fa 8f 00 00 00 00 88 13 00 20 0f 00 00 00 | p'......... .... |
0019f340 | 01 10 ee 01 f0 31 93 03 4c f3 19 00 02 00 00 00 | .....1..L....... |
0019f350 | 00 00 00 00 07 00 00 00 b1 03 00 00 8d 02 00 00 | ................ |
0019f360 | ff ff ff ff 00 00 00 00 00 f4 19 00 bf a3 d8 00 | ................ |
0019f370 | bc 04 3e 00 b1 03 00 00 80 00 00 00 24 00 00 00 | ..>.........$... |
0019f380 | 01 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 | ............0... |
0019f390 | ff ff ff ff ff ff ff ff 3f 82 c4 76 00 00 00 00 | ........?..v.... |
0019f3a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
0019f3b0 | 00 00 00 00 48 13 03 00 00 00 00 00 12 00 00 80 | ....H........... |
0019f3c0 | 01 00 00 00 80 a0 d8 00 00 00 00 00 00 00 00 00 | ................ |
0019f3d0 | 12 00 00 80 00 00 00 00 01 00 00 00 bc 04 3e 00 | ..............>. |
0019f3e0 | 70 27 fa 8f 6f 80 3a cf 04 ec 19 00 50 f4 19 00 | p'..o.:.....P... |
0019f3f0 | 80 dc c4 76 e4 df 29 f9 00 00 00 00 60 f4 19 00 | ...v..).....`... |
0019f400 | 8a 7f c4 76 80 a0 d8 00 00 00 00 00 0f 00 00 00 | ...v............ |
0019f410 | 00 00 00 00 00 00 00 00 00 60 3b 00 01 00 00 00 | .........`;..... |
0019f420 | ec 20 fa 8f 84 f5 19 00 60 e8 76 77 7c f5 19 00 | . ......`.vw|... |
0019f430 | 90 f4 19 00 80 dc c4 76 c4 df 29 f9 00 00 00 00 | .......v..)..... |
0019f440 | bc 04 3e 00 00 00 00 00 20 f4 19 00 04 ec 19 00 | ..>..... ....... |
[Instruction data]
00d890e9 => DasmX86Dll.dll not found.
[Registers]
eip: 00d89169
eax: 00000000
ebx: 00000000
ecx: 039331f0
edx: 01ee100c
esi: 039331f0
edi: 039331f0
ebp: 003e04bc
efl: 00210212
esp: 0019f250
[Modules]
base 0x00400000 size 0x00eb5000 entry 0x012b4000 "TS3.exe" "C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\TS3.exe"
base 0x776f0000 size 0x00190000 entry 0x00000000 "ntdll.dll" "C:\WINDOWS\SYSTEM32\ntdll.dll"
base 0x744d0000 size 0x000e0000 entry 0x744e06a0 "KERNEL32.DLL" "C:\WINDOWS\System32\KERNEL32.DLL"
base 0x76210000 size 0x001e4000 entry 0x762ff4b0 "KERNELBASE.dll" "C:\WINDOWS\System32\KERNELBASE.dll"
base 0x71e70000 size 0x0009d000 entry 0x71ea81b0 "apphelp.dll" "C:\WINDOWS\SYSTEM32\apphelp.dll"
base 0x716c0000 size 0x00281000 entry 0x716db450 "AcLayers.DLL" "C:\WINDOWS\SYSTEM32\AcLayers.DLL"
base 0x76510000 size 0x000bf000 entry 0x76545660 "msvcrt.dll" "C:\WINDOWS\System32\msvcrt.dll"
base 0x76c10000 size 0x0018d000 entry 0x76c40110 "USER32.dll" "C:\WINDOWS\System32\USER32.dll"
base 0x74cf0000 size 0x00017000 entry 0x00000000 "win32u.dll" "C:\WINDOWS\System32\win32u.dll"
base 0x74c60000 size 0x00022000 entry 0x74c66ce0 "GDI32.dll" "C:\WINDOWS\System32\GDI32.dll"
base 0x746b0000 size 0x00164000 entry 0x7476be10 "gdi32full.dll" "C:\WINDOWS\System32\gdi32full.dll"
base 0x765d0000 size 0x0007d000 entry 0x765e6920 "msvcp_win.dll" "C:\WINDOWS\System32\msvcp_win.dll"
base 0x74330000 size 0x0011d000 entry 0x74361780 "ucrtbase.dll" "C:\WINDOWS\System32\ucrtbase.dll"
base 0x74ec0000 size 0x0134a000 entry 0x75035830 "SHELL32.dll" "C:\WINDOWS\System32\SHELL32.dll"
base 0x74a10000 size 0x00039000 entry 0x74a1d080 "cfgmgr32.dll" "C:\WINDOWS\System32\cfgmgr32.dll"
base 0x74a50000 size 0x00088000 entry 0x74a92c20 "shcore.dll" "C:\WINDOWS\System32\shcore.dll"
base 0x76400000 size 0x000c0000 entry 0x76419660 "RPCRT4.dll" "C:\WINDOWS\System32\RPCRT4.dll"
base 0x73fb0000 size 0x00020000 entry 0x73fbca20 "SspiCli.dll" "C:\WINDOWS\System32\SspiCli.dll"
base 0x73fa0000 size 0x0000a000 entry 0x73fa2a20 "CRYPTBASE.dll" "C:\WINDOWS\System32\CRYPTBASE.dll"
base 0x74950000 size 0x00057000 entry 0x7497f770 "bcryptPrimitives.dll" "C:\WINDOWS\System32\bcryptPrimitives.dll"
base 0x764c0000 size 0x00044000 entry 0x764caf90 "sechost.dll" "C:\WINDOWS\System32\sechost.dll"
base 0x740d0000 size 0x0025c000 entry 0x741fda70 "combase.dll" "C:\WINDOWS\System32\combase.dll"
base 0x76650000 size 0x005ba000 entry 0x76880a90 "windows.storage.dll" "C:\WINDOWS\System32\windows.storage.dll"
base 0x74450000 size 0x00078000 entry 0x7446e740 "advapi32.dll" "C:\WINDOWS\System32\advapi32.dll"
base 0x749b0000 size 0x00045000 entry 0x749c9500 "shlwapi.dll" "C:\WINDOWS\System32\shlwapi.dll"
base 0x74940000 size 0x0000f000 entry 0x74944260 "kernel.appcore.dll" "C:\WINDOWS\System32\kernel.appcore.dll"
base 0x74900000 size 0x00018000 entry 0x74907bd0 "profapi.dll" "C:\WINDOWS\System32\profapi.dll"
base 0x748b0000 size 0x00045000 entry 0x748b79a0 "powrprof.dll" "C:\WINDOWS\System32\powrprof.dll"
base 0x74c50000 size 0x00008000 entry 0x74c52e60 "FLTLIB.DLL" "C:\WINDOWS\System32\FLTLIB.DLL"
base 0x74610000 size 0x00096000 entry 0x7463d370 "OLEAUT32.dll" "C:\WINDOWS\System32\OLEAUT32.dll"
base 0x76da0000 size 0x0042b000 entry 0x76dccc70 "SETUPAPI.dll" "C:\WINDOWS\System32\SETUPAPI.dll"
base 0x72760000 size 0x00018000 entry 0x72762660 "MPR.dll" "C:\WINDOWS\SYSTEM32\MPR.dll"
base 0x66680000 size 0x00003000 entry 0x00000000 "sfc.dll" "C:\WINDOWS\SYSTEM32\sfc.dll"
base 0x70f10000 size 0x0006d000 entry 0x70f26e20 "WINSPOOL.DRV" "C:\WINDOWS\SYSTEM32\WINSPOOL.DRV"
base 0x70d90000 size 0x00180000 entry 0x70dfc830 "PROPSYS.dll" "C:\WINDOWS\SYSTEM32\PROPSYS.dll"
base 0x72780000 size 0x00030000 entry 0x7278cc00 "IPHLPAPI.DLL" "C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL"
base 0x70b60000 size 0x00019000 entry 0x70b69630 "bcrypt.dll" "C:\WINDOWS\SYSTEM32\bcrypt.dll"
base 0x725e0000 size 0x00010000 entry 0x725e6ad0 "sfc_os.DLL" "C:\WINDOWS\SYSTEM32\sfc_os.DLL"
base 0x77240000 size 0x00026000 entry 0x772448a0 "IMM32.DLL" "C:\WINDOWS\System32\IMM32.DLL"
base 0x778d0000 size 0x0009a000 entry 0x778dbe0a "Activation.dll" "C:\Program Files (x86)\Origin Games\The Sims 3\Game\Bin\Core\Activation.dll"
base 0x77a60000 size 0x00069000 entry 0x77a93cf4 "MSVCP100.dll" "C:\WINDOWS\SYSTEM32\MSVCP100.dll"
base 0x77bc0000 size 0x000bf000 entry 0x77bd1dfc "MSVCR100.dll" "C:\WINDOWS\SYSTEM32\MSVCR100.dll"
base 0x6a460000 size 0x0016f000 entry 0x6a4d7f30 "d3d9.dll" "C:\WINDOWS\SYSTEM32\d3d9.dll"
base 0x72620000 size 0x00023000 entry 0x72624e80 "dwmapi.dll" "C:\WINDOWS\SYSTEM32\dwmapi.dll"
base 0x03310000 size 0x00267000 entry 0x0352af6c "d3dx9_31.dll" "C:\WINDOWS\SYSTEM32\d3dx9_31.dll"
base 0x50750000 size 0x000ea000 entry 0x50763030 "DDRAW.dll" "C:\WINDOWS\SYSTEM32\DDRAW.dll"
base 0x6a3c0000 size 0x00098000 entry 0x6a3efeb0 "dxgi.dll" "C:\WINDOWS\SYSTEM32\dxgi.dll"
base 0x52820000 size 0x00007000 entry 0x52822020 "DCIMAN32.dll" "C:\WINDOWS\SYSTEM32\DCIMAN32.dll"
base 0x72f20000 size 0x00454000 entry 0x7324d400 "WININET.dll" "C:\WINDOWS\SYSTEM32\WININET.dll"
base 0x73fd0000 size 0x000fc000 entry 0x74002620 "ole32.dll" "C:\WINDOWS\System32\ole32.dll"
base 0x74a00000 size 0x00006000 entry 0x74a01470 "PSAPI.DLL" "C:\WINDOWS\System32\PSAPI.DLL"
base 0x526f0000 size 0x00087000 entry 0x52720dce "MSVCP80.dll" "C:\WINDOWS\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.9445_none_d08c58b4442ba54f\MSVCP80.dll"
base 0x52870000 size 0x0009b000 entry 0x5287232b "MSVCR80.dll" "C:\WINDOWS\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.9445_none_d08c58b4442ba54f\MSVCR80.dll"
base 0x771d0000 size 0x00067000 entry 0x771e6690 "WS2_32.dll" "C:\WINDOWS\System32\WS2_32.dll"
base 0x71260000 size 0x00017000 entry 0x00000000 "USP10.dll" "C:\WINDOWS\SYSTEM32\USP10.dll"
base 0x72240000 size 0x00182000 entry 0x722788c0 "dbghelp.dll" "C:\WINDOWS\SYSTEM32\dbghelp.dll"
base 0x733f0000 size 0x00008000 entry 0x733f17e0 "VERSION.dll" "C:\WINDOWS\SYSTEM32\VERSION.dll"
base 0x71950000 size 0x00013000 entry 0x71951df0 "NETAPI32.dll" "C:\WINDOWS\SYSTEM32\NETAPI32.dll"
base 0x71980000 size 0x00081000 entry 0x719af290 "DSOUND.dll" "C:\WINDOWS\SYSTEM32\DSOUND.dll"
base 0x72ed0000 size 0x00024000 entry 0x72ed4e30 "WINMM.dll" "C:\WINDOWS\SYSTEM32\WINMM.dll"
base 0x725f0000 size 0x00023000 entry 0x725f8820 "winmmbase.dll" "C:\WINDOWS\SYSTEM32\winmmbase.dll"
base 0x537d0000 size 0x0003f000 entry 0x53803000 "glu32.dll" "C:\WINDOWS\SYSTEM32\glu32.dll"
base 0x77f20000 size 0x000d9000 entry 0x77fcddc0 "OPENGL32.dll" "C:\WINDOWS\SYSTEM32\OPENGL32.dll"
base 0x55130000 size 0x00007000 entry 0x55131850 "xinput9_1_0.dll" "C:\WINDOWS\SYSTEM32\xinput9_1_0.dll"
base 0x71fc0000 size 0x00056000 entry 0x71fcd1d0 "mswsock.dll" "C:\WINDOWS\system32\mswsock.dll"
base 0x72650000 size 0x0007c000 entry 0x7268a5c0 "uxtheme.dll" "C:\WINDOWS\system32\uxtheme.dll"
base 0x67410000 size 0x02e93000 entry 0x67931413 "igd9dxva32.dll" "C:\WINDOWS\System32\DriverStore\FileRepository\ki126950.inf_amd64_fa7f56314967630d\igd9dxva32.dll"
base 0x74d10000 size 0x00196000 entry 0x74d69d90 "crypt32.dll" "C:\WINDOWS\System32\crypt32.dll"
base 0x74eb0000 size 0x0000e000 entry 0x74eb5400 "MSASN1.dll" "C:\WINDOWS\System32\MSASN1.dll"
base 0x77270000 size 0x00047000 entry 0x7728a500 "WINTRUST.DLL" "C:\WINDOWS\System32\WINTRUST.DLL"
base 0x74920000 size 0x00019000 entry 0x749264c0 "imagehlp.dll" "C:\WINDOWS\System32\imagehlp.dll"
base 0x72050000 size 0x00013000 entry 0x72056c10 "CRYPTSP.dll" "C:\WINDOWS\SYSTEM32\CRYPTSP.dll"
base 0x72020000 size 0x0002f000 entry 0x7202e260 "rsaenh.dll" "C:\WINDOWS\system32\rsaenh.dll"
base 0x77400000 size 0x00083000 entry 0x77420620 "clbcatq.dll" "C:\WINDOWS\System32\clbcatq.dll"
base 0x52840000 size 0x00027000 entry 0x52847f30 "winbrand.dll" "C:\WINDOWS\system32\winbrand.dll"
base 0x70f80000 size 0x00022000 entry 0x70f89b40 "DEVOBJ.dll" "C:\WINDOWS\SYSTEM32\DEVOBJ.dll"
base 0x54af0000 size 0x00010000 entry 0x54af25c0 "DEVRTL.dll" "C:\WINDOWS\SYSTEM32\DEVRTL.dll"
base 0x53810000 size 0x00017000 entry 0x53819510 "SPINF.dll" "C:\WINDOWS\SYSTEM32\SPINF.dll"
base 0x52430000 size 0x000cf000 entry 0x52462e90 "drvstore.dll" "C:\WINDOWS\SYSTEM32\drvstore.dll"
base 0x721f0000 size 0x0001e000 entry 0x721f8c70 "gpapi.dll" "C:\WINDOWS\SYSTEM32\gpapi.dll"
base 0x775e0000 size 0x00007000 entry 0x775e1f90 "NSI.dll" "C:\WINDOWS\System32\NSI.dll"
base 0x521e0000 size 0x00171000 entry 0x5228e851 "nvspcap.dll" "C:\WINDOWS\system32\nvspcap.dll"
base 0x723d0000 size 0x000b0000 entry 0x72418c80 "WINHTTP.dll" "C:\WINDOWS\SYSTEM32\WINHTTP.dll"
base 0x73a80000 size 0x0000f000 entry 0x73a82be0 "WTSAPI32.dll" "C:\WINDOWS\SYSTEM32\WTSAPI32.dll"
base 0x50c60000 size 0x0041d000 entry 0x50f6f13b "nvapi.dll" "C:\WINDOWS\system32\nvapi.dll"
base 0x64220000 size 0x019f2000 entry 0x6484630d "igc32.dll" "C:\WINDOWS\System32\DriverStore\FileRepository\ki126950.inf_amd64_fa7f56314967630d\igc32.dll"
base 0x54050000 size 0x0000d000 entry 0x54056ff0 "XInput1_4.dll" "C:\WINDOWS\SYSTEM32\XInput1_4.dll"
base 0x56cf0000 size 0x0005a000 entry 0x56d37690 "inputhost.dll" "C:\WINDOWS\SYSTEM32\inputhost.dll"
base 0x63d30000 size 0x000d6000 entry 0x63da72b0 "wintypes.dll" "C:\WINDOWS\SYSTEM32\wintypes.dll"
base 0x56c60000 size 0x0008b000 entry 0x56cb69c0 "CoreMessaging.dll" "C:\WINDOWS\SYSTEM32\CoreMessaging.dll"
base 0x56a00000 size 0x0025d000 entry 0x56a61690 "CoreUIComponents.dll" "C:\WINDOWS\SYSTEM32\CoreUIComponents.dll"
base 0x71f10000 size 0x00029000 entry 0x71f17fa0 "ntmarta.dll" "C:\WINDOWS\SYSTEM32\ntmarta.dll"
base 0x77490000 size 0x00143000 entry 0x774eddd0 "MSCTF.dll" "C:\WINDOWS\System32\MSCTF.dll"
base 0x52580000 size 0x000c5000 entry 0x525823e0 "nvldumd.dll" "C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvldumd.dll"
base 0x072e0000 size 0x00efb000 entry 0x07a86300 "nvd3dum.dll" "C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvd3dum.dll"
base 0x721c0000 size 0x00026000 entry 0x721cde60 "cryptnet.dll" "C:\WINDOWS\SYSTEM32\cryptnet.dll"
base 0x55dc0000 size 0x001a3000 entry 0x55edde40 "igdumdim32.dll" "C:\WINDOWS\System32\DriverStore\FileRepository\ki126950.inf_amd64_fa7f56314967630d\igdumdim32.dll"
base 0x6a5d0000 size 0x00228000 entry 0x6a78d800 "iertutil.dll" "C:\WINDOWS\SYSTEM32\iertutil.dll"
base 0x605c0000 size 0x00011000 entry 0x605c3cb0 "ondemandconnroutehelper.dll" "C:\WINDOWS\SYSTEM32\ondemandconnroutehelper.dll"
base 0x60550000 size 0x00008000 entry 0x605521c0 "WINNSI.DLL" "C:\WINDOWS\SYSTEM32\WINNSI.DLL"
base 0x5edc0000 size 0x000d8000 entry 0x5edcf9e0 "rasapi32.dll" "C:\WINDOWS\SYSTEM32\rasapi32.dll"
base 0x5ed00000 size 0x0002a000 entry 0x5ed03270 "rasman.dll" "C:\WINDOWS\SYSTEM32\rasman.dll"
base 0x605f0000 size 0x0008e000 entry 0x605fd0b0 "mscms.dll" "C:\WINDOWS\SYSTEM32\mscms.dll"
base 0x73a90000 size 0x00021000 entry 0x73a982a0 "USERENV.dll" "C:\WINDOWS\SYSTEM32\USERENV.dll"
base 0x605e0000 size 0x0000c000 entry 0x605e57f0 "ColorAdapterClient.dll" "C:\WINDOWS\SYSTEM32\ColorAdapterClient.dll"
base 0x72130000 size 0x00014000 entry 0x72133b10 "dhcpcsvc.DLL" "C:\WINDOWS\SYSTEM32\dhcpcsvc.DLL"
base 0x605b0000 size 0x00008000 entry 0x605b1da0 "DPAPI.DLL" "C:\WINDOWS\SYSTEM32\DPAPI.DLL"
base 0x710c0000 size 0x0019d000 entry 0x71154220 "urlmon.dll" "C:\WINDOWS\SYSTEM32\urlmon.dll"
base 0x527a0000 size 0x0003e000 entry 0x527a9e70 "icm32.dll" "C:\WINDOWS\SYSTEM32\icm32.dll"
base 0x726d0000 size 0x0008e000 entry 0x726e15c0 "DNSAPI.dll" "C:\WINDOWS\SYSTEM32\DNSAPI.dll"
base 0x72180000 size 0x00008000 entry 0x72181960 "rasadhlp.dll" "C:\Windows\System32\rasadhlp.dll"
base 0x72070000 size 0x0004f000 entry 0x72086ad0 "fwpuclnt.dll" "C:\WINDOWS\System32\fwpuclnt.dll"
base 0x71f50000 size 0x0006a000 entry 0x71f700c0 "schannel.dll" "C:\WINDOWS\System32\schannel.dll"
base 0x72150000 size 0x00010000 entry 0x721530f0 "mskeyprotect.dll" "C:\WINDOWS\SYSTEM32\mskeyprotect.dll"
base 0x71060000 size 0x0001f000 entry 0x710685f0 "ncrypt.dll" "C:\WINDOWS\SYSTEM32\ncrypt.dll"
base 0x71030000 size 0x0002d000 entry 0x71048250 "NTASN1.dll" "C:\WINDOWS\SYSTEM32\NTASN1.dll"
base 0x71010000 size 0x0001b000 entry 0x71019ad0 "ncryptsslp.dll" "C:\WINDOWS\system32\ncryptsslp.dll"
base 0x53b10000 size 0x0000a000 entry 0x53b12720 "netbios.dll" "C:\WINDOWS\SYSTEM32\netbios.dll"
base 0x641c0000 size 0x0005c000 entry 0x641e2ee0 "MMDevApi.dll" "C:\WINDOWS\System32\MMDevApi.dll"
base 0x6a2b0000 size 0x0003b000 entry 0x6a2bd2c0 "wdmaud.drv" "C:\WINDOWS\SYSTEM32\wdmaud.drv"
base 0x641b0000 size 0x00007000 entry 0x641b1f00 "ksuser.dll" "C:\WINDOWS\SYSTEM32\ksuser.dll"
base 0x641a0000 size 0x00008000 entry 0x641a1a70 "AVRT.dll" "C:\WINDOWS\SYSTEM32\AVRT.dll"
base 0x63e10000 size 0x000fb000 entry 0x63e502d0 "AUDIOSES.DLL" "C:\WINDOWS\SYSTEM32\AUDIOSES.DLL"
base 0x63d20000 size 0x0000a000 entry 0x63d24320 "msacm32.drv" "C:\WINDOWS\SYSTEM32\msacm32.drv"
base 0x63d00000 size 0x00019000 entry 0x63d04440 "MSACM32.dll" "C:\WINDOWS\SYSTEM32\MSACM32.dll"
base 0x63cc0000 size 0x00008000 entry 0x63cc1970 "midimap.dll" "C:\WINDOWS\SYSTEM32\midimap.dll"
base 0x56dd0000 size 0x000d9000 entry 0x56e29080 "Windows.UI.dll" "C:\Windows\System32\Windows.UI.dll"
base 0x56d50000 size 0x0007d000 entry 0x56d801e0 "TextInputFramework.dll" "C:\Windows\System32\TextInputFramework.dll"
base 0x72160000 size 0x00013000 entry 0x721620a0 "dhcpcsvc6.DLL" "C:\WINDOWS\SYSTEM32\dhcpcsvc6.DLL"
base 0x60fa0000 size 0x00011000 entry 0x60fa2a60 "napinsp.dll" "C:\WINDOWS\system32\napinsp.dll"
base 0x60f80000 size 0x00016000 entry 0x60f831f0 "pnrpnsp.dll" "C:\WINDOWS\system32\pnrpnsp.dll"
base 0x60f60000 size 0x00013000 entry 0x60f65910 "NLAapi.dll" "C:\WINDOWS\system32\NLAapi.dll"
base 0x60f50000 size 0x0000c000 entry 0x60f51930 "winrnr.dll" "C:\WINDOWS\System32\winrnr.dll"
[Register memory]
ecx 039331f0 |<00>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
03933200 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
edx 01ee1000 | <??>?? ?? ?? | ???? |
01ee1010 | ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? | ???????????????? |
01ee1020 | ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? | ???????????? |
esi 039331f0 |<00>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
03933200 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
edi 039331f0 |<00>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
03933200 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ |
ebp 003e04b0 | <??>?? ?? ?? | ???? |
003e04c0 | ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? | ???????????????? |
003e04d0 | ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? | ???????????? |
[Extra]
ScriptHeap: 72.25MB/81.96MB (12); 7.32MB
If my sim is on the same lot and I click cancel at the object picker menu, I get a script error. I actually have two at different points, one says:
<?xml version="1.0" encoding="UTF-8"?>
-<NRaas.ErrorTrap>
<ModVersion value="100"/>
<BuildVersion value="0.2.0.32"/>
<Installed value="BaseGame, EP1, EP2, EP3, EP4, EP5, SP5, EP6, SP7, EP7, EP8, EP9, EP10"/>
<Enumerator value="1"/>
<Content> -- Correction Logs -- Destroyed Object Found: Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister Loaded Assemblies:00909141186213707468569206119209105436836654536141563014772344118565176681067335391536239468226596744555568479594819809870214830780050842155007792493845558128828074957500536858471AniNoFridgeShoppingLibraryModNRaasAntiMagicScroll: Version 9NRaasCareer: Version 87NRaasCupcake: Version 5NRaasDebugEnabler: Version 54NRaasErrorTrap: Version 100NRaasMasterController: Version 132NRaasMasterControllerCheats: Version 132NRaasMasterControllerExpandedTattoo: Version 122NRaasMasterControllerIntegration: Version 132NRaasMover: Version 28NRaasOverwatch: Version 118NRaasPortraitPanel: Version 33NRaasRegister: Version 80NRaasStoryProgression: Version 265NRaasStoryProgressionPopulation: Version 267NRaasTraveler: Version 82NRaasWoohooer: Version 128RealJamResortTowerRugScriptCoreSimAddonToPosePlayerSimIFaceSims3.Gameplay.Objects.CmoPoseBoxSims3GameplayObjectsSims3GameplaySystemsSims3MetadataSims3StoreObjectsStoreObjectsBakersStationStoreObjectsCraftersConsignmentStoreObjectsHotTubGrottoGeoStoreObjectsMillWheelStoreObjectsPhoneTableMidCModsuiteStoreObjectsStaircaseLandingMansionStoreObjectsTeaSetStoreObjectsTractorStoreObjectsTreeOfProsperitySystemSystem.XmlUIgranthesOMSPicarusallsorts.SalvageJunkyardObjectsicarusallsorts.ServeMealsmscorlibtalkingted </Content>
</NRaas.ErrorTrap>
and the other is the same as last time I think but I'll copy it here just in case:
-- Script Errors -- Object:Name: May HawleyType: Sims3.Gameplay.Actors.SimObject id: 0x7742009f15ed9c60Position: (158.8797, 15.5005, 74.8294)Room id: 0Level: 0Flags: InWorld, IsUsedLot: Sims3.Gameplay.Core.LotLot Name:Lot Address: Beachfront Street, 5IsValid: TrueWorld: UserCreatedOnVacation: FalseSeason: SummerPosture: Sims3.Gameplay.Actors.Sim+StandingPostureHousehold: HawleyLotHome:Active Actor SimDescription:Name: May HawleyAge: YoungAdultGender: FemaleSimDescriptionId: 5710002013521797296LotHomeId: 9860068878451067936HomeWorld: UserCreatedProper GenealogyValid: TrueSpecies: HumanHousehold: HawleyOccult: NoneAlien: 0Career: School: Lot:Address: Mill Street, 1Skill Photography: 0Skill Social Networking: 0Trait LonerTrait PerfectionistTrait Hopeless RomanticTrait ProperTrait Equestrian Interactions: 1: AskForBook Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook+AskForBookDefinition UserDirectedCounter: 1Sim-Time: Sun. at 3:12 PMStart-Time: 07/15/2019 10:55:31PreLoadup-Time: 07/15/2019 10:57:32Loadup-Time: 07/15/2019 10:57:40Log-Time: 07/15/2019 11:08:58 System.NullReferenceException: A null value was found where an object instance was required. #0: 0x00134 callvirt in Sims3.Gameplay.Objects.Register.Zoeoemod.LibraryRegister+AskForBook:Run () () #1: 0x000db stloc.u1 in Sims3.Gameplay.Interactions.Sims3.Gameplay.Interactions.InteractionInstance:RunInteractionWithoutCleanup () () #2: 0x00348 stloc.u1 in Sims3.Gameplay.ActorSystems.Sims3.Gameplay.ActorSystems.InteractionQueue:ProcessOneInteraction () () #3: 0x0011c stfld.u1 in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:DoInteraction () () #4: 0x00015 br.s in Sims3.Gameplay.Actors.Sims3.Gameplay.Actors.Sim:Simulate () () #5: 0x00027 leave.s in ScriptCore.ScriptCore.ScriptProxy:Simulate () () Loaded Assemblies:00909141186213707468569206119209105436836654536141563014772344118565176681067335391536239468226596744555568479594819809870214830780050842155007792493845558128828074957500536858471AniNoFridgeShoppingLibraryModNRaasAntiMagicScroll: Version 9NRaasCareer: Version 87NRaasCupcake: Version 5NRaasDebugEnabler: Version 54NRaasErrorTrap: Version 100NRaasMasterController: Version 132NRaasMasterControllerCheats: Version 132NRaasMasterControllerExpandedTattoo: Version 122NRaasMasterControllerIntegration: Version 132NRaasMover: Version 28NRaasOverwatch: Version 118NRaasPortraitPanel: Version 33NRaasRegister: Version 80NRaasStoryProgression: Version 265NRaasStoryProgressionPopulation: Version 267NRaasTraveler: Version 82NRaasWoohooer: Version 128RealJamResortTowerRugScriptCoreSimAddonToPosePlayerSimIFaceSims3.Gameplay.Objects.CmoPoseBoxSims3GameplayObjectsSims3GameplaySystemsSims3MetadataSims3StoreObjectsStoreObjectsBakersStationStoreObjectsCraftersConsignmentStoreObjectsHotTubGrottoGeoStoreObjectsMillWheelStoreObjectsPhoneTableMidCModsuiteStoreObjectsStaircaseLandingMansionStoreObjectsTeaSetStoreObjectsTractorStoreObjectsTreeOfProsperitySystemSystem.XmlUIgranthesOMSPicarusallsorts.SalvageJunkyardObjectsicarusallsorts.ServeMealsmscorlibtalkingted
Another thing which might be the problem, was that when I changed "parameters.Target as LibraryRegister" to "this.Target as LibraryRegister", there was an error "Cannot convert type Sims3.Gameplay.Actors.Sim to Sims3.Gameplay.Objects.Register.ZoeoeMod.LibraryRegister" so I removed the "as LibraryRegister". I'm guessing it is something to do with the fact the social interaction has to have a target as a sim, not an object?
I think I will try changing the GetBooksOnLot to use the Sim as the target too, rather than the register, and I'm thinking it should work because the sim should be on the same lot as the register? But perhaps there's a more robust way, as I feel like there would be problems if the sim isn't on lot or there hasn't been a sim assigned to the role yet...
[edit: did not work, the same thing happens, except it also crashes when object picker menu is cancelled and sim is on the same lot]
Thanks again for helping
Posts: 437
Thanks: 5334 in 22 Posts
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Update! It works! (Almost...) Renaming the Run Method seemed to do the trick. The only problem, however, is that if I click cancel at the object picker menu, I get a script error my sim , who resets and the error file says "A null value was found where an object instance was required"
Would it be worth doing using try {} catch {} or better to use the code that deals with cancelling?
Posts: 437
Thanks: 5334 in 22 Posts
I will try. Do you know what I should do about the different targets? If I use the target as Sim then I had to create a second GetBooksOnLot function with the target type as Sim rather than GameObject for the parameters, as in the test function in the Takeout Book interaction calls it with target as the Game object. As I said in my last post this still caused it to crash. So in the AskForBook class, should the target be the register or the sim? Is it even possible for it to be the register if it's derived from a social interaction? |
Yes, the target of TakeOutBook is still the register object, but the target of AskForBook is the Sim operating the register. At the beginning of your Test() method in AskForBookDefinition, add this:
if (!ShoppingRegister.TestIfSocialValid(actor, target)) { return false; }
And in the beginning of the Test() method of your TakeOutBookDefinition, add this:
if (!target.TestInteractionAvailability()) { return false; }
These are test methods in the game code that will check whether the sim managing the register is valid and whether the two are on the same lot; if everything checks out, then the definition will do your checks to see if there are any books on that lot.
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Posts: 437
Thanks: 5334 in 22 Posts
Yes thanks, the only problem now is when I cancel the object picker dialogue it crashes as there's no book chosen. Not sure how to error handle this, checking it's not null doesn't work. |
Crashes? As in, crash-to-desktop? I don't know how that could be happening.
The ObjectPickerDialog returns null if the cancel button is clicked. Are you checking that by using something like this?
if (selectedObjects == null || selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { return false; }
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
if (selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { Actor.ShowTNSIfSelectable("There are no books!", StyledNotification.NotificationStyle.kGameMessageNegative); } else { if (!(selectedObjects == null)) { Actor.ShowTNSIfSelectable("Working! - " + book.Title.ToString(), StyledNotification.NotificationStyle.kSimTalking); GetBook(Actor, book); } }
Posts: 437
Thanks: 5334 in 22 Posts
Woops I meant a script error, not crashes, don't know why I said that... I do have a check for it being null and it is still giving a script error for my sim when I click cancel |
I think there's another constructor for the ObjectPickerDialog that can be used to disable the cancel button. Try this instead:
List<ObjectPicker.RowInfo> selectedObjects = ObjectPickerDialog.Show(true, ModalDialog.PauseMode.PauseSimulator, title, Localization.LocalizeString("Ui/Caption/Global:Accept"), Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel"), listObjs, headers, numSelectableRows, new Vector2(-1f, -1f) , false, null, true, true);
Be sure to test what happens if the okay button is clicked and nothing is selected, as well.
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
For the next part, I'd really like to have a return book interaction. Is there a way to sort of tag the books taken out as taken from a register, so it is only possible to return the books taken from a register?
Thanks
Posts: 437
Thanks: 5334 in 22 Posts
Yep that works for blanking out the cancel button, and the okay button is blanked out until a book is selected anyway. I know it's a small thing, but do you think it is possible to allow for cancelling? If not, it doesn't really matter. For the next part, I'd really like to have a return book interaction. Is there a way to sort of tag the books taken out as taken from a register, so it is only possible to return the books taken from a register? Thanks |
I think the best way to do what you’re thinking of doing is by creating a new List<Book> inside your LibraryRegister class, outside of your interaction classes. That way, your AskForBook interaction will be able to add checked-out books to that list. When you make your “Return Book” interaction, you can have a test in your definition such that only Sims with a book in their inventory that is contained in the List<Book> will be allowed to return that book. When the interaction is run, the book is removed from the list and from the Sim’s inventory. This list will be on a per-register basis, so a Sim cannot return a book from one library at another’s register.
There are three things you’ll need to watch out for in such a system. What happens when a book is sold from a Sim’s inventory? Will the list be persistable (i.e. will the data survive saving/reloading)? Finally, what happens when a Sim travels with the library books still in their inventory? Will they still be able to return them upon returning home?
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Posts: 437
Thanks: 5334 in 22 Posts
Ahhhh there's always so much more to consider than anticipated. Regarding the books being sold, is it possible to force the books to be unsellable and perhaps even impossible to remove from the inventory, apart from when your sim is directly reading the book? Kind of like the pager thing that sims get in the law enforcement career and such? |
I'm honestly not sure if such a thing is possible without creating a custom book class, which I do not recommend doing. I suppose you could add an event listener to the kSoldObject, then, if the object sold is a book in any LibraryRegister's list, a fine would be assessed to the Sim's household. However, this would be diving into the realm of pure scripting, with all the instantiators and OnWorldLoadFinished delegates that implies.
That's the only real issue that I can think of. The register lists should be persistable, and travel shouldn't affect anything, but you never can know until you test
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Thanks for all your help though
It's great I got this far
Posts: 562
Thanks: 3599 in 11 Posts
Here is the code in the Run Function:
int numSelectableRows = 1; List<ObjectPicker.HeaderInfo> headers = new List<ObjectPicker.HeaderInfo>(); List<ObjectPicker.TabInfo> listObjs = new List<ObjectPicker.TabInfo>(); headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 250)); List<ObjectPicker.RowInfo> list = new List<ObjectPicker.RowInfo>(); List<Book> booksCanReturn = booksTaken; foreach (Book item3 in booksTaken) { bookOwner.TryGetValue(item3, out Sim sim); if (sim == Actor) { List<ObjectPicker.ColumnInfo> list2 = new List<ObjectPicker.ColumnInfo>(); ResourceKey objectDescKey = new ResourceKey(ResourceUtils.XorFoldHashString32("book_standard"), 23466547u, 1u); ThumbnailKey thumbnail = new ThumbnailKey(objectDescKey, ThumbnailSize.Medium, ResourceUtils.HashString32(item3.Data.GeometryState), ResourceUtils.HashString32(item3.Data.MaterialState)); MedicalJournalData medicalJournalData = item3.Data as MedicalJournalData; if (medicalJournalData != null) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, medicalJournalData.GetTitle((item3 as MedicalJournal).mOwner, medicalJournalData.CurrentEdition))); } else { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, item3.Data.Title)); } ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(item3, list2); list.Add(item); } } ObjectPicker.TabInfo item2 = new ObjectPicker.TabInfo("Coupon", Localization.LocalizeString("Ui/Caption/ObjectPicker:Books"), list); listObjs.Add(item2); string title = "Return Book"; List<ObjectPicker.RowInfo> selectedObjects = ObjectPickerDialog.Show(title, Localization.LocalizeString("Ui/Caption/Global:Accept"), Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel"), listObjs, headers, numSelectableRows) ; if (selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { return false; } try { book.Destroy(); booksTaken.Remove(book); return true; } catch { return false; }
I also used a try catch which solved the cancelling problem
Posts: 437
Thanks: 5334 in 22 Posts
So I have been adding a return books immediate interaction, using the List of the books taken out, as well as a dictionary with the book as the key and the sim who took it out as the value, but when I destroy the book selected, it's still there... Here is the code in the Run Function:
Code:
int numSelectableRows = 1; List<ObjectPicker.HeaderInfo> headers = new List<ObjectPicker.HeaderInfo>(); List<ObjectPicker.TabInfo> listObjs = new List<ObjectPicker.TabInfo>(); headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 250)); List<ObjectPicker.RowInfo> list = new List<ObjectPicker.RowInfo>(); List<Book> booksCanReturn = booksTaken; foreach (Book item3 in booksTaken) { bookOwner.TryGetValue(item3, out Sim sim); if (sim == Actor) { List<ObjectPicker.ColumnInfo> list2 = new List<ObjectPicker.ColumnInfo>(); ResourceKey objectDescKey = new ResourceKey(ResourceUtils.XorFoldHashString32("book_standard"), 23466547u, 1u); ThumbnailKey thumbnail = new ThumbnailKey(objectDescKey, ThumbnailSize.Medium, ResourceUtils.HashString32(item3.Data.GeometryState), ResourceUtils.HashString32(item3.Data.MaterialState)); MedicalJournalData medicalJournalData = item3.Data as MedicalJournalData; if (medicalJournalData != null) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, medicalJournalData.GetTitle((item3 as MedicalJournal).mOwner, medicalJournalData.CurrentEdition))); } else { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, item3.Data.Title)); } ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(item3, list2); list.Add(item); } } ObjectPicker.TabInfo item2 = new ObjectPicker.TabInfo("Coupon", Localization.LocalizeString("Ui/Caption/ObjectPicker:Books"), list); listObjs.Add(item2); string title = "Return Book"; List<ObjectPicker.RowInfo> selectedObjects = ObjectPickerDialog.Show(title, Localization.LocalizeString("Ui/Caption/Global:Accept"), Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel"), listObjs, headers, numSelectableRows) ; if (selectedObjects.Count == 0 || !(selectedObjects[0].Item is Book book)) { return false; } try { book.Destroy(); booksTaken.Remove(book); return true; } catch { return false; } I also used a try catch which solved the cancelling problem |
Is the book removed from the register's list of checked-out books? If not, then you're running into a script error that's been silenced by your try-catch block -- one reason why I usually don't use try-catches in my mods.
You could try running book.Dispose() after book.Destroy() just to make sure that it's been fully nuked from the game: see here for more info. Also, I'd remove the book from the list before removing it from the game, just to be safe.
Regarding some code refactoring you could do, you have a variable "booksCanReturn" that goes completely unused and can be removed. Additionally, so far as I can tell, there is no reason to have both a list and a dictionary managing checked-out books; you can use one or the other, but having both seems redundant and unnecessary.
I've found that storing Sim objects in persistable data structures is very unreliable. This is because of the way Sim objects inherently function -- they are essentially "blank slates" with scripting data slapped onto them. Whenever a Sim travels, or is hard-reset by mods like NRaas MasterController, the game literally destroys the Sim object, creates an entirely new Sim object, and copies the critical data over; as far as the code is concerned, that Sim is no longer the "same" Sim it originally was, so any tests you would do with that Sim would return false.
Instead, if you go the dictionary route, make it a Dictionary<Book, ulong>, and then use the Sim.SimDescription.SimDescriptionId property as the value. That way, the book will be tied to the Sim's permanent data, rather than the Sim object itself.
Another thing to consider: the way this works, there will be two copies of any given book: one that is checked-out by a Sim and another that remains in the library. I don't know if there's a way to facilitate moving books from the library into a Sim's inventory and back again -- it may be more trouble than it's worth. Still, something to think about
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Posts: 562
Thanks: 3599 in 11 Posts
Woops I didn't notice how I used the lists, and I remember thinking I could just use the dictionary but didn't think it through. I wanted to have the dictionary so only the sim who takes out the book can return it, not sure if i could do that with the list.
Thanks for the advice about the Sim thing, I'll change that.
Originally I was thinking of having the books be moved in that way, and I can't remember what I did at first but one way I implemented it ended having any book that was taken out was removed from the list of books you can take out, but it was still in the bookshelf. So I was happier with however I made it now. But that also makes me wonder about how the books are saved, like do they also have the problems that sims do, where a copy might be made to replace it, or not? I thought that could be the reason the books were removed from the list but not from the sim's inventory but I didn't test it out.
Posts: 562
Thanks: 3599 in 11 Posts
Who Posted
|