AndrewOverload519 Posted August 25, 2012 Share Posted August 25, 2012 (edited) Hello there. As you may or may not know, I am the author of the Cube of Transmutation mod. My mod seems to be getting quite popular already and I aim to make it even better. This is why I want to ask a few things, as I can only do some basic scripting. First off, is it possible to create a randomised item of a certain type? Let's say, for example, I want the Cube of Transmutation to create a random enchanted Daedric Sword by using an unenchanted Daedric Sword and a filled Black Soul Gem. I assume I have to create some sort of placeholder item that when added to my inventory, would replace itself with said random weapon? Another question that I wanted to ask, is it also possible to create an unbound summoned creature by using the Cube? Let's say that I wanted to incorporate a secret recipe for a laugh or two. ;) Edited August 25, 2012 by AndrewOverload519 Link to comment Share on other sites More sharing options...
JanusForbeare Posted August 25, 2012 Share Posted August 25, 2012 1) You could create a new formlist for each material/item type, put the appropriate objects inside, and have the the cube produce a random item from that list. 2) I don't know how your mod works, but it should be possible to have the cube run a placeatme() function when used. That will spawn a new creature of whatever type your script specifies. Link to comment Share on other sites More sharing options...
AndrewOverload519 Posted August 26, 2012 Author Share Posted August 26, 2012 (edited) Okay, I've started work on a script that would supposedly make the following happen: once the created placeholder item (eg. RandomEnchIronDagger) is in the player's inventory, it will remove itself and then add a random enchanted item from a formlist (eg. CreateEnchIronDagger) in it's place. Here's what I've got so far. Scriptname RandomIronDaggerScript extends ObjectReference WEAPON Property NewProperty Auto Event OnItemAdded(Form RandomEnchIronDagger, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if !akSourceContainer == Game.GetPlayer() Function RemoveItem(Form RandomEnchIronDagger, int aiCount = 1, bool abSilent = false) Function AddItem(Form CreateEnchIronDaggerRandom, int aiCount = 1, bool abSilent = false) endif endEvent However, when I try to compile it, I get errors. Here's what the output is trying to tell me. Starting 1 compile threads for 1 files...Compiling "RandomIronDaggerScript"...c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(7,4): mismatched input 'Function' expecting ENDIFc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(7,49): required (...)+ loop did not match anything at input ','c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(7,66): required (...)+ loop did not match anything at input ','c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(7,89): required (...)+ loop did not match anything at input ')'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(9,2): no viable alternative at input 'endif'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(0,0): error while attempting to read script RandomIronDaggerScript: Object reference not set to an instance of an object.No output generated for RandomIronDaggerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on RandomIronDaggerScript Have I done anything wrong? Edited August 27, 2012 by AndrewOverload519 Link to comment Share on other sites More sharing options...
AndrewOverload519 Posted August 27, 2012 Author Share Posted August 27, 2012 I don't mean to double post or anything like that, but this is really important for my mod and I desperately needed some help with my script. So recently, I've made some amendments to my script and I still couldn't get anything right. Here's the new script, this time by using a LeveledItem (eg. LItemEnchIronDagger) instead of a formlist. I haven't deleted the formlist though, just incase I need it for anything. Scriptname RandomIronDaggerScript extends ObjectReference WEAPON Property NewProperty Auto Event OnItemAdded(Form RandomEnchIronDagger, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if !akSourceContainer == Game.GetPlayer() Game.GetPlayer().RemoveItem(RandomEnchIronDagger, 1, true) Game.GetPlayer().AddItem(LItemEnchIronDagger, 1, false) endif endEvent And the output to go with it. Starting 1 compile threads for 1 files...Compiling "RandomIronDaggerScript"...c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\RandomIronDaggerScript.psc(8,29): variable LItemEnchIronDagger is undefinedNo output generated for RandomIronDaggerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on RandomIronDaggerScript Obviously, this has much better results than the previous version of my script, however it now says that there is an undefined variable that's causing it to not compile properly. Can anyone explain what I've done wrong this time? Link to comment Share on other sites More sharing options...
JanusForbeare Posted August 27, 2012 Share Posted August 27, 2012 An undefined variable is usually a property that hasn't been declared. From the looks of it, you forgot to declare the levelled item before you added it to the script, so the CK doesn't know what "LItemEnchIronDagger" is. Link to comment Share on other sites More sharing options...
AndrewOverload519 Posted August 27, 2012 Author Share Posted August 27, 2012 (edited) Okay, I've been reading about declaring properties on the Creation Kit Wiki for answers but what it tells me is really confusing and does not seem to fit my needs. How do I make a declared property that defines the LeveledItem, exactly? EDIT: Wait, I think I may have actually solved my own problem. Not only that, but the end result is a script that could work on ANY weapon! Thanks a lot! Edited August 27, 2012 by AndrewOverload519 Link to comment Share on other sites More sharing options...
AndrewOverload519 Posted August 27, 2012 Author Share Posted August 27, 2012 Double post again, but this time I have a new problem. The script has now compiled as it should, but when I go to test the script ingame it doesn't seem to actually work as intended. To explain this problem in more detail, I've used the Cube of Transmutation to create a placeholder Iron Dagger. However, the placeholder Iron Dagger did not replace itself with a random enchanted Iron Dagger as soon as it is added to the player's inventory, but instead it just stays as the placeholder item. I can only assume that I may have done something wrong in the script yet again. Here is the new script, with the properties now properly defined and all. Scriptname CraftRandomWeponScript extends ObjectReference LeveledItem Property ListReference Auto WEAPON Property WeaponReference Auto Event OnItemAdded(Form WeaponReference, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if !akSourceContainer == Game.GetPlayer() Game.GetPlayer().RemoveItem(WeaponReference, 1, true) Game.GetPlayer().AddItem(ListReference, 1, false) endif endEvent Link to comment Share on other sites More sharing options...
AndrewOverload519 Posted August 30, 2012 Author Share Posted August 30, 2012 I'm really sorry if I've been getting on anyone's nerves lately through all of this multi-posting but I seriously needed some more help with getting this script up and running right now. I'd just like someone to point out what I have done wrong and suggest some amendments to the script found on the above post, that is all I ask. It is integral for the next version of my mod and I would really appreciate all the help that I could get. Link to comment Share on other sites More sharing options...
Recommended Posts