Jump to content

MXXIV

Member
  • Content Count

    86
  • Joined

  • Last visited

About MXXIV

  • Rank
    Advanced Member

Recent Profile Visitors

845 profile views
  1. Chop some trees I like to build those long log walls. So I chop until "can barely move" at which point I have to take 8 hours sleep.
  2. While you're at it, please make sleep remove exertion faster. Waking up after 4 hours and still heavy breathing is ridiculous.
  3. 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. Nice to see people being drawn into programming by games!
  4. 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.
  5. Simple lua mod could add this feature. Basically just edit my dismantle mod so that it spawns wall with frame instead of removed wall.
  6. MXXIV

    Npc Modding?

    Sorry for being off topic but seeing your avatar I must ask - is Rim World still active? Is my force field shield still used?
  7. 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.
  8. 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
  9. 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.
  10. Decreasing entropy is a hard thing to do and rather elaborate strategies are needed to do so. One nice trick is so-called evaporative cooling, used in Africa to preserve food. However it's not miraculously effective, especially in colder and wetter climates.
  11. Yeah, pretty plausible with buckets, pots and bowls but nothing else really. I wonder, can you do something to affect items on ground with rain?
  12. Good idea. Instead of consuming the game, battery could be required and consumed as you play.
  13. MXXIV

    Foraging filters beta

    Not sure about you, but this is starting to freak me out: I won't burn this in ten years: Hence... Simple foraging filters 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 Attached file, as usual. ForagingFilters.7z
  14. 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.
  15. 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.
×
×
  • Create New...