Kexikus 995 Posted May 12, 2017 I'm working on a script that swaps a hidden item on a partymember. So what I'm doing is basically this (sItem is a string with the item's tag): object oOldItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, OBJECT_SELF); object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF); if (GetIsObjectValid(oOldItem)) { DestroyObject(oOldItem); } DelayCommand(0.2, ActionEquipItem(oNewItem, INVENTORY_SLOT_CARMOUR, TRUE)); And that's working perfectly fine. However, when I run this script in a dialog, I always get the pop-up message that I lost and gained an item. I'd very much prefer it this message did not appear as these Creature Hide items are a hidden game mechanic that the player shouldn't be informed about. Is there any way to do that? Edit: Oh, and a second question: Are there switch-cases possible in KotOR / TSL or do I have to use if-else statements all the time? Quote Share this post Link to post Share on other sites
bead-v 251 Posted May 12, 2017 (edited) For your second question: void main(){ int nParam = GetScriptParameter(1); switch(nParam){ case 0: { //Do stuff when called with dialog parameter 1 == 0 } break; case 1: { //Do stuff when called with dialog parameter 1 == 1 } break; default: { //Default case } break; } } This is basically how all my dialog scripts look in TSL. A very important note: you can leave out the {braces} between case and break; as long as there are no variable definitions in there. But if there are, the compiler does not give any warning and will compile the script, but you will get all kinds of problems in the game that make absolutely no sense and you can waste a lot of time figuring out what's wrong if you don't know about this. So especially in kotor scripting, it is a very good practice to always write the braces. break; can be left out to allow falling through to the next case, just like in C++. As for your first question, no idea, sorry. I hope there is a way – it sounds pretty useful! Edited May 12, 2017 by bead-v Quote Share this post Link to post Share on other sites
djh269 264 Posted May 12, 2017 You may find the first questions answer within this TSL script, it controls Mandalores implant switching and doesn't pop up with an Item Lost/Received message:a_swapimplant.nss a_swapimplant.ncsa_swapimplant.nss 1 Quote Share this post Link to post Share on other sites
Kexikus 995 Posted May 13, 2017 Thank you for your replies. It looks like they did not block this message in a_swapimplant.nss but instead used a completely different method by adding the effects directly to Canderous. The problem here is that ClearAllEffects() will clear these effects which makes the entire thing pretty pointless. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted May 15, 2017 Have you tried emulating commented out code from a_swapimplant.nss? Changing this: object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF); To this: object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF, 1, TRUE); 1 Quote Share this post Link to post Share on other sites
Kexikus 995 Posted May 15, 2017 No, I didn't... And now I feel like an idiot. I didn't check the commented out part at all but that was indeed the solution. Thank you very much So to answer my original question: At least in TSL you can add "TRUE" as an additional argument to both CreateItemOnObject() and DestroyObject() and it won't show the "Item received/lost" message. 1 Quote Share this post Link to post Share on other sites
djh269 264 Posted May 15, 2017 Have you tried emulating commented out code from a_swapimplant.nss? Changing this: object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF); To this: object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF, 1, TRUE); Is this the same as Kotor 1? No, I didn't... And now I feel like an idiot. I didn't check the commented out part at all but that was indeed the solution. Thank you very much I thought it was strange that p_mandalore.utc has a hide item already placed in his items. I thought the script applies the bonuses twice when I first read a_swapimplant.nss Quote Share this post Link to post Share on other sites
Kexikus 995 Posted May 15, 2017 Is this the same as Kotor 1? I don't think so or they would have used it for the HK upgrades. The documentation in K1's nwsscript.nss has no information on that either. The latter is also true for TSL but that's probably due to Obsidian not updating the documentation properly when updating the function. 1 Quote Share this post Link to post Share on other sites
djh269 264 Posted May 15, 2017 I don't think so or they would have used it for the HK upgrades. The documentation in K1's nwsscript.nss has no information on that either. The latter is also true for TSL but that's probably due to Obsidian not updating the documentation properly when updating the function. Ah that's fair play. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted May 15, 2017 The new functionality of the CreateItemOnObject and DestroyObject functions are advancements made by Obsidian and won't work in K1. The CreateItemOnObject function has an optional bHideMessage argument at the very end that defaults to 0 (FALSE). This argument will hide the popup. The DestroyObject function has the optional bHideFeedback argument, which I would assume prevents the entry from being posted to the Feedback screen. Quote Share this post Link to post Share on other sites