Spinner385 Posted July 17, 2012 Share Posted July 17, 2012 (edited) Okay some background. I know visual basic a little C and used to write scripts for Ultima Online. I'm trying to learn papyrus now. Played around with the hello world and I messed with some existing scripts. Would like to start writing things to add to the community. I'm now trying to write a script that has the magnitude of the potion in the name. I found the magic effect alchrestoreheath. First tried to just add <mag> in the title of the form. Only showed up as <mag>, guess it only works in the item description. But I was happy I was editing the right thing. So on to scripting. Did a little research and came up with this one liner. Well two if your count the premade header. Scriptname PotionName extends activemagiceffect AlchRestoreHealth.GetBaseObject().SetName("Restore Health " +AlchRestoreHealth.GetNthEffectMagnitude(0)) Of course it didn't compile. I'm probably way off. There's a lot I'm questioning, can anyone help. Maybe a nice breakdown. Thnx in advance Edited July 17, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Spinner385 Posted July 17, 2012 Author Share Posted July 17, 2012 (edited) A little more detail of whats going on in my head Scriptname PotionName extends activemagiceffectIm not really messing with the activemagiceffect, but the form of the object it applies to. What should I be extending? AlchRestoreHealth.GetBaseObject().SetName("Restore Health " +AlchRestoreHealth.GetNthEffectMagnitude(0))AlchRestoreHealth - is the thing im referring toGetBaseObject() - seemed necessary from the setname instructions (maybe not necessary)AlchRestoreHealth.GetNthEffectMagnitude(0) - Again referring to AlchRestoreHealth trying to return its magnitude I also believe I could add the lineFloat Mag = AlchRestoreHealth.GetNthEffectMagnitude(0)Then use mag in my setname but I was trying to be as simple as possible The compile error I get is (3,17): no viable alternative at input '.'Makes me think I'm not activating something I should because it seems like its questioning my period? Edited July 17, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Spinner385 Posted July 17, 2012 Author Share Posted July 17, 2012 Okay so I believe that I must have an event for papyrus. So I'm trying OnItemAdded. GetNthEffectMagnitude is giving me trouble so I tried: Scriptname PotionName extends activemagiceffect int mag = 99 Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If aiItemCount > 0 akBaseItem.SetName("Restore Health Test " + mag) endif endeventIt compiled but did nothing in-game. Tried dropping and picking up and crafting new potion. Link to comment Share on other sites More sharing options...
Spinner385 Posted July 18, 2012 Author Share Posted July 18, 2012 Anybody? I'm putting in the time myself. Can anyone help me? Link to comment Share on other sites More sharing options...
scrivener07 Posted July 18, 2012 Share Posted July 18, 2012 Scriptname AAAscrivener07 extends Actor ;This script will be extending an actor, the player ;/ Attach this script to the player. /; Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ;fires when ever something is added to the player potionToBeRenamed = akBaseItem as Potion originalName = akBaseItem.GetName() Int magnitude = potionToBeRenamed.GetNthEffectMagnitude(0) as Int String NewPotionName ="(" + magnitude + ")" + " " + originalName If (akBaseItem.HasKeywordString("VendorItemPotion") || akBaseItem.HasKeywordString("VendorItemPosion") && aiItemCount <= 0) ;Make sure the item added is in fact a potion or posion ;If aiItemCount < 0 If (magnitude <= 0 || none) akBaseItem.SetName(originalName + " (No Mag)") Else akBaseItem.SetName(NewPotionName) ;change the name. Only works on the base form so all potions of this type will change too Debug.Notification("Potion name changed to " + NewPotionName) Endif ;Endif Endif EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) ;fires when ever something is removed from the player ;If (akBaseItem.HasKeywordString("VendorItemPotion") || akBaseItem.HasKeywordString("VendorItemPosion")) Potion potionToBeUnnamed = akBaseItem as Potion If potionToBeUnnamed == potionToBeRenamed akBaseItem.SetName(originalName) Debug.Notification("Potion name changed back to " + originalName) Endif ;Endif EndEvent Potion Property potionToBeRenamed Auto ;the value should be left as none in the creationkit String Property originalName Auto ;the value should be left as none in the creationkit idk, whats that do. It might be close I havent tested it. I need a way to store the original potion name so expect wonkyness. Ill cruise by tomorrow when Im not passing out :) Link to comment Share on other sites More sharing options...
Spinner385 Posted July 18, 2012 Author Share Posted July 18, 2012 Thanks so much. I wanted to attach it to the player but I couldn't find it's object to attach it to. Was very aggravated that there is no object for crafted potions. Now I know what to look for. I knew attaching it to the magic effect was sketchy. I'll play with this again today. If I get it to work I will expand and refine it. Then I'll upload it, hope you don't mind. I'm sure others would like to know what potion they are about to chug from the 10 different ones that say restore health in the favorites menu. Again thnx very much, strangely happy to be writing code again. Link to comment Share on other sites More sharing options...
Spinner385 Posted July 18, 2012 Author Share Posted July 18, 2012 (edited) . Edited July 19, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Spinner385 Posted July 19, 2012 Author Share Posted July 19, 2012 Having serious issue with GetNthEffectMagnitude(0) This is applied to the player Scriptname PotionRenamer extends Actor Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Debug.MessageBox("Added (" + aiItemCount + ") " + akBaseItem.getname()) float mag = akBaseItem.GetNthEffectMagnitude(0) akBaseItem.setname(akBaseItem.getname() + " " + mag) endevent I tried several different things with it but I'm starting to think I can't use it this way. It seems I need to use it like this from the website: float mag = Potion.GetNthEffectMagnitude(0) Then how do I point it to akBaseItem? Do I need to some how pull the magic effect from akBaseItem first? Link to comment Share on other sites More sharing options...
steve40 Posted July 19, 2012 Share Posted July 19, 2012 @Scrivener: "VendorItemPosion" or "VendorItemPoison"? Just checking 'cause I know the CK has some awful spelling errors. @Spinner: you need SKSE to use some of those script functions, I'm assuming that you have it installed? Scriptname PotionRenamer extends Actor Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Debug.MessageBox("[PotionRenamer]Added (" + aiItemCount + ") " + akBaseItem.GetName()) Potion myPotion = akBaseItem as Potion ;make sure that the item is in fact a potion If myPotion != none && (akBaseItem.HasKeywordString("VendorItemPotion") || akBaseItem.HasKeywordString("VendorItemPoison")) float mag = myPotion.GetNthEffectMagnitude(0) Debug.MessageBox("[PotionRenamer]The potion has magnitude: " + mag) akBaseItem.SetName(akBaseItem.GetName() + " " + mag) Else Debug.MessageBox("[PotionRenamer]The item doesn't appear to be a potion.") EndIf EndEvent Link to comment Share on other sites More sharing options...
Spinner385 Posted July 19, 2012 Author Share Posted July 19, 2012 (edited) YOU FREAKING ROCK! You too scrivener! This is what I was missing Potion myPotion = akBaseItem as Potion So I understand, you declared myPotion to be a Potion (as you would string, integer, or float). Then you said akBaseItem was a potion (as in the type/child of form). So now GetNthEffectMagnitude(0) recognizes the variable and its data as a potion and not just a general form? My working script. This will be the guts of it anyway. Scriptname PotionRenamer extends Actor Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem.GetType() == 46 Debug.MessageBox("Added (" + aiItemCount + ") " + akBaseItem.getname()) Potion myPotion = akBaseItem as Potion float mag = myPotion.GetNthEffectMagnitude(0) akBaseItem.setname(akBaseItem.getname() + " " + mag) endif endevent first order of business getting rid of all the zero's from float =] Edited July 19, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Recommended Posts