francogp Posted March 12, 2016 Share Posted March 12, 2016 Hello, Is there a way to access in a lua file an item introduced via script file (located on the script folder)? I need to access an item and modify a value without overriding it (improving future compatibilities). Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 12, 2016 Share Posted March 12, 2016 Moved to Mods Help. The short answer is: "Yes, but I can't find the code I used to do it . . . " Will poke around if I can find the time tonight. francogp 1 Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 12, 2016 Share Posted March 12, 2016 Take a look at ScriptManager in the Lua files. You can then use it to get an Item or Recipe object and alter its properties directly. Hopefully I'm not wrong about that. ZombiesLoveBrainiacs 1 Link to comment Share on other sites More sharing options...
francogp Posted March 12, 2016 Author Share Posted March 12, 2016 22 minutes ago, EnigmaGrey said: Take a look at ScriptManager in the Lua files. You can then use it to get an Item or Recipe object and alter its properties directly. Hopefully I'm not wrong about that. I can't find any lua file using that ScriptManager Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 12, 2016 Share Posted March 12, 2016 Search "scriptmanager" (9 hits in 7 files) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\ISUI\ISInventoryPaneContextMenu.lua (1 hit) Line 1501: local item = ScriptManager.instance:FindItem(itemType) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\LastStand\ISUI\ISChallenge2VariousItemWindow.lua (1 hit) Line 71: local item = ScriptManager.instance:getItem(itemType) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\LastStand\ISUI\ISChallenge2WeaponUpWindow.lua (1 hit) Line 61: local item = ScriptManager.instance:getItem(itemType) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\Tests\RecipeTests.lua (3 hits) Line 316: local recipe = ScriptManager.instance:getRecipe("Base.Make Mattress") Line 350: local recipe = ScriptManager.instance:getRecipe("Base.Clean Bandage") Line 377: local recipe = ScriptManager.instance:getRecipe("Base.Rip sheets") C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\TimedActions\ISDumpContentsAction.lua (1 hit) Line 49: local item = ScriptManager.instance:FindItem(itemType) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\server\Farming\ScavengeDefinition.lua (1 hit) Line 245: local item = ScriptManager.instance:FindItem(v.type) C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\server\Items\ItemPicker.lua (1 hit) Line 247: local item = ScriptManager.instance:FindItem(itemname) Link to comment Share on other sites More sharing options...
francogp Posted March 12, 2016 Author Share Posted March 12, 2016 1 minute ago, EnigmaGrey said: snipt thanks! I tried to do that search with cortana... but it seems to fail :S Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 12, 2016 Share Posted March 12, 2016 Notepad++ has a very nice "Find in Files" function. francogp, Svarog and xenoglyph 3 Link to comment Share on other sites More sharing options...
francogp Posted March 12, 2016 Author Share Posted March 12, 2016 Just now, EnigmaGrey said: Notepad++ has a very nice "Find in Files" function. Another "related" question. Is there a way to access this items, but only after scripts loading time? Link to comment Share on other sites More sharing options...
francogp Posted March 13, 2016 Author Share Posted March 13, 2016 Think that its solved, I'm using Events.OnPreMapLoad., but don't know its fine Link to comment Share on other sites More sharing options...
Svarog Posted March 13, 2016 Share Posted March 13, 2016 (edited) Someone made something for it. I believe it is related to what you originally asked for.http://steamcommunity.com/sharedfiles/filedetails/?id=566115016 Edited March 13, 2016 by Svarog francogp 1 Link to comment Share on other sites More sharing options...
francogp Posted March 13, 2016 Author Share Posted March 13, 2016 @Svarog @EnigmaGrey Thanks all for the help! I managed to solve it doing: local item = ScriptManager.instance:getItem(itemname); --load the item if item then item:setWeaponSprite(newValue); else print("WARNING: can't find item " .. itemname); end Link to comment Share on other sites More sharing options...
ShuiYin Posted March 14, 2016 Share Posted March 14, 2016 If only we can override recipes too and avoid duplicate recipes. Pls if someone know how to do it will really make modding much easier and less conflicting. Link to comment Share on other sites More sharing options...
francogp Posted March 14, 2016 Author Share Posted March 14, 2016 Just now, ShuiYin said: If only we can override recipes too and avoid duplicate recipes. Pls if someone know how to do it will really make modding much easier and less conflicting. in the pinned tutorial there's a way to override scripted items. If you only want to modify them, you should use the code that I post in this thread. Link to comment Share on other sites More sharing options...
ShuiYin Posted March 14, 2016 Share Posted March 14, 2016 (edited) 19 hours ago, francogp said: in the pinned tutorial there's a way to override scripted items. If you only want to modify them, you should use the code that I post in this thread. Really? Ill check again. Last time i looked i cant find a way to override vanilla recipes using lua. I can override object properties in game tho using lua. I remember now i can get the recipes but there is no set method that can change the recipe properties. If you can i think many modders want to know this or we can approach from another angle: is there a way through lua to delete current existing recipe? i think this one should be easier to do, ill post in help section hopefully someone can come up with something Edited March 15, 2016 by ShuiYin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now