DarkWolfModding Posted November 21, 2014 Share Posted November 21, 2014 How would you have a script be applied to every type of the same item in the game Is it possible? Is it easy to do? For example:lets say I have a script that changes the weight of every item in a category (like Crafting Materials or food, which could possibly be done by checking the object for a keyword) to 0 without having to attach the script to each object. Link to comment Share on other sites More sharing options...
Terra Nova Posted November 21, 2014 Share Posted November 21, 2014 (edited) An array. Let's say for example, you wanna enable every Xmarker in a specific room, and lets say there are 10 of them in there ObjectReference[] property myXmarkerArray auto Function MyArray() Int i = myXmarkerArray.length While i i -= 1 myXmarkerArray[i].enable() EndWhile EndFunctionThis doubles as a convenience function so you can change the type to whatever category you want. Like if you wanna do something to potions, just change the array type to potion. Edited November 21, 2014 by Terra Nova Link to comment Share on other sites More sharing options...
DarkWolfModding Posted November 22, 2014 Author Share Posted November 22, 2014 Could you use a quest script to make it work on every object Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 22, 2014 Share Posted November 22, 2014 Weight only really matters for the player. Maybe perhaps for followers and/or pack mules. An array is fine, but they are limited to a max of 128 entries. You could use a formlist but you'd need to pre-fill that, then you have mod & dlc compatibility to deal with. Easiest solution is to simply let the player change the weight as they come across it. A start game enabled questA player aliasAnd a script on the player alias. You'd use the OnItemAdded eventYou'd check akBaseItem for weight & anything else such as item typeIf the weight were greater than 0, change the weight.At the same time, add the item to a formlist that starts out empty. Weight changes aren't retained across saves so you have to reset them again on each game loadYou'd use the OnPlayerLoadGame eventYou'd loop through the formlist and reset each item's weight to 0 If you wanted to zero the weight of items added to followers as well, you could create an alias that points to the current follower and apply the OnItemAdded event on their alias script. But they can't run the OnPlayerLoadGame event so you'd need to reset those weights on the player alias script too. Link to comment Share on other sites More sharing options...
Terra Nova Posted November 22, 2014 Share Posted November 22, 2014 ..The average modder is never going to need all 128 elements in an array, and besides, if you need more than that, you can break it up into two arrays. Formlists also have their own limitations, and are much slower than arrays. And yes you can use a Quest script. Quest scripts are the "go to" form for holding functions and storing values. Link to comment Share on other sites More sharing options...
lofgren Posted November 22, 2014 Share Posted November 22, 2014 True it is unlikely that you would need all 128 elements of an array, but for a mod like the OP describes you have the problem that you never know what the end user is going to do. Between just two mods that I have that add new crafting supplies (Complete Crafting Overhaul and Immersive Armors) there are more than a dozen new skins, ingots, ores, carapaces, and whathaveyou for crafting. Other mods add even more items, some even specialize in nothing but adding more crafting items. The right kind of player could easily exceed the number of items in an array. Arrays have other limitations as well that in my opinon make them a poor choice for this type of mod. This is exactly the kind of thing that formlists are for. You might as well use them. Link to comment Share on other sites More sharing options...
Recommended Posts