ItemZed (updated 1.1b)
5 5

32 posts in this topic

We're seeing a few mods popping up on the Workshop that have been built through ItemZed, which is awesome. So if you're doing one too then please let us know - and give feedback :)

Share this post


Link to post
Share on other sites

I just downloaded the tool so I could play around with it a bit, experiment. I am however running into a problem that kind of makes me unable to properly load in the base game files and thus, doing any experimenting with it. And with kind of, I mean it does not work.

 

I downloaded the tool and put the folder in my modding tool file, which is on my desktop. I started the tool and it was unable to locate my Zomboid folder, which is in my steam folder. I manually navigate to it and select it. However, the option to import items from the base game does not appear. I have tried selecting the root folder \Projectzomboid and the media folder \Projectzomboid\Media, but both result in the same.

 

Any idea what could cause this? I am on windows 7, 64 bit, the game is located in my steam folder which is in my Programfiles(x86) folder.

Share this post


Link to post
Share on other sites

GHawkins the import button, imports the currently selected mod data. Try hitting file, create new mod, fill in the information it asks for and see if that works for you.

Share this post


Link to post
Share on other sites

I'm having a similar problem to GHawkins. I've watched ItemZed Additional Options by TurboTuTone several times and I'm not sure what I'm doing wrong. Is there a video or guide somewhere that I'm not seeing for how to set this up?

Share this post


Link to post
Share on other sites

@Void, @Crowborn and others having the issue of not seeing anything in the distribution tab, make sure youve got a updated IWBMS on steam like @russafiii mentioned and then it should be working properly. Ill update OP to include a little note concerning this.

 

@thiosk Indeed the distribution panel isnt well suited for bulk insertion operations like that atm.
Ideally id like to fix up the entire distibution panel a bit at some point in the near future so the points youve raised work better allong with some more drag and drop improvements.

However when doing amounts 250 items this may still result in quite some dragging, depending on how they need to be distributed in the list lua might be a valid option as well.

Ive played around with creating a little helper script for that purpose and came up with the following which may be helpful to you:

 

DistributionInsertion

Spoiler

-- Script can insert items of a certain module to a list of target distribution containers.

-- SETTINGS ---------------------------------------
-- change local variables accordingly and run script.
local module = "myModule";
local spawnChance = 1.0;
local dontAddIfItemExist = true; -- if set to true this will not add a item if the target container already contains that item.
local targetContainers = {
	"aesthetic.counter",
	"bakery.counter",
	"all.shelves",
	"all.fridge",
	"grocery.crate",
	"Schoolbag",
	"Purse",
};

-- SCRIPT -----------------------------------------

