PDA

View Full Version : General Notebook - Inspired by Sims 2 diary and Buzzler's Scribbling Pad


birdyfly
17th Nov 2011, 07:24 PM
Hi,
Since I'm waiting for a response on my hot tub script in the Object Creation forum, and also since I think it is close to being done, I decided to get a head start on this.

The one thing about Sims 2 I miss is when sims could write in their diary. I figured it might be doable after seeing the scribbling pad (http://www.modthesims.info/d/422974) that Buzzler made.

There are five main interactions that I want to implement into it:
Write in Diary
Read Diary
Practice Writing
Write Story
Sketch


Write In Diary: I have extracted the inscription plaque script from World Adventures since it has both the text box to write in and also being able to read from it. The only issue is that in order to place your own description in the plaque, you need to SHIFT + Click on the plaque in order to get the text box to show up. I am hoping that this can be fixed through the coding so when I click on the pie menu "Write In Diary" it will open the text box.
Read Diary: Using the inscription plaque script again, when the sim clicks the "Read Diary", it will show what the player or sim has written.
Practice Writing: I have extracted the practice writing script from the computer in order to have it so the sim can practice their writing.
Write Story: I have the Write Novel script so the sim can write novel.
Sketch: I have the drafting "research" script so the sim can sketch like they do with the drafting table. I wasn't sure if I should have use the drafting table or easel.

Here are the scripts I have extracted. I am not sure if I got the right scripts or not:
Draft Table.cs
Practice Writing.cs
Write Novel.cs
Tomb Inscription Plaque.cs

The mesh I was going to use was the homework object due to the writing animation it has. If this is going against Buzzler's policy, then I can look for finding an alternative method.

I do have a few questions/issues starting out with this though.

1) I am using four different scripts (draft table, practice writing, write novel, tomb inscription plaque). Will I be able to add these into one object?

2) Is there a way to add more than one text box, so sims can write more than one page? And when reading, have a way to make it so they can see more than one page? To do this, will I need to use a different script than the inscription plaque?

Although I have done scripting before, this is technically my second scripting project for Sims 3, and I still haven't finished the first one yet. I understand that this is a huge project that I am taking on and it will be frustrating. I don't know how far I will get, but I'm hoping to at least complete it eventually. I am looking at this tutorial: http://simswiki.info/wiki.php?title=Tutorial:Sims_3_Object_Modding but I might have to switch over to this tutorial instead: http://simswiki.info/wiki.php?title=Tutorial:Sims_3_Pure_Scripting_Modding

This is the start of the script I have so far:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.Objects.Miscellaneous;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.SimIFace;
using Sims3.UI;

namespace Sims3.Gameplay.Objects.Miscellaneous.BirdyFly

{

public class BirdyDiary : Homework

{

lorenrose1013
18th Nov 2011, 06:15 PM
I have very little experience, but for that first question, I'm going to go with yes, because Buzzlers mod uses both the practice writing and write novel scripts in that one script, so I assume that if they work together than so will all the others. This is just a guess though, don't take my word for it.

I'd like to add that this is a really awesome idea, and I would use it a lot to keep up with my sims. (This is perfect for the challenge I'm doing, so I can keep track of the lives of all 26 kids, plus the parents)

birdyfly
18th Nov 2011, 06:46 PM
After seeing the writing plaque text and turning it into an inscription podium for my Sims 3 museum, I figured this would be a great way to make a diary. Hopefully Buzzler will see this thread and maybe give me some tips on how he created his scribbling pad. :)

I am unsure about with having separate scripts, if I add it all to one file or if they have to be separated (I have a similar question about this with my hot tub as well). I do not know how to open up mods outside of the EA mods, so I am not sure how Buzzler went on to do his.

lorenrose1013
18th Nov 2011, 09:53 PM
Have you downloaded Reflector? If so, open Buzzler's mod in S3PE and find the S3SA file, then Export DLL. Open up Reflector and then open up that DLL to view his code :)
I think he's okay with it because it says on his page that you can look at his mods. Sorry Buzzler if I'm mistaken

birdyfly
18th Nov 2011, 10:27 PM
I am getting a little freaked out since I only have 12 days left on Reflector (the reason why I have been impatient for responses). Thank you for telling me how to open the script. Here are some parts of the script that jumped out to me. I may be wrong though and Buzzler may have to correct me if this is not what I should be looking at:

