crafting recipes and how to teach the player the recipe

Post » Mon Nov 19, 2012 1:21 pm

This has proberly been asked before but wasnt successful with my search.

I have a smithing recipe that i would like to teach to the player when he/she reads a speciel book or note, included in this book/note is also the tempering recipe.

I've been fooling around trying to se if i could do it with the "teaches" checkbox on books/notes but to no luck. thinking i have to do it with scripting.

Would be greatful if i could get directed to some infor on how i should write the damn script or if its even possible. Or maybe a tutorial.
User avatar
Eilidh Brian
 
Posts: 3504
Joined: Mon Jun 19, 2006 10:45 am

Post » Mon Nov 19, 2012 6:09 am

Create a GlobalVariable called KnowsSmithingRecipe
Attach the following script to note/book with the recipe in it

Event OnRead()KnowsSmithingRecipe.SetValue(1)EndEventGlobalVariable Property KnowsSmithingRecipe Auto

Then in the conditions in the craftable object menu do a GetGlobal check to see if KnowsSmithingRecipe = 1 same for the tempering recipe.
User avatar
JD bernal
 
Posts: 3450
Joined: Sun Sep 02, 2007 8:10 am

Post » Mon Nov 19, 2012 3:24 pm

and its that simple, i was even fooling around with that idea bit missed out on the global part
Thank you! :)
User avatar
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Mon Nov 19, 2012 6:43 pm

How I did it:
Recipe requires perk
Get perk from book
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Mon Nov 19, 2012 12:23 pm

If the recipe is part of a quest, you could even just use a 'GetStage' condition.
User avatar
Natalie J Webster
 
Posts: 3488
Joined: Tue Jul 25, 2006 1:35 pm

Post » Mon Nov 19, 2012 11:33 am

the recipe is a random clutter note the player can find
though to craft the item, the player is required to have a set perk or two
User avatar
Charles Weber
 
Posts: 3447
Joined: Wed Aug 08, 2007 5:14 pm

Post » Mon Nov 19, 2012 6:03 am

You just game me an excellent idea for something in my mod. Thanks
User avatar
CArlos BArrera
 
Posts: 3470
Joined: Wed Nov 21, 2007 3:26 am

Post » Mon Nov 19, 2012 3:30 pm

so, apperently im missing something, or my CK is bugged somehow (hoping for the first)

Create a GlobalVariable called KnowsSmithingRecipe
Attach the following script to note/book with the recipe in it

Event OnRead()KnowsSmithingRecipe.SetValue(1)EndEventGlobalVariable Property KnowsSmithingRecipe Auto

Then in the conditions in the craftable object menu do a GetGlobal check to see if KnowsSmithingRecipe = 1 same for the tempering recipe.

misc -> global -> rightclik -> new (named it "TGFLLearnRecipe01" to keep the naming theme and easy to find) set value to zero, klicked ok
found my note -> edit -> scripts -> add new script -> pasted above script into and made sure to rename the sections with the global name correctly -> compiled with succes.
found my recipe -> edit -> in the "match Conditions" added new -> set to "GetGlobalValue" -> selected my Global -> Comparison set to "==" -> value set to "1" klicked ok
did the same for my temering recipe.
and somehow i failed to make it work.
Checked and recheck spelling, checked and rechecked the script, and its properties (the properties I'm assuming should be set to the global)
Can anyone from this deduse what I'm doing wrong?
User avatar
naana
 
Posts: 3362
Joined: Fri Dec 08, 2006 2:00 pm

Post » Mon Nov 19, 2012 6:13 pm

In game, after you read the note, type Show TGFLearnRecipe01. This should show you if the variable has been set correctly after reading the note.

If it's not setting the variable correctly (it's still 0 after reading the note), the problem is in the script. If the variable is correctly 1, the problem is in your recipes.

I use this same set up in several of my mods, and it works fine, so I'm not sure what's going wrong this time.
User avatar
Euan
 