function string:split(sep)
   local sep, fields = sep or ":", {}
   local pattern = string.format("([^%s]+)", sep)
   self:gsub(pattern, function(c) fields[#fields+1] = c end)
   return fields
end

function run()
  -- collect the fullnames for items from the defined module
  local items = {};
  for v in DataManager.Objects do
    if v.ObjectType.IsItem then
      if v.ParentModule~=nil and v.ParentModule.Name==module then
	  table.insert(items, v.FullName);
      end
    end
  end

  -- now find the defined target containers for insertion
  local distRoot = DataManager.DistributionContainer;

  for _,s in ipairs(targetContainers) do
    local c = distRoot;
    for _,val in ipairs(string.split(s,".")) do
      local cache = c;
      if c.Children.Count>0 then
        for i=0,c.Children.Count-1 do
          if c.Children[i].Name==val then
            c = c.Children[i];
            break;
          end
        end
      end

      if c==cache then
        c = nil;
        break;
      end
    end

    if c~=nil and c~=distRoot then
      --print("container found!");
      if not c.IsItemContainer then
        print("container '"..s.."' is not a itemcontainer");
      else
        -- interting the earlier collected items into this container
        for _,item in ipairs(items) do
          local canAdd = true;
          if dontAddIfItemExist then
            if c.Items.Count > 0 then
              for i=0,c.Items.Count-1 do
                if c.Items[i].IsMod==DataManager.IsModMode and c.Items[i].Item==item then
                  canAdd = false;
                  break;
                end
              end
            end
          end
          if canAdd then
            c.addItem(item,spawnChance,DataManager.IsModMode,true);
          end
        end     
      end
    else
      print("could not find container: "..tostring(s));
    end

  end
  print("Success!");
end

 


The top part has some settings you can modify, the way it works would be to have all the items that you wanna add in bulk to the distribution in a seperate module wich will act as a category.
You can set a default spawn chance and add target containers, the nested containers need to be seperated with dots as per example and be aware that the container names are case sensitive.
When running the script it will add all the items from the defined module to the targetcontainers, afterwards you can optionally use the right side item filter box to filter on the module name (see img) instead of item name incase you need to override some default spawn chances of some of the items.

7c3caa82e24601403db0301328f97ba8.png


Additionally ive also created helper script to remove items from the distributions in bulk, it has somewhat similar settings in the top part:

 

DeleteItemsFromDistribution

Spoiler

-- Script to delete items from distribution.

-- SETTINGS ---------------------------------------
-- change local variables accordingly and run script.

-- any items belonging to modules defined here will be removed.
-- to disable modules set it to false, nil or a empty table.
local modules = { 
	"myModule" 
};

-- any items defined here (full name including module), will be removed.
-- set to false, nil or empty table to disable.
local items = {
	"myModule.testItemC",
}

-- optionally define spawnchances which the items must match, set spawnChances to false, nil or empty table to disregard spawnchance.
local spawnChances = {
	1.0,
	2.5,
}

-- define target containers to remove items from 
-- NOTE: if set to false, nil or empty table then the specified items will be removed from ALL containers.
local targetContainers = {
	"aesthetic.counter",
	"bakery.counter",
	"all.shelves",
	"all.fridge",
	"grocery.crate",
	"Schoolbag",
	"Purse",
};

-- SCRIPT -----------------------------------------

function string:split(sep)
   local sep, fields = sep or ":", {}
   local pattern = string.format("([^%s]+)", sep)
   self:gsub(pattern, function(c) fields[#fields+1] = c end)
   return fields
end

function run()
  local doModules = modules~=nil and #modules>0;
  local doItems = items~=nil and #items>0;
  local doChances = spawnChances~=nil and #spawnChances>0;
  --local doTargets = targetContainers~=nil and #targetContainers>0;
  
  local finalItems = {};
  if doItems then
    for k,v in ipairs(items) do
      addItem(finalItems, v);
    end
  end

  if doModules then
    for k,v in ipairs(modules) do
      addItemsFromModule(finalItems, v);
    end
  end

  if #finalItems>0 then
    local containers = getContainers();
    for _,c in ipairs(containers) do
      if c.Items.Count>0 then
        for _,item in ipairs(finalItems) do
          for i = c.Items.Count-1,0,-1 do
            if c.Items[i].Item==item and c.Items[i].IsMod==DataManager.IsModMode then
              local canRemove = not doChances;
              if doChances then
                for _,chance in ipairs(spawnChances) do
                  if chance==c.Items[i].Chance then
                    canRemove=true;
                    break;
                  end
                end
              end
              
              if canRemove then
                c.Items.RemoveAt(i);
              end
            end
          end
        end
      end
    end
    print("Success!");
  else
    print("Warning: no valid modules or items to remove.");
  end
end

local function getContainersWhiteList()
  local containers = {};
  local distRoot = DataManager.DistributionContainer;

  for _,s in ipairs(targetContainers) do
    local c = distRoot;
    for _,val in ipairs(string.split(s,".")) do
      local cache = c;
      if c.Children.Count>0 then
        for i=0,c.Children.Count-1 do
          if c.Children[i].Name==val then
            c = c.Children[i];
            break;
          end
        end
      end

      if c==cache then
        c = nil;
        break;
      end
    end

    if c~=nil and c~=distRoot and c.IsItemContainer then
      table.insert(containers, c);
    end

  end
  return containers;
end

local function getContainersRecurs(_cont, _list)
  if not _cont.IsItemContainer and _cont.Children~=nil and _cont.Children.Count>0 then
    for i=0, _cont.Children.Count-1 do
      getContainersRecurs(_cont.Children[i], _list);
    end
  elseif _cont.IsItemContainer then
    table.insert(_list, _cont);
  end
  return _list;
end

function getContainers()
  if targetContainers~=nil and #targetContainers>0 then
    return getContainersWhiteList();
  else
    return getAllContainersRecurs(DataManager.DistributionContainer, {});
  end
end

function addItemsFromModule(_itemList, _module)
  if _module==nil then
    return false;
  end
  if DataManager.Objects.Count > 0 then
    for i=0,DataManager.Objects.Count-1 do
      local obj = DataManager.Objects[i];
      if obj.ObjectType.IsItem and obj.ParentModule~=nil and obj.ParentModule.Name==_module  then
        addItem(_itemList, obj.FullName);
      end
    end
  end
end

function addItem(_itemList, _item)
  for k,v in ipairs(_itemList) do
    if v==_item then
      return;
    end
  end
  table.insert(_itemList, _item);
end

 


Hope this is usefull, both scripts adjust to the mode youre running the program in (mod or dev), in mod mode the remove script for example will not touch and base game entries.

Also, if there might be need for other similar scripts feel free to post a request in this thread!

 

Regards,
Turbo

Batsphinx and Rathlord like this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
5 5