garymevs Posted October 30, 2013 Share Posted October 30, 2013 Couldn't see a way to do this :/ any ideas? Link to comment Share on other sites More sharing options...
cmkb3 Posted October 30, 2013 Share Posted October 30, 2013 Can you specify what exactly you're trying to do to clear up the question? If you simply need a static list of the possible in-game items, view items.txt and newitems.txt in the ProjectZomboid/media/scripts folder. Link to comment Share on other sites More sharing options...
garymevs Posted October 30, 2013 Author Share Posted October 30, 2013 I was hoping for a method/function that would return a table/array of items that are currently loaded in the game Link to comment Share on other sites More sharing options...
RoboMat Posted October 30, 2013 Share Posted October 30, 2013 I don't think there is a function for that. What do you need it for? Link to comment Share on other sites More sharing options...
garymevs Posted October 30, 2013 Author Share Posted October 30, 2013 I wanted to do something similar to zSpawn as a first step into modding but I didn't want to manually list every single item :/ I would parse the item files but I also wanted to keep support for other mods, any ideas on what I could do? Link to comment Share on other sites More sharing options...
cmkb3 Posted October 30, 2013 Share Posted October 30, 2013 Well, the list of items available for the game to use appears to be contained in <THashMap> ItemMap which is generated within an instance of ScriptModule. Edit: I know that may not seem terribly useful, but looking through the java files is starting to make me dizzy. >_< It's somewhere to start. Actually, I'm not sure if a particular module contains all the entries from a particular text file or if each entry is its own module where the parameters are the entries in the hashmap and oh no I've gone crosseyed. . . Link to comment Share on other sites More sharing options...
garymevs Posted October 30, 2013 Author Share Posted October 30, 2013 That should do it, thanks! I can't think of a way to access that class or the contents of it with just lua :/ If anybody can think of anything that would be great Link to comment Share on other sites More sharing options...
RoboMat Posted October 30, 2013 Share Posted October 30, 2013 I have a function in my modding utilities, which converts arrays to lua tables: ----- Converts a java arrayList to a lua table. Remember-- that lua tables start at index 1. Thanks to lemmy101.---- @param _arrayList - The arrayList to convert---- @author RoboMat-- @since 1.5.0--function Utility.convertArrayList(_arrayList) local list = _arrayList; local itemTable = {}; for i = 0, list:size() - 1 do table.insert(itemTable, list:get(i)); end return itemTable;endMaybe that helps. Link to comment Share on other sites More sharing options...
garymevs Posted October 31, 2013 Author Share Posted October 31, 2013 While that is helpful, my issue is with accessing the array not converting it to a table :/ Is there some kind of bindClass function for the lua interpreter PZ uses? or am I going about this the wrong way? Link to comment Share on other sites More sharing options...
RoboMat Posted October 31, 2013 Share Posted October 31, 2013 Oh ... totally misunderstood your problem haha Afaik you can only access public methods via lua. You could ask for a Getter in the lua requests thread though Okay just talked to RJ ... there is no item list - the HashMap is something different. So parsing the .txt files is the only way I can think of atm. Link to comment Share on other sites More sharing options...
garymevs Posted October 31, 2013 Author Share Posted October 31, 2013 Ok Thanks for the help. Do you want me to mark this as solved? Link to comment Share on other sites More sharing options...
RoboMat Posted October 31, 2013 Share Posted October 31, 2013 If you feel it has been answered sufficiently, then yes it would be nice if you marked it as solved 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