Posts: 3376
Joined: Mon May 14, 2007 3:34 pm

Post » Mon Nov 19, 2012 2:43 am

In game, after you read the note, type Show TGFLearnRecipe01. This should show you if the variable has been set correctly after reading the note.

If it's not setting the variable correctly (it's still 0 after reading the note), the problem is in the script. If the variable is correctly 1, the problem is in your recipes.

I use this same set up in several of my mods, and it works fine, so I'm not sure what's going wrong this time.
Getting right onto that and testing.
While we are at this, is there anyway i could get a display text at the top left corner informing the player they have learned to make this item, same way it shows for spells?
User avatar
Riky Carrasco
 
Posts: 3429
Joined: Tue Nov 06, 2007 12:17 am

Post » Mon Nov 19, 2012 6:09 am

Make a message, do not check Message Box so that it displays in the corner, and use http://www.creationkit.com/Show_-_Message to display the message when you give the player access to the recipe.
User avatar
Sun of Sammy
 
Posts: 3442
Joined: Mon Oct 22, 2007 3:38 pm

Post » Mon Nov 19, 2012 3:13 am

Make a message, do not check Message Box so that it displays in the corner, and use http://www.creationkit.com/Show_-_Message to display the message when you give the player access to the recipe.
That you have to define a bit more.
misc -> Messages -> create new (its what you ment right?)
and then in the script add a "ID-of-message.show()"
or am i missing something?

As for the other bits, that i finally got working.
Problem was the user, i had forgotten the "extends ObjectReference" ...
User avatar
sophie
 
Posts: 3482
Joined: Fri Apr 20, 2007 7:31 pm

Post » Mon Nov 19, 2012 11:42 am

Misc -> Messages -> create new -> name it -> uncheck "message box" -> Enter the text that you want displayed.

Back in your script add the following line after you set the variable
.Show()

then add the following line underneath the GlobalVariable Property.... line
Message Property  Auto
User avatar
zoe
 
Posts: 3298
Joined: Sun Nov 12, 2006 1:09 pm

Post » Mon Nov 19, 2012 4:30 am

those blasted proberties, i really should get my head around those soon!

And thanks guys, got it to work :)
User avatar
Bonnie Clyde
 
Posts: 3409
Joined: Thu Jun 22, 2006 10:02 pm

Post » Mon Nov 19, 2012 6:55 am

those blasted proberties, i really should get my head around those soon!

And thanks guys, got it to work :smile:

Just remember that anytime you reference ANYTHING you can select in the object window, you need a property.
User avatar
Matt Bigelow
 
Posts: 3350
Joined: Sun Sep 30, 2007 6:36 pm

Post » Mon Nov 19, 2012 3:23 am

Just remember that anytime you reference ANYTHING you can select in the object window, you need a property.
To further my idea, can the script be written to check if the player has a specific perk, so i can create a message that says "you lack surficiant knowledge to understand the recipe"
Might be wishful thinking, but seams odd to teach the player how to make an item, when the recipe requires a set perk within the smithing perk-tree.

From what i can understand, i think it involves "if/then" functions, though not something needed just an idea, that would have been cool :)
User avatar
Felix Walde
 
Posts: 3333
Joined: Sat Jun 02, 2007 4:50 pm

Post » Mon Nov 19, 2012 6:40 pm

If (Game.GetPlayer().HasPerk(SteelSmithing))	 ;do whatever you need done if the player has the perk hereElse	 ;do whatever you need done if the player doesn't have the perk hereEndIf

Obviously you'd need to change SteelSmithing to the ID of the perk you want to check for. Then if you're looking to give the the player the recipe at that point, add the .SetValue(1) to that block of the if statement and a message explaining that they need the perk to the "else" block.
User avatar
Robert Bindley
 
Posts: 3474
Joined: Fri Aug 03, 2007 5:31 pm

Post » Mon Nov 19, 2012 8:29 am


