Open Crafting Menu from item in inventory.

Post » Wed Jun 20, 2012 12:24 pm

Hi everyone. I'm trying to get an misc item in my inventory to open the crafting menu when it is selected. Right now I'm just trying to do a proof of concept, but I have a few mods that I'm planning that would use this as a central feature. Does anyone know how to do this or if it is even possible?
User avatar
Matt Gammond
 
Posts: 3410
Joined: Mon Jul 02, 2007 2:38 pm

Post » Wed Jun 20, 2012 9:32 am

you might be able to do some smoke and mirrors trick by throwing the item on the ground and have a crafting furniture moveto your location (although i dont know if moveto would be applicable to furniture)
User avatar
Aaron Clark
 
Posts: 3439
Joined: Fri Oct 26, 2007 2:23 pm

Post » Wed Jun 20, 2012 7:27 am

I don't know how or if it's even possible. I do know how to open up a crafting menu when equipping an item, drinking a potion, or eating an ingredient.

Basically, you script the object so that when you use it, it activates a crafting station (eg forge). It basically works the same way as you selecting a forge or other crafting station in the game, opening up the console, and typing "activate player".

If I'm playing and want to enchant something, sometimes I just open up the console and type in:

prid c6e44
activate player
User avatar
Tiffany Castillo
 
Posts: 3429
Joined: Mon Oct 22, 2007 7:09 am

Post » Wed Jun 20, 2012 7:04 pm

Edit: Nevermind, I got that one script working, this is what I used. I know it's really simple, but I have to start somewhere right?

Scriptname AAATestScript extends ObjectReference
{This is my first script.}

Event OnEquipped(Actor akActor)

Debug.MessageBox("Hello, World!")

endEvent

Ok, I think I understand. I'm trying to take this a step at the time, and the next question is going to sound stupid but why wont this compile?


Scriptname AAATestScript extends ObjectReference

Event OnEquipped

Debug.MessageBox("Hello, World!")

endEvent

I apologize for the stupid question, I'm just starting with scripting at this point.
User avatar
Anne marie
 
Posts: 3454
Joined: Tue Jul 11, 2006 1:05 pm

Post » Wed Jun 20, 2012 4:47 am

Event OnEquipped(actor akActor)

OnEquipped is a function and needs the parentheses
User avatar
Lil Miss
 
Posts: 3373
Joined: Thu Nov 23, 2006 12:57 pm

Post » Wed Jun 20, 2012 9:59 am

You are a very helpful person AD.

So this is my first attempt at simply getting the script to activate an enchanting table. Again the code won't compile, so any help is appreciated.

Scriptname AAATestScript extends ObjectReferenceEvent  OnEquipped(Actor akActor)c6e44.activate playerDebug.MessageBox("Hello, World!")endEvent

Any thoughts? It's probably very simple...

I also tried all variations of the ref id that I could think of.
User avatar
Katie Pollard
 
Posts: 3460
Joined: Thu Nov 09, 2006 11:23 pm

Post » Wed Jun 20, 2012 1:05 pm

you need to declare the enchanting table as an object reference property

above your event you declare:

ObjectReference Property EnchantTable Auto


and inside your event function

EnchantTable.Activate(game.getplayer())




