Jump to content

MXXIV

Member
  • Posts

    86
  • Joined

  • Last visited

Posts posted by MXXIV

  1. 19 minutes ago, ShuiYin said:

    You should :)its quite fun to do

    Agreed. I wasn't saying it's wrong to ask for a feature, I just thought you are upset that I said it's easy but still it isn't added. Hence I explained that the problem isn't technical but is a HR issue.

     

    21 minutes ago, ShuiYin said:

    I happen to be an interior designer :Pbut i really like this game so i go into modding. I guess its my present priority hobby now.

    Nice to see people being drawn into programming by games! :)

  2. 29 minutes ago, King Kitteh said:

    So I don't see why this can't be added to the game

    It can be added. But most modders, I suppose, either work as programmers or study. I already added two mods that add highly requested or useful functions in less than a month. But nor my girlfriend nor my friends will be happy if I spend all of my time coding. This weekend I'm going to British sitcom festival, so maybe afterwards I'll look into it.

     

    Another issue here is that rather than programming, this is going to be a tedious collecting and linking textures to make sure making window hole produces wall with same texture. If someone told me how to list textures efficiently, world-object based mods would be way faster to develop.

     

    Also, if you're in hurry to get this mod, do not forget you can try to develop it yourself and people like me can help you on IRC or forums. Waiting for others to do stuff for you isn't the most efficient way to get stuff done.

  3. Following the Project Zomboid pattern, I tried to add translation file for my mod:

     

    .../Zomboid/mods/MyModName/media/lua/shared/Translate/EN/MyModName.lua

     

    To no avail. Even editing built in translation files didn't allow me to query getText for my string. I'm confused.

  4. I decided to make list of some code snippets I have used so far. I will try to sort them but generally just use CTRL+F to find what you need.

    Lua tricks

    I aim to share PZ related Lua tricks. I assume here you understand what prototype inheritance is and how does OOP work in Lua. However some things can work for you well without understanding them.

    Subclassing Lua "class"

    In PZ files, following function is used to subclass a class:

    MyClass = BaseClass:derive("MyClass")

    This only works with classes defined in PZ library or classes that inherit from it.

    Class constructor

    Generally, constructors look like this:

    function MyClass:new()
        -- Create a map and set iteself as map prototype
    	local o = {}
    	setmetatable(o, self)
        -- not sure or care what this is
        -- inheritance actually worked without it too
    	o.__index = self
    	return o
    end

    Overriding built-in method

    Suppose you want to patch some built-in PZ method but not completely rewrite it. You can do this by saving the old function in local variable. Keep an eye on : and . difference!

     

    local old_doStuff = PzOriginalCode.doStuff;
    function MyMod:doStuff() 
        -- Do some stuff
        print("Doing stuff real hard");
        -- Call original function
        old_doStuff(self);
        -- Do this to preserve return value
        -- return old_doStuff(self);
    end

    Loop over numeric items in array

    If you have array that contains enumerated list, you can loop over these. Note the difference between pairs and ipairs:

    local values = {"first", "second", "third"};
    for index,value in ipairs(values) do
        print(value);
    end

    Loop over named items in table

    This comes handy when you have something indexed by item names for example. Note the difference between pairs and ipairs:

    local item_type = {Axe="weapon", Berry="food", Lipstick="garbage"};
    for item_name,type_name in pairs(item_type) do
        print(item_name.." is "..type_name);
    end

    Items

    Item script files are /media/scripts/items.txt, /media/scripts/newitems.txt, media/scripts/items_radio.txt.

    Get item name translation

    To do this, use ScriptManager.getItemName which will return English name. Then put English name into getItemText which comes from global lua object. Whole:

    getItemText(ScriptManager.getItemName("Base.Axe"));

    This method is safe from null pointer errors and returns original string on failure.

    Get item texture object

    This will provide you with Texture object if you have item name.

    local item = InventoryItemFactory.CreateItem("Base.Axe");
    local texture = nil;
    if item then
        texture = item:getTex();
    end

    Add item into inventory

    Requires instance of IsoGameCharacter (eg. player), uses ItemContainer which is player's inventory:

    local inv = player:getInventory()
    if inv~=nil then
        inv.addItem("Base.Axe")
    end

    Spawn item on ground

     Requires instance of IsoGridSquare to spawn the items on:

    square:AddWorldInventoryItem("Base.Axe", 0, 0, 0);

    World objects

    Containers, walls, trees - those are all world objects.

     

    Get all world objects player has right-clicked:

     

    function objectRightClicked(player, context, worldObjects, test)
      print("Objects right clicked");
      -- Not sure but it's all around production code so probably
      -- important
      if test and ISWorldObjectContextMenu.Test then
         return true
      end
      -- Pick first object in worldObjects as refference one
      local firstObject;
      for _,o in ipairs(worldObjects) do
        if not firstObject then firstObject = o; end
      end
      -- the square this object is in is the clicked square
      local square = firstObject:getSquare()
      -- and all objects on that square will be affected
      local worldObjects = square:getObjects();
      -- Loop over objects on square
      for i=0,worldObjects:size()-1 do
        local object = worldObjects:get(i);
        print("Clicked object!");
        print("      Name:"..(object:getName() or ""));
        print("    Object:"..(object:getObjectName() or ""));
        print("    Sprite:"..(object:getSpriteName() or ""));
        print("   Texture:"..(object:getTextureName() or ""));
      end
    end
    Events.OnFillWorldObjectContextMenu.Add(objectRightClicked);

    Destroy world object:

    Requires IsoObject instance:

    local square = object:getSquare();
    square:transmitRemoveItemFromSquare(object)
    square:RemoveTileObject(object);

    Put container items on ground before destroying

    In case you want to destroy, for example, crate, items should be put on ground first:

    local container = object:getContainer();
    local square = object:getSquare();
    -- If the object has container
    if container~=nil then
      local items = container:getItems();
      for i=0,items:size()-1 do
        -- WARNING: this will cause item duplication if the container
        -- is not destroyed
        local item = items:get(i);
        square:AddWorldInventoryItem(item, 0, 0, 0);
      end
    end
    -- Destroy the object
      -- see above

     

  5. 28 minutes ago, Jab said:

    I thought up a solution, but people want to discuss being right and wrong. :(

    I didn't want to discuss right and wrong but RoboMat and EnigmaGrey decided to shut-down anything I (and apparently others) say on this matter as wrong. I disapprove such attitude which unfortunately stirs unpleasant discussion and usually misses the point anyway. I even had very specific ideas myself and wanted to start another thread about actual constructive suggestion, but what's the point? lemmy101 said there's no time for it (I respect this, I'm sure there are other problems) and several others decided that in that case any debate on this should not even start. Too bad for me I guess.

     

    If there was more programmers concerned about this issue, I'd like to look into what lemmy101 proposed - try to understand and solve the issue in our way. I work in programming department which means I don't have time or will to go into it alone, team would be nice.

  6. Not sure about you, but this is starting to freak me out:

    cz7xELY.png

    I won't burn this in ten years:

    95Uyeq4.png

    Hence...

    Simple foraging filters

    puWu7xv.png Because I really suck at making GUI I raped the Crafting view to do some work for me. In the crafting window, there's now an additional tab called Foraging. Under this tab, all possible items are listed and you can toggle them on or off. Toggling is done by the star for favourites or by pressing F after selecting an item.

     

    I understand the GUI work I did sucks ass but frankly I think this mod will be soon replaced by built-in feature or maybe the foraging will be reworked. Therefore I was looking for fast ad-hoc solution. I did my job carefully on overriding built-ins so this mod shouldn't break anything.

     

    I will appreciate any testing on this. One flaw of modding is that you have less time to test the game and your own work.

    Where are the settings saved?

    Your preferences are saved in player modData table in foraging_filters sub-table. Note that items are not added until you change anything.

    Download

    Sample settings screenshot Attached file, as usual.
    ForagingFilters.7z

  7. 4 minutes ago, RoboMat said:

    people who have no clue about programming games

    This is still just more negativity instead some nice explanation or some google terms I can use to improve my education. Seems I better unsubscribe of this thread because this debate is just spamming the forum and no benefit to me...

     

    Edit: apparently it's not possible to ignore your own threads.

  8. 1 minute ago, EnigmaGrey said:

    *Sighs* The "It's 2D so it's simple" argument, really?

    Yeah, probably and definitely better than no argument at all. I wonder where does all that negative attitude of yours coming from. If you're so sure there's something wrong with what I say, be a man and say what it is rather than just challenging me (or whatever is your post's message). The thing is 2D might be not be simple or might be but it must always be possible to make it simpler than 3D. That's just a matter of degrees of freedom.

     

    lemmy101 explained some of the challenges regarding zombie patfinding but it's not really that other games don't have them, I just decided not to bring it up on him since he really doesn't seem to like to discuss this anymore and instead of asking him I can just look in the code anyway saving everyone's time. Until I look how it actually works I of course can't be sure. But I feel like I have full right to speculate without being perceived negatively.

  9. 6 minutes ago, EnigmaGrey said:

    Yes, let's make it even more complex.

    46 minutes ago, EnigmaGrey said:

    Because pathfinding is already resource intensive, as is . . .

    Come on, it's a 2D game. Minecraft does the same in 3D just fine and there are some games who have realistic physics apart of million critters using A* to attack players. Performance might be a problem, might be not. I wouldn't dare to claim this without having some benchmarks that it's pathfinding what slows the game.

     

    It's truth that the game eats almost 2 full cores of my CPU even when it's running in the background and it's truth that the A* has almost no recursion limit. That might be a problem.

     

  10. On 3. 7. 2014 at 6:11 PM, turbotutone said:

    This link is now dead too. Could the correct link be added to the original post so that people can see it instantly? The original post mentions TileZed like something everyone knows, but when I searched it in google and Project Zomboid application folder, I found nothing.

  11. 8 minutes ago, EnigmaGrey said:

    check adjacent tiles for similarly named texture

    Are "furniture_seating_indoor_01_13" and "furniture_seating_indoor_01_14" similar? Well nice, but they are two different chairs, not one multi-tile object...

     

    Only way seems to be manual lookup table. Which would make development even more pain than it is now.

  12. Although there already was some dismantle action added to the game, it doesn't really satisfy me. It uses the same tools for everything and is very limited. I already wanted to do this mod long time ago, so I did it now.

    Dismantle all

    This mod aims to allow player to dismantle as many in-game objects as possible.

    9j9GxmC.png

    Different objects require different tools and different skills. Dismantling most objects grants experience for related skills. Dismantling complicated objects takes a long time.

    Current status

    Currently, almost all one-tile furniture can be dismantled. Dismantling furniture grans carpentry experience and often also requires carpentry skill level. Doors can be also dismantled, though only if they're open.

     

    Several electronic objects can be dismantled, such as televisions and microwave ovens - both useless once electricity is off.

    Limitations

    • Multi tile objects cannot be dismantled, because the objects are not connected anyhow. Same problem happens with sledgehammer so I guess there's no ingame API to deal with this yet:
      jrOJzoD.png
    • Currently, loot is not randomized.

    Plans for full version

    • Randomize loot from dismantled items
    • Allow players to restore dismantle progress
    • Increase speed depending on skill
    • Skill should also improve loot
    • Certain items should make operation faster/slower (eg. Axe vs Raw Axe)
    • Load dismantle recipes from txt scripts rather than lua code
    • Also add dismantle recipes for inventory items
    • Smooth interaction with other mods

    This mod is moddable!

    You can easily change behavior of this mod. Add more objects in lua/client/Data/ObjectAssociations.lua. To view info about clicked objects, enable debug in lua/client/Context/ISDismantleMenu.lua, by setting debug property to true. You can also add more dismantle definitions in lua/client/Data/ObjectTypeDefs.lua.

    I appreciate your feedback!

    Currently, the mod is unbalanced. Many items are surely missing. I will appreciate your ideas or criticisms! If you understand Lua, I will also appreciate some code-review. This is my first Lua code ever.

    To download, click on attached file

    Dismantle.7z

  13. 5 hours ago, zomboid123 said:

    building a bunch of window frames and boarding them up

    I wanted to do exactly that but you can't barricade your own window frames. At least I certainly couldn't.

     

    5 hours ago, zomboid123 said:

     What is it with windows that overides their pathfinding AI

    My guess is that windows are considered empty space by the pathfinder (like fences). So the zombie picks path that goes through unbroken window because broken/unbroken makes no difference for it.

  14. Ideal case: Spawn items in player's inventory. If he cannot carry the items, spawn them on ground.

     

    I tried to search for some existing usage, but I found nothing. Specifically, I looked into tree chopping (media\lua\client\TimedActions\ISChopTreeAction.lua). It doesn't handle the log spawning because the tree "dies" independently of chopping and spawns items. And it seems that this is done in java.

×
×
  • Create New...