Obviously you'd need to change SteelSmithing to the ID of the perk you want to check for. Then if you're looking to give the the player the recipe at that point, add the .SetValue(1) to that block of the if statement and a message explaining that they need the perk to the "else" block.

Scriptname TGFLScriptToLearn extends ObjectReference GlobalVariable Property TGFLLearnRecipe01 AutoMessage Property TGFLLearnRecipe01DisplayYes AutoMessage Property TGFLLearnRecipe01DisplayNo AutoEvent OnRead()If (Game.GetPlayer().HasPerk(AdvancedArmors))	    TGFLLearnRecipe01.SetValue(1)	    TGFLLearnRecipe01DisplayYes.Show()Else	    TGFLLearnRecipe01DisplayNo.Show()EndIfEndEvent
I need to exstend the property for the perk aswell, since im getting a warning that the perk is undefined?
User avatar
Antony Holdsworth
 
Posts: 3387
Joined: Tue May 29, 2007 4:50 am

Post » Mon Nov 19, 2012 2:18 am

I need to exstend the property for the perk aswell, since im getting a warning that the perk is undefined?
Whenever you reference anything from the base game (Objects, perks, spells, actors, etc) you need to define it in a property. Otherwise the script has no clue what you're talking about.

Add this line and the direct it to your perk;

Perk Property MyPerk Auto
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Mon Nov 19, 2012 5:18 pm

Figured that, with a bit of trail and error i got it running :)

Thank again guys!
User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am

Post » Mon Nov 19, 2012 3:20 pm

Whenever you reference anything from the base game (Objects, perks, spells, actors, etc) you need to define it in a property. Otherwise the script has no clue what you're talking about.

It's not just the base game either, if you're referencing stuff you've added in your own mod, you need to property that as well.

Basically, if you're going to run a function on it, or use it as part of a function, it needs to be propertied. There's VERY few exceptions to this rule (like using Game.GetPlayer() . or Self.) but you could still property those if you wanted to as well.
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Mon Nov 19, 2012 8:41 am

Spoiler

Scriptname TGFLScriptToLearn extends ObjectReferenceGlobalVariable Property TGFLLearnRecipe01 AutoMessage Property TGFLLearnRecipe01DisplayYes AutoMessage Property TGFLLearnRecipe01DisplayNo AutoPerk Property AdvancedArmors AutoEvent OnRead()If (Game.GetPlayer().HasPerk(AdvancedArmors))		TGFLLearnRecipe01.SetValue(1)		TGFLLearnRecipe01DisplayYes.Show()Else		TGFLLearnRecipe01DisplayNo.Show()EndIfEndEvent
key element i keep forgetting is to fill in the properties once you have compiled the script, but hey, live and learn :smile: above is the script compiled and working.

@R'lyeh Liberation Front
I'm starting to get the hang of it, though i need to pratice alot more, for now this bit was to ensure i could get my head around it and make it work, while reading up on the scripting (not my strong side)

@Alexander J. Velicky
My problem was getting the right name and spelling for that perk once i figured out, the syntax i needed :smile: given that english is not my main language some of the words are tricking me at times, even more so when tired :tongue:
User avatar
Nims
 
Posts: 3352
Joined: Thu Jun 07, 2007 3:29 pm

Post » Mon Nov 19, 2012 2:26 pm

It's not just the base game either, if you're referencing stuff you've added in your own mod, you need to property that as well.
True, I should have worded that better.

If you're script references anything from the game, vanilla or in your mod (Or any parent mod), it needs to be a property. :)
User avatar
Andres Lechuga
 
Posts: 3406
Joined: Sun Aug 12, 2007 8:47 pm

Post » Mon Nov 19, 2012 3:27 pm

How I did it:
Recipe requires perk
Get perk from book

That's what I did - I made a dummy perk and reading the book adds the perk to the player and all the recipes require that perk for HASPERK, as well as Steel, Arcane Smithing etc.

~
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am


Return to V - Skyrim