save your script then open the properties window. for your EnchantTable property you need to link this to the enchant table of your choice (actual table in the world somehwere, i.e. farengar's enchant table in dragonsreach)
User avatar
Jamie Lee
 
Posts: 3415
Joined: Sun Jun 17, 2007 9:15 am

Post » Wed Jun 20, 2012 6:18 am

Wow, the code is working great. This is what I have:

Scriptname AAATestScript extends ObjectReferenceObjectReference Property EnchantTable AutoEvent OnEquipped(Actor akActor)       EnchantTable.Activate(game.getplayer())endEvent

Now, I want to make sure I understand what this means. As far as I understand "ObjectReference Property EnchantTable Auto" is declaring the variable EnchantTable, while EnchantTable.Activate(game.getplayer()) calls the variable and activates it. However, the variable is not defined in the script, but by the properties set later. Really a pretty clever way to allow a script to be used in a myriad of different situations.

One question I have though: When the crafting table being activated is in the same cell, I am immediately teleported to it, and I begin crafting, but when the table is in another cell, I have to press E after I exit the menu to begin crafting, and I am able to move and do anything else I want to until I press E.

Is there anyway for the script to close the menu and force the crafting menu to appear immediately? If not, it's not a big deal.

FYI - you are getting your name in the credits for this mod.
User avatar
Ria dell
 
Posts: 3430
Joined: Sun Jun 25, 2006 4:03 pm

Post » Wed Jun 20, 2012 4:23 am

A) Now, I want to make sure I understand what this means. As far as I understand "ObjectReference Property EnchantTable Auto" is declaring the variable EnchantTable, while EnchantTable.Activate(game.getplayer()) calls the variable and activates it. However, the variable is not defined in the script, but by the properties set later. Really a pretty clever way to allow a script to be used in a myriad of different situations.

B) One question I have though: When the crafting table being activated is in the same cell, I am immediately teleported to it, and I begin crafting

C) Is there anyway for the script to close the menu and force the crafting menu to appear immediately? If not, it's not a big deal.
A) Correct

B) Point the EnchantTable property elsweyr, to an unreachable station

C) Activate the station from within a custom function, perhaps? It won't close the inventory menu, but should still prompt the crafting menu.

ScriptName AAATestScript extends ObjectReferenceObjectReference Property ThisARMO AutoObjectReference Property EnchantTable AutoEvent OnEquipped(Actor akActor)      If akActor == Game.GetPlayer()            akActor.UnequipItem(ThisARMO, False, True)            Enchant()      EndIfEndEvent;=========================Function Enchant()       EnchantTable.Activate(Game.GetPlayer())EndFunction
Worth a shot...
User avatar
kitten maciver
 
Posts: 3472
Joined: Fri Jun 30, 2006 2:36 pm

Post » Wed Jun 20, 2012 9:03 am

A) Correct

B) Point the EnchantTable property elsweyr, to an unreachable station

C) Activate the station from within a custom function, perhaps?

For B, I created a station in another empty, unreachable cell, and pointed the variable towards that station. It seems that when the station is unreachable, once the item is equipped, I have to close the menu and the press E before I can begin crafting.

For C, I'm not exactly sure what you mean by that. Could you explain?

Sorry, I've been modding since Morrowind, but I've never even tried scripting before, so I appreciate everybody's patience.
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Wed Jun 20, 2012 3:46 pm

It's just a hunch as a Menu() function I've been working on works from within or without the inventory menu but when in the inventory menu, certain things don't immediately transpire unless wrapped in separate functions. My suspicion is that the above code will bring up the enchanting menu immediately and right over the inventory menu unless accessed via a hotkey (in which case scrolling will probably pull the camera in/out).
User avatar
Tanya Parra
 
Posts: 3435
Joined: Fri Jul 28, 2006 5:15 am

Post » Wed Jun 20, 2012 1:53 pm

OK, sorry, didn't see the code there the first time.

hmmmmm. Unfortunately I'm not having any luck with the code above. It works, but there is still the delay. I'm assuming that the variable "ThisARMO" is meant to be associated with the item being equipped. Is that correct?

Also, do you know of any functions to force the menu to close?

Thanks for sharing your knowledge.
User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am

Post » Wed Jun 20, 2012 1:06 pm

does it have to be an armor that triggers the table access?

alternatively you could put it on a power so that when you press the power button the table menu comes up
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Wed Jun 20, 2012 2:59 pm

does it have to be an armor that triggers the table access?

alternatively you could put it on a power so that when you press the power button the table menu comes up

