yetibear Posted January 4, 2014 Share Posted January 4, 2014 Hi ya'll I'm trying to write a script that will remove all alchemy ingredients from my inventory and place them in a specified container. But I just can't get it to work. Can anyone help. Attached is the script I have so far, writen in notepad. Any help would be much appreciated, and thanks in advance. Link to comment Share on other sites More sharing options...
Sjogga Posted January 4, 2014 Share Posted January 4, 2014 (edited) Create a FormList with all ingredints, then use this:Scriptname _TestAlchemyRemoverScript extends ObjectReference Message Property _TestMessage auto Container Property _testBarrel Auto Formlist Property ingredientList auto Event OnActivate (ObjectReference AkActionRef) int aiButton = _TestMessage.show() If aiButton == 0; Open Activate(_testBarrel) ElseIf aiButton == 1; Store ingredients AkActionRef.RemveItem(IngredientList, 999, true, _testBarrel) ElseIf aiButton == 2; Cancel EndIf EndEvent Edited January 4, 2014 by Sjogga Link to comment Share on other sites More sharing options...
yetibear Posted January 6, 2014 Author Share Posted January 6, 2014 Sorry to take so long to respond, it was the wee man's birthday Put script on to barrel, created form list with all ingredients and message for options Got message (13,17): type mismatch on parameter 1 (did you forget a cast?)(15,28): mismatch on parameter 4 (did you forget a cast?) I have no idea what this means though. Any suggestions Link to comment Share on other sites More sharing options...
Xander9009 Posted January 7, 2014 Share Posted January 7, 2014 Typo. Forgot the "O" in "RemoveItem". Not sure if that's causing the error, but it's there. If that still doesn't work, try thisScriptname _TestAlchemyRemoverScript extends ObjectReference Container Property _TestBarrel Auto Message Property _TestMessage Auto Event OnActivate (ObjectReference AkActionRef) Int aiButton = _TestMessage.show() If ( aiButton == 0 ) _TestBarrel.Activate(Game.GetPlayer()) ElseIf ( aiButton == 1 ) Int i = Game.GetPlayer.GetNumItems() While ( i > 0 ) i -= 1 If ( Game.GetPlayer.().GetNthForm(i).GetType() == 30 ) Game.GetPlayer.RemoveItem(Game.GetPlayer().GetNthForm(i), 1, True, _TestBarrel) EndIf EndWhile Debug.Notification("Finished") EndIf EndEventI've already written it out, so I'll leave it there, but it might also be the activate bit. You might try replacing the Activate line in the first script with the activate line from mine "_TestBarrel.Activate(Game.GetPlayer())" Link to comment Share on other sites More sharing options...
Sjogga Posted January 7, 2014 Share Posted January 7, 2014 _TestBarrel shouldn't be a Container Property; it should be an ObjectReference Property. Link to comment Share on other sites More sharing options...
yetibear Posted January 8, 2014 Author Share Posted January 8, 2014 Script works well now thanks, Changed the container property and added the "o". Found that I did not need the first option of opening the barrel as it automatically opens and shows the script at the same time, don't know why, any ideas how to show the script first would be much appreciated. Thanks for all the help though so far, I'm going to insert the script into my mod. Link to comment Share on other sites More sharing options...
Xander9009 Posted January 8, 2014 Share Posted January 8, 2014 (edited) This might do the trick. Blocking the activation. Unfortunately, I don't know the BlockActivation function well enough to know if I've over-complicated matters. It might not be necessary to unblock activation before activating it with a script and then re-blocking it.Scriptname _TestAlchemyRemoverScript extends ObjectReference Message Property _TestMessage auto ObjectReference Property _testBarrel Auto Formlist Property ingredientList auto Event OnInit () BlockActivation() EndEvent Event OnActivate (ObjectReference AkActionRef) int aiButton = _TestMessage.show() If aiButton == 0; Open BlockActivation(false) Activate(_testBarrel) ElseIf aiButton == 1; Store ingredients AkActionRef.RemoveItem(IngredientList, 999, true, _testBarrel) ElseIf aiButton == 2; Cancel EndIf Utility.Wait(0.1) BlockActivation() EndEventI think we both assumed this was going on a button or switch, not directly on the container. EDIT: Immediately after posting it, I realized (the very obvious fact) that if I block activation, then you might not be able to activate it at all. But the page for BlockActivation says it'll still receive the OnActivate event. I suspect that would only be the case for being activated from scripts, though, not by pressing E. Maybe Sjogga can make it cooperate if that's the case, but in the mean time, just put the script on a button or lever instead of directly on the container if this doesn't work. @Sjogga, are you certain your activate function is correct? The CK website shows that for the player to activate a door, you put NeatDoor.Activate(Game.GetPlayer()). Edited January 8, 2014 by Xander9009 Link to comment Share on other sites More sharing options...
Sjogga Posted January 8, 2014 Share Posted January 8, 2014 On 1/8/2014 at 7:31 AM, Xander9009 said: @Sjogga, are you certain your activate function is correct? The CK website shows that for the player to activate a door, you put NeatDoor.Activate(Game.GetPlayer()). Then the CK Wiki is right. I've used that function like once. As for the problem at hand, exactly what triggers the script? Link to comment Share on other sites More sharing options...
yetibear Posted February 1, 2014 Author Share Posted February 1, 2014 Sorry for the delay again, been stuck doing everything I think. The idea was to get the script show when you activate the container so that it will automatically store all of the selected goods, like ingredients. As a bye the bye, I have noticed that the script works with anything, but if I set it up to store books or potions it doesn't remove them until you close the container as opposed to when you click on your choice like it does with everything else. Also the potion container does not seem to take potions made from the alchemy bench just vanilla potions, Thanks for all the help so far though. I am so nearly there with my mod its killing me and I would not have managed without the help of people like yourselves. So thanks again. Link to comment Share on other sites More sharing options...
Xander9009 Posted February 1, 2014 Share Posted February 1, 2014 (edited) So, you want to look at the container, activate it, but not have the container open, right? Instead, have a message that lets you choose to open it or to store items? That might be possible, but you be better off doing one of two other things. Either put a button/lever nearby and activate that, instead. Or put an activable primitive around the container so it looks like you're activating the container, but you're really activating an invisible box around the container. It seems like the better option, at first, but I've had lots of trouble making that method work. The potions from the alchemy bench wouldn't be potions that exist in your form list, so they're ignored. What I would try is adding the keywords MagicAlchBeneficial and MagicAlchHarmful to your potions formlist. (You could almost remove everything else since every potion should have one or the other). Crafted potions have those keywords, too. Confirmed with the quest WICraftItem03. Its scenes check the created items for those keywords to decide what the NPCs will say (like when a nearby alchemist says "You've created a truly vile poison"). Don't know why it would transfer books and potions after closing while doing everything else before. Best guess would be that it simply processes the others faster. I'm pretty sure there's a way to make the script keep running even while menus are open, but I don't know how. EDIT: I tried it with keywords for something else I was working on just now and it didn't seem to work. Only way I can think of then would be to cycle through all items and either check their type or check for the keywords. Using VendorItemPotion might get poisons as well, or it might not. Edited February 1, 2014 by Xander9009 Link to comment Share on other sites More sharing options...
Recommended Posts