protected class GetPad : Interaction<Sim, ScribblingPad>
{
// Fields
public static readonly InteractionDefinition SingletonPracticeWriting = new PracticeWritingDefinition();
public static readonly InteractionDefinition SingletonWriteNovel = new WriteNovelDefinition();
public static readonly InteractionDefinition SingletonWriteRabbitHoleReview = new WriteRabbitHoleReviewDefinition();
public static readonly InteractionDefinition SingletonWriteReport = new WriteReportDefinition();
public static readonly InteractionDefinition SingletonWriteScreenplay = new WriteScreenplayDefinition();
public static readonly InteractionDefinition SingletonWriteStakeoutReport = new WriteStakeoutReportDefinition();


What I could do is where it has the code "Write New Screenplay" is to make it use the draft function:

public bool StartNewScreenplay(Film filmCareer, BookData.BookGenres genre)
{
List<string> list = BookData.WrittenBookTitles[genre];
string randomObjectFromList = RandomUtil.GetRandomObjectFromList<string>(list);
randomObjectFromList = "Gameplay/Excel/Books/WrittenBookTitles:" + randomObjectFromList;
string str2 = StringInputDialog.Show(Computer.LocalizeString("StartScreenplayDialogTitle", new object[0]), Computer.LocalizeString("StartScreenplayDialogPrompt", new object[0]), Localization.LocalizeString(randomObjectFromList, new object[0]), false, Computer.kMaxLenghtForBookName);
if (string.IsNullOrEmpty(str2))
{
return false;
}
return filmCareer.CreateNewScreenplay(str2, genre);
}



public bool WriteScreenplayTest(Sim actor, Computer.WritingInteractionType type)
{
Film film = actor.get_OccupationAsCareer() as Film;
if (((type == Computer.WritingInteractionType.Continue) && (film != null)) && (film.CurrentScreenplay == null))
{
return false;
}
return true;
}



protected class WriteScreenplayDefinition : ScribblingPad.GetPad.Definition
{
// Methods
public WriteScreenplayDefinition()
{
}

public WriteScreenplayDefinition(InteractionDefinition intDef)
{
base.IntDef = intDef;
}

public override void AddInteractions(InteractionObjectPair iop, Sim actor, ScribblingPad target, List<InteractionObjectPair> results)
{
Film film = actor.get_OccupationAsCareer() as Film;
if ((film != null) && (film.CurrentScreenplay != null))
{
results.Add(new InteractionObjectPair(new ScribblingPad.GetPad.WriteScreenplayDefinition(new ScribblingPad.WriteScreenplay.Definition(Computer.LocalizeString("ContinueScreenplay", new object[] { film.CurrentScreenplay.Title }), Computer.WritingInteractionType.Continue, 0x15)), iop.get_Target()));
results.Add(new InteractionObjectPair(new ScribblingPad.GetPad.WriteScreenplayDefinition(new ScribblingPad.WriteScreenplay.Definition(Computer.LocalizeString("ScrapScreenplay", new object[] { film.CurrentScreenplay.Title }), Computer.WritingInteractionType.Scrap, 0x15)), iop.get_Target()));
}
else
{
foreach (BookData.BookGenres genres in Computer.WriteScreenplay.kScreenplayGenres)
{
if (Writing.CanWriteScreenplayGenre(actor, genres))
{
results.Add(new InteractionObjectPair(new ScribblingPad.GetPad.WriteScreenplayDefinition(new ScribblingPad.WriteScreenplay.Definition(this.GetMenuText(genres), Computer.WritingInteractionType.Start, genres)), iop.get_Target()));
}
}


private sealed class WriteScreenplay : ScribblingPad.ScribblingInteraction
{
// Fields
private Definition interactionDefinition;
private Film mFilmCareer;
private DateAndTime mStartWritingTime;
private Writing mWritingSkill;



Not sure if this would be the best way though. Looking at his code, it has most of what I would need except for the write screenplay, write good/negative review, write report, and write stakeout.

The actions I do need that he does have is the sketch, write in diary, and read diary.

I think the best thing to do is to try to get the sketch code working first then do the diary section after since I am a little lost on how to add pages to it and how to get rid of the SHIFT + Click function.

lorenrose1013
19th Nov 2011, 07:45 PM
About the reflector program, mine expired, so I deleted it a re-downloaded it :P the rest of that code just flies over my head though...

birdyfly
22nd Nov 2011, 03:01 AM
I'm struggling greatly with this, but I'm hesitant to PM Buzzler since he said that he preferred to keep the questions in the Modding Forum. I am hoping to be able to at least get the diary part up and running, even if I can't add multiple pages to it since I liked that feature in Sims 2. I am going over the pure scripting mod one more time, and then the Object Modding forum. If anyone wouldn't mind helping me, I'd greatly appreciate it. :bunny:

lorenrose1013
24th Nov 2011, 10:08 PM
I think I would pm him at this point, it seems that no experienced modders have noticed this thread (Or they have and they haven't posted)

Buzzler
28th Nov 2011, 07:25 AM
Shoot, completely missed this. It's kinda difficult to give you hints, though, because you will basically need almost all the scribbling pad's code or code that does the very same. My offer would be that I give you the source code and you change it to your liking. Oh, you'll need the JAZZ script as well. The homework JAZZ doesn't work for adults.

To the basic working of the scribbling pad code: GetPad is the interaction to get the pad (Duh!) into the actor's hand first and actor and pad into a writing position. Then there's an abstract interaction named ScribblingInteraction from which all the actrual interactions are derived. That one handles the actual action, like practice writing etc.

I'm struggling greatly with this, but I'm hesitant to PM Buzzler since he said that he preferred to keep the questions in the Modding Forum.Always the wrong people who are scared off by the pm "firewall". Gotta remove that. It's ineffective against the people I actually want to scare off anyway.

I am getting a little freaked out since I only have 12 days left on ReflectorYou can use ILSpy.

birdyfly
28th Nov 2011, 06:37 PM
Thank you Buzzler! I am now downloading ILSpy.

I am planning to change the "write new screenplay" with the "research" script from the drafting table. I plan to just do that first before trying to get the diary up and running since it will probably be harder to do. Is this ideal to do, or is there a better method to add the research function?

Once I get the script for the sketch up and running, I'll post it here. :)

Buzzler
29th Nov 2011, 06:47 AM
I am planning to change the "write new screenplay" with the "research" script from the drafting table. I plan to just do that first before trying to get the diary up and running since it will probably be harder to do. Is this ideal to do, or is there a better method to add the research function?Ideal for what? I'd suggest to always do stuff that's slightly out of your league, so you can learn something by doing it, don't get frustrated and fully understand what you've done afterwards. :)

Are you using the scribbling pad code now? If so, it should be easy enough to get stuff going. When you derive a class from ScribblingInteraction, there are five methods for you to use/override.

- OnScribblingStarted() - this gets called directly before the writings animations start
- LoopDel() - this one gets called regurlary during the writing
- OnScribblingEnded() - surprise! this gets called after the writing
The latter two only get called if the first returns true.

Then there's OnSucceededExit() which gets called if the interaction exits successful. You can probably ignore that one. I think I didn't use myself. ;)

You need to override ExitReasons(), because it's abstract. You can just make it return ~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached); I initially thought I might use different exit reasons in the interactions, but as far as I remember that wasn't the case.

HTH

birdyfly
1st Dec 2011, 12:17 AM
Okay, this is the draft table script:
Code removed. Please only post relevant code, not humongous quotes of code. Use attachments instead. -Buzzler

I think I need this code:

private void EnsureDraft(Sim actor, SkillNames skill, OccupationNames occupation)

{

if (this.Draft != null)

{

if (this.Draft.get_InUse() && !this.Draft.get_ActorsUsingMe().Contains(actor))

{

return;

}

bool flag = false;

if ((skill != 0L) && (skill != this.Draft.SkillGuid))

{

flag = true;

}

if ((occupation != 0L) && (occupation != this.Draft.OccupationGuid))

{

flag = true;

}

if (flag)

{

this.Draft.RemoveFromUseList(actor);

this.Draft.Destroy();

}

}

if (this.Draft == null)

{

ResourceKey key;

PaintingSkill.PaintingQuality quality;

PaintingSkill.PickPainting(actor, skill, occupation, 1, ref key, ref quality);

Canvas.InitParameters parameters = new Canvas.InitParameters(actor, key, quality, 5, skill, occupation);

GlobalFunctions.CreateObjectParentedToSlot("workbenchDraftingCanvas", 8, this, -1474234201, null, parameters);

this.Draft.AddToUseList(actor);

}

}



and

private static DraftingTable GetDraftingTable(GameObject canvasOrDraftingTable)

{

return ((canvasOrDraftingTable as DraftingTable) ?? (canvasOrDraftingTable.get_Parent() as DraftingTable));

}



public SurfaceTypes GetSoundMaterial(uint index)

{

return this.mSurfaceType;

}



private bool IsDraftValid(Sim sim, SkillNames skill, OccupationNames occupation)

{

if (this.Draft == null)

{

return false;

}

if (this.Draft.PainterSimId != sim.get_SimDescription().get_SimDescriptionId())

{

return false;

}

if ((skill != 0L) && (skill != this.Draft.SkillGuid))

{

return false;

}

if ((occupation != 0L) && (occupation != this.Draft.OccupationGuid))

{

return false;

}

return true;

}



private static string LocalizeString(string name, params object[] parameters)

{

return Localization.LocalizeString(sLocalizationKey + ":" + name, parameters);

}



public override void OnCreation()

{

base.OnCreation();

}



public override void OnStartup()

{

base.AddInteraction(Research.SingletonInteriorDesigner);

base.AddInteraction(Research.SingletonStylist);

base.AddInteraction(Research.SingletonPainting);

base.AddInteraction(ScrapDraft.Singleton);

base.AddInteraction(TakeDraft.Singleton);

}



public void SetSoundMaterial(uint index, SurfaceTypes soundMaterial)

{

if (index == 0)

{

this.mSurfaceType = soundMaterial;

}

}


Sorry if this is the wrong script to add. I'm going to look through the script again and see if there is anything else I missed with what would be associated with the "research" function.

Buzzler
2nd Dec 2011, 12:33 PM
You seem to be on the wrong track. What you want is an interaction, i.e. an interaction that does something similar to an existing interaction. So, what you need to look for is another interaction. DraftingTable.Research in this particular case. You will find the most important stuff in its Run() method.