In this case it needs to be a physical item. It has to do with a survival mod, so I really want to avoid using powers or spells except as a last resort. Right now I am using it with both an equipable weapon and a non equipable item. Both work the same way when I click on them in the inventory. The equipable weapon has the advantage though because I can hotkey it.

It works how it stands right now, I would just like to make it a more seamless transition to the crafting menu.

Optimally, I hope to play a custom animation, from a certain camera angle while I bring up the crafting menu, essentially replacing one of the crafting stations with a somewhat less powerful portable version.
User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Wed Jun 20, 2012 4:20 am

you could also make it an enchantment (ironic lol) on the armor. in which the magic effect of the armor wont start until the menu is closed. and instead of OnEquipped you would use OnEffectStart in a script attached to the magic effect

edit: i just thought of something, you might be able to use Utility.Wait(0.5) in your existing script. if i remember correctly having the wait function will "queue" the rest of the code until after the menu closes. but i could be wrong, my memory could be fuzzy
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am

Post » Wed Jun 20, 2012 10:02 am

I have a script which activates a container (which is stored in the world in an unreachable cell) by equipping an item in your inventory and everything works perfectly as far as I can tell.


==============================================================================================================================================================


Scriptname YourScriptNameHere extends ObjectReference


Event OnEquipped(Actor akActor)

Game.DisablePlayerControls(false, false, false, false, false, true, false) ;; gets you out of your inventory

utility.wait(0.1)

Game.EnablePlayerControls(false, false, false, false, false, true, false) ;; fixes menu being disabled
TargetContainer.Activate(Game.GetPlayer())

Game.GetPlayer().UnequipItem(ThisItem) ;; unequip the item that was equipped to activate the container

EndEvent


ObjectReference Property TargetContainer Auto

Armor Property ThisItem Auto


==============================================================================================================================================================

You just need to replace the container with your crafting furniture item, make sure to remove keywords from the furniture item which trigger animations (this means it has to be a copy of the furniture item that you are using or else you will cause bugs for other crafting furniture in the game world).

:biggrin:
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Wed Jun 20, 2012 4:54 am

Thanks a lot KC, though I just came back excited because I had just figured (most) of the script out, but this will really help and will take me into the next phase of my mod, I really appreciate it. Edit - KC -That actually woks extremely smoothly, I'll think I'll borrow some of that if you don't mind. The code I posted below is what I had before you posted yours. Thanks.

For anyone who runs into this problem for their mods, I'm posting the scripting that Everyone is this thread help me put together.

ScriptName AAATestScript extends ObjectReferenceObjectReference Property EnablePlayerControls AutoObjectReference Property DisablePlayerControls AutoObjectReference Property ThisARMO AutoObjectReference Property EnchantTable AutoEvent OnEquipped(Actor akActor)	  If akActor == Game.GetPlayer()			akActor.UnequipItem(ThisARMO, False, True)  DisablePlayerControls  utility.wait(0.1)  EnablePlayerControls  Enchant()Else  Enchant()EndIfEndEvent;=========================Function Enchant()	   EnchantTable.Activate(Game.GetPlayer())EndFunction

Now I just need to figure out how to nerf the players smithing skills temporarily, but that shouldn't be too hard.

One More Thing: Thank you guys so much for your help tonight. Thanks to you, I actually went from having zero knowledge of papyrus to being able to navigate it pretty confidently. It's members like you that are why this community is so great. Okay, I'll stop being sappy and over dramatic now. Have a good night everybody.
User avatar
sara OMAR
 
Posts: 3451
Joined: Wed Jul 05, 2006 11:18 pm

Post » Wed Jun 20, 2012 6:10 am

Hey guys, just wanted to drop by and thank everyone for their help. the mod is now LIVE!

Here is the thread: http://www.gamesas.com/topic/1362034-relz-whetstones-immersive-super-nifty-extremely-portable/

I made mention of all of you in the credits.

I hope you guys give it a try, and let me know what you think,

Thanks again,
d_b
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm


Return to V - Skyrim