Phrosen63 Posted March 11, 2012 Author Share Posted March 11, 2012 (edited) If I understand this whole script right you want to be able to set up traps right?So, you probably can't avoid the engine to stack more than 5 items to a group, but what's the point in setting up 10 traps to the same location anyways?I would try to make the script only drop 1 item everytime and re-add the other items again like I suggested earlier. Correct.The weird thing is, I can drop lots and lots of gems without them stacking in a group.Ten traps are better than one. = (potentionally) ten times more damage, and a higher chance of the enemies actually stepping in the trap.After play-testing my traps I have realized that it's easier and more manageable to handle two traps at a time. But some enemies are just too strong. :P I could try the re-add thing, but I'm afraid that wouldn't make much sense to the player if they just drop a bunch of items and 90% of them came back into the inventory. As there's nothing else in your Function (aka Event) than the loop code, then you could use Return as a Break. Yes, "Return" is what I was looking for. Works like a charm. Thank you.-What will happen if I use two loops in the same function, though?-Is there anything else Return could affect?-Correct me if I'm wrong, but doesn't Return break the entire function? (Not just the loop.) EDIT: I updated my script, adding Return and an if-function to check if the item was dropped: Scriptname HT_PlayerDropTrap extends ReferenceAlias {A script attached to the player, through a quest, that will replace the dummy item with an actual trap when the player drops it.} Activator[] Property HT_TrapActivator Auto MiscObject[] Property HT_MyItem Auto Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) int loop = 0 if (!akDestContainer) while loop < 5 If (akBaseItem == HT_MyItem[loop]) akItemReference.PlaceAtMe(HT_TrapActivator[loop]) akItemReference.Delete() Return endIf loop += 1 endwhile endIf endEvent EDIT #2: I played around with dropping gems. It seems I was wrong. As soon as I drop more than five at once they automatically stack. So I guess I have to live with that "bug".Unless, of course, if there's a way to make each trap item unique, so that they don't stack at all in the player's inventory? -Is that possible? Edited March 11, 2012 by Phrosen63 Link to comment Share on other sites More sharing options...
tunaisafish Posted March 11, 2012 Share Posted March 11, 2012 Yep Return will end the current Function or Event. There isn't a loop-break command as you've found, but in the case above the return is doing the same thing. BTW, I'm watchng this with interest as I do something similar in a mod that's on hold. I didn't get around to testing a dropped stack of items. I doubt that would happen in game as only one is needed at a time. I'm working on an FNV mod atm so won't get back to it for a while yet. What I do in mine is allow the item to drop, but not replace it with the Activator immediately.You can drag it around to position it, or activate the menu.So I override the standard 'Take' and my custom menu gives 'Take' or 'Deploy' options (among others).For traps that may set eachother off then that may be something to implement in yours too. I'll paste my script below, but it does have some weirdness I still have to iron out. Scriptname TunaSortCraftableScript Extends ObjectReference Message Property TunaSortDeployMsg Auto Message Property TunaSortMoveMsg Auto Message Property TunaSortRotateMsg Auto Form Property TunaSortController Auto float fTimer = 120.0 Event OnInit() BlockActivation() EndEvent Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akOldContainer && !akNewContainer Debug.Notification("Craftable dropped!") BlockActivation() RegisterForSingleUpdate(fTimer) SetAngle(0, 0, GetAngleZ()) elseif akNewContainer && !akOldContainer Debug.Notification("Craftable picked up, just crafted, or AddItem used!") UnregisterForUpdate() else Debug.Notification("Craftable switched containers!") endIf EndEvent Event OnActivate(ObjectReference akActionRef) Debug.Notification("Activated by " + akActionRef) UnregisterForUpdate() Int iBtn = 1 while iBtn iBtn = TunaSortDeployMsg.Show() If iBtn == 1 ;Deploy Debug.Notification("Deploying") PlaceAtMe(TunaSortController) ;Disable() Delete() Return ElseIf iBtn == 2 ;Take Activate(akActionRef, True) Return ElseIf iBtn == 3 ;Move Int jBtn = 1 Float fMag = 10.0 While jBtn jBtn = TunaSortMoveMsg.Show(fMag) If jBtn == 1 ;N SetPosition(X, Y + fMag, Z) ElseIf jBtn == 2 ;S SetPosition(X, Y - fMag, Z) ElseIf jBtn == 3 ;E SetPosition(X + fMag, Y, Z) ElseIf jBtn == 4 ;W SetPosition(X - fMag, Y, Z) ElseIf jBtn == 5 ;Up SetPosition(X, Y, Z + fMag) ElseIf jBtn == 6 ;Dn SetPosition(X, Y, Z - fMag) ElseIf jBtn == 7 ;Finer fMag /= 10 If fMag < 0.01 fMag = 0.01 EndIf ElseIf jBtn == 8 ;Reset Mag fMag = 10.0 EndIf EndWhile ElseIf iBtn == 4 ;Rotate Int jBtn = 1 Float fMag = 10.0 While jBtn jBtn = TunaSortRotateMsg.Show(fMag) If jBtn == 1 ; SetAngle(GetAngleX() + fMag, GetAngleY(), GetAngleZ()) ElseIf jBtn == 2 ; SetAngle(GetAngleX() - fMag, GetAngleY(), GetAngleZ()) ElseIf jBtn == 3 ; SetAngle(GetAngleX(), GetAngleY() + fMag, GetAngleZ()) ElseIf jBtn == 4 ; SetAngle(GetAngleX(), GetAngleY() - fMag, GetAngleZ()) ElseIf jBtn == 5 ; SetAngle(GetAngleX(), GetAngleY(), GetAngleZ() + fMag) ElseIf jBtn == 6 ; SetAngle(GetAngleX(), GetAngleY(), GetAngleZ() - fMag) ElseIf jBtn == 7 ;Finer fMag /= 10 If fMag < 0.01 fMag = 0.01 EndIf ElseIf jBtn == 8 ;Reset Mag fMag = 10.0 EndIf EndWhile EndIf ; 0 = Cancel EndWhile RegisterForSingleUpdate(fTimer) EndEvent Event OnUpdate() ;Timer ran out, so return the object to the player. Activate(Game.GetPlayer(), True) EndEvent Link to comment Share on other sites More sharing options...
Phrosen63 Posted March 11, 2012 Author Share Posted March 11, 2012 Yep Return will end the current Function or Event. There isn't a loop-break command as you've found, but in the case above the return is doing the same thing. I guess I have to be careful with "Return", then. =) I like your idea of having a custom menu to control the activators.However, I prefer the simplicity. One "E" click to snap the activator shut. The second "E" click picks up the trap. Drop it, and it's ready to go again. Click and hold "E" to drag the activator into place. (Only downside with this is that it's easy to accidentally set off the trap against other objects or traps lying around.) The only thing I would like to improve is to change from drop activate. So that players could add traps to their Favorite list. (I first thought of making the Dummy Item out of a potion, but quickly realized it would look silly.)Do you have any ideas for a misc object that can be activated? (I wonder if the "OnActivate" event would work for this.) Link to comment Share on other sites More sharing options...
Grasmann Posted March 11, 2012 Share Posted March 11, 2012 (edited) I also experienced this limits. IMO the scripting offers to much specific and to less common functionality.Why shouldn't there be an event, which triggers if you left click an item in the inventory? Simple, because it wasn't intended by the creator XD.But actually it is more or less exactly what you need. Edited March 11, 2012 by Grasmann Link to comment Share on other sites More sharing options...
fg109 Posted March 11, 2012 Share Posted March 11, 2012 I thought left-clicking an item in the inventory triggered it's OnEquipped event... Link to comment Share on other sites More sharing options...
Phrosen63 Posted March 11, 2012 Author Share Posted March 11, 2012 I thought left-clicking an item in the inventory triggered it's OnEquipped event... You might be right.However, OnEquipped only has "Actor akActor" as parameter. I'm afraid my script will need more parameters than that. Link to comment Share on other sites More sharing options...
fg109 Posted March 12, 2012 Share Posted March 12, 2012 Event OnEquipped(Actor akActor) akActor.DropObject(Self.GetBaseObject(), 1) EndEvent Link to comment Share on other sites More sharing options...
Grasmann Posted March 12, 2012 Share Posted March 12, 2012 I bet this event actually only is processed for real equipment.But it could work if you would make your trap a weapon ... but then again it probably really would equip it and you would have to cope with that lol. Link to comment Share on other sites More sharing options...
fg109 Posted March 12, 2012 Share Posted March 12, 2012 (edited) You're right, I just tried it out on some wooden bowls and it didn't work. I actually tried some other things too. The akItemReference from the OnItemRemoved event only returns one of the items. I gave the player an alias and them dropped 10 iron daggers. I saved the akItemReference to a variable, and then scripted the player to activate it. The "Iron Dagger (10)" on the ground disappeared, but I only got 1 iron dagger back in my inventory. I also tried putting a script on the object instead. I scripted the iron daggers to add an iron dagger to the player's inventory when they received the OnContainerChanged event. Adding the daggers to the player using the console didn't trigger it. Neither did dropping them on the ground the first time. But when I picked them back up (10 of them at once), one of their scripts fired off and so I ended up with 11. But that means the other 9 daggers' scripts didn't fire. There was some strange behavior when I started dropping and adding daggers. Sometimes, they ended up in two piles. A pile of 9 daggers and then a pile of 1 dagger (the one that had the script running). The daggers added by that 1 dagger also seemed to have running scripts. Edited March 12, 2012 by fg109 Link to comment Share on other sites More sharing options...
Grasmann Posted March 12, 2012 Share Posted March 12, 2012 (edited) I still think the best method would be to have an event that triggers on a left click.I guess that's what most mods of this kind could use.I hate the limits this script language is giving us XD ... hopefully the skse will actually extend this somehow.But I don't know what is planned there at all, or if it is even possible to extend it that way. For another mod idea of mine I searched for a way to display a message on screen. I don't mean on the top-left corner or in the middle of the screen with a button interrupting the gameplay, but just a message that I can display at the coordinates X, Y ... but you think this is possible ... forget it! XD Edited March 12, 2012 by Grasmann Link to comment Share on other sites More sharing options...
Recommended Posts