Xiron Posted March 11, 2010 Share Posted March 11, 2010 Ok, so the purpose of this bit of script was to attach it to a container with the effect of it doubling the count of the item placed inside it (1 at a time) once you exited its inventory menu screen. This function works fine, when I open the container and place something inside, and open/close the container, the item count doubles. HOWEVER, if I open the container and close it without putting any items into it, or open it, put items in it, close/open it again and remove them, the container will not reopen. Script follows in code tags, I cannot find an error in my code, what did I do wrong? :/ Scriptname ItemDuplicatorChestScript short runvar == 0 short itemcount == 0 ref boxeditem begin OnActivate if runvar < 5 set runvar to runvar + 1 Activate elseif runvar == 5 Activate endif End begin Gamemode if runvar >= 1 set boxeditem to (GetInventoryObject 0) set itemcount to (GetItemCount boxeditem) if itemcount >= 1 if boxeditem == MS04HornGift removeitem MS04HornGift itemcount set boxeditem to MinotaurHorn elseif boxeditem == MG01Bonemeal removeitem MG01Bonemeal itemcount set boxeditem to bonemeal elseif boxeditem == MG13VampireDust removeitem MG13VampireDust itemcount set boxeditem to vampiredust endif additem boxeditem itemcount endif set runvar to runvar - 1 endif End Link to comment Share on other sites More sharing options...
Vagrant0 Posted March 11, 2010 Share Posted March 11, 2010 (edited) Offhand I'd be tempted to say that the problem is due to either the container returning a different item after it's opened and closed, or because the counter you use gets screwed up when the container isn't empty. A solution might be to just purge the container (removeallitems) to the player if it's activated after the item is duplicated. Then you remove the possibility of the two instances where the script fails from happening, or should. You should also refrain from bumping posts that have less than a few days since the last response. In particular, scripting and higher level modding questions can take longer to answer since there aren't many who know enough, and answering them usually requires having the time to really look at what is going on. Edited March 11, 2010 by Vagrant0 Link to comment Share on other sites More sharing options...
Pronam Posted March 11, 2010 Share Posted March 11, 2010 short runvar == 0short itemcount == 0 Variables are already put at 0 at the beginning and other than that, it won't have any effect. Link to comment Share on other sites More sharing options...
Xiron Posted March 11, 2010 Author Share Posted March 11, 2010 I apologize for the bumping, I've just been frustrated with it for a day now heheh.... EDITEDIT: Solved my problem, figured out that it had to do with the items, but not returning a different item. Apparently it does NOT like null returns, so the following code is the final (fixed, working) version. Scriptname ItemDuplicatorChestScript short runvar = 0 long itemcount = 0 ref boxeditem begin OnActivate set runvar to 1 Activate End begin Gamemode if runvar > 0 set runvar to 0 if GetNumItems > 0 set boxeditem to (GetInventoryObject 0) set itemcount to (GetItemCount boxeditem) if boxeditem == MS04HornGift removeitem MS04HornGift itemcount set boxeditem to MinotaurHorn elseif boxeditem == MG01Bonemeal removeitem MG01Bonemeal itemcount set boxeditem to bonemeal elseif boxeditem == MG13VampireDust removeitem MG13VampireDust itemcount set boxeditem to vampiredust endif RemoveAllItems set itemcount to itemcount + itemcount additem boxeditem itemcount endif endif End Link to comment Share on other sites More sharing options...
Recommended Posts