Spawning objects through message box

Post » Mon Nov 19, 2012 12:59 am

Ok, i'll have one last go at explaining this.

I'd like a setup whereby activating an object (a workbench) brings up a message box with multiple options to spawn a variety of objects for building purposes, with each option requiring items to be in the player's inventory. Something like this:

Workbench (activate) -> message box appears with two options: option A - spawn object set A (requires 1 iron ore,) option B - spawn object set B (requires one steel ingot) -> Choose option -> items removed from player inventory -> objects spawn

I sort of get some of the individual scripting pieces I need, but have no idea how to put them all into a script that actually works.

Thanks.
User avatar
kristy dunn
 
Posts: 3410
Joined: Thu Mar 01, 2007 2:08 am

Post » Mon Nov 19, 2012 9:17 am

Well it depends on how you want the object sets to spawn, you can set an enable parent for all the objects that you want to appear then enable that parent in the script which would look something like this:
Spoiler
Scriptname SM_Teset extends ObjectReferenceMiscObject Property IronOre AutoMiscObject Property SteelIngot AutoObjectReference Property ObjectSet1 AutoObjectReference Property ObjectSet2 AutoMessage Property Message1 Autoint button1Event OnActivate(ObjectReference akActionRef); Message Box with 2 optionsbutton1 = Message1.Show(); Options 1 & 2If button1 == 0 ;Option AIf (Game.GetPlayer().GetItemCount(IronOre) == 1)ObjectSet1.Enable()EndIfElseIf button1 == 1 ;Option BIf (Game.GetPlayer().GetItemCount(SteelIngot) == 1)ObjectSet2.Enable()EndIfEndIfEndIfEndEvent

Or you could spawn the object sets using "PlaceAtMe" which would look something like this:

Spoiler
Scriptname SM_Teset extends ObjectReferenceMiscObject Property IronOre AutoMiscObject Property SteelIngot AutoObjectReference Property ObjectSet1 AutoObjectReference Property ObjectSet2 AutoObjectReference Property Marker1 AutoObjectReference Property Marker2 AutoMessage Property Message1 Autoint button1Event OnActivate(ObjectReference akActionRef); Message Box with 2 optionsbutton1 = Message1.Show(); Options 1 & 2If button1 == 0 ;Option AIf (Game.GetPlayer().GetItemCount(IronOre) == 1)Marker1.PlaceAtMe(ObjectSet1)EndIfElseIf button1 == 1 ;Option BIf (Game.GetPlayer().GetItemCount(SteelIngot) == 1)Marker2.PlaceAtMe(ObjectSet2)EndIfEndIfEndIfEndEvent

I personally find it easier to just set an xmarker as an enable parent for all the objects I'm going to spawn then enable it in the script, the "PlaceAtMe" will essentially do the same thing, but it might not be in the exact position you want and it's not as efficient. Hope this helps! :biggrin:
User avatar
Ana
 
Posts: 3445
Joined: Sat Jul 01, 2006 4:29 am

Post » Mon Nov 19, 2012 10:23 am

Rather than conditionalizing in the script, I'd recommend conditionalizing the message box buttons such that they'll not show when inapplicable.

See also: http://www.creationkit.com/Options_Menu
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Mon Nov 19, 2012 5:16 am

Currently i've got all the items linked to an Xmarker which is set to "initially disabled" (that bit I can do. :biggrin:) So I would probably be using the enable function. That's what I really needed, a complete script I could just tweak to fit my needs. Thanks y'all i'll give it a go and see how badly I can mess it up now.

Spoiler
 Scriptname SM_Teset extends ObjectReference MiscObject Property IronOre Auto MiscObject Property SteelIngot Auto ObjectReference Property ObjectSet1 Auto ObjectReference Property ObjectSet2 Auto Message Property Message1 Auto int button1 Event OnActivate(ObjectReference akActionRef) ; Message Box with 2 options button1 = Message1.Show() ; Options 1 & 2 If button1 == 0 ;Option A If (Game.GetPlayer().GetItemCount(IronOre) == 1) ObjectSet1.Enable() EndIf Else If button1 == 1 ;Option B If (Game.GetPlayer().GetItemCount(SteelIngot) == 1) ObjectSet2.Enable() EndIf EndIf EndIf EndEvent 

Ok can someone get the big pointy stick with the rubber tipped end and show me in the code where I actually put the text for my choices. :biggrin:
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am


Return to V - Skyrim