Jump to content

Search the Community

Showing results for tags 'code'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Twitter


Interests

Found 8 results

  1. Hello! I guess there is not that many controller or Steam Deck users which probably also means lack of feedback. I am a controller user myself (accessibility reasons) and since B42 is nearby I thought it's a good time to suggest a very simple to implement chage. From the very first day I got this game about one year ago one thing bothered me: invenotry and loot menus cover half of the screen. Even though it is possible to adjust those using mouse or touchpad it is far from comfortable (or precise/symmetrical/alligned for all the perfectionists out there), and then manually made changes don't persist. Half of the screen is enormous on 50" 4k TV by the way. That same month I made a mod which changes the math behind how it is drawn. It allows players to chose in percentage how much of the screen space said menus should take on their screen. This includes both vertical and horisontal space as well as positioning. Players can choose to have inventory on the left and loot on the right with plenty of open space in between to finally see their character or keep both menus together on the left. The change to the math behing calculating sizes works well for any common resolution including Steam Deck and split screen players. Chosen layout persists between restarts. Here is the vanilla part of code behind it in ISPlayerDataObject.lua: --some code else local ww = w local hh = h self.x1left = x; self.x1 = x; self.y1top = y; self.y1 = self.y1top + (hh/2); self.w1 = (ww / 2); self.h1 = (hh / 2); self.x2 = self.x1 + self.w1; self.y2 = self.y1; self.w2 = (ww / 2); self.h2 = (hh / 2); end --some code Here is the change I made to it: --some code else local x = getPlayerScreenLeft(playerID) local y = getPlayerScreenTop(playerID) local w = getPlayerScreenWidth(playerID) local h = getPlayerScreenHeight(playerID) local ms = CGUI.Options.ms --loot menu position (boolean) local mw = CGUI.Options.mw --inventory + loot width (%) local mh = CGUI.Options.mh --inventory height (%) local lmh = CGUI.Options.lmh --loot height (%) self.x1left = x; self.y1top = y; self.x1 = x; self.w1 = (w * mw / 2); self.h1 = (h * mh); self.y1 = h - self.h1; if ms then self.x2 = self.x1 + w - self.w1; else self.x2 = self.x1 + self.w1; end self.w2 = self.w1; self.h2 = (h * lmh); self.y2 = h - self.h2; end --some code Here are the screenshots at Steam Deck resolution plus settings used: Having mods is great, but when it comes to multiplayer one have to somehow reach to unknown person behind the server and make them add one more mod which is usually not possible. I would be so happy to see something like this implemented. Thank you, I love your game.
  2. First of all, I would like to apologize in advance for my english. It's not my first language, but I promise that'll do my best. For the past days I've been trying to create a mod for a custom trait, but I haven't found much about it. I've been posting on forums, watching tutorials, and even downloading other mods to see and analyze their structure, hoping to being able to do some reverse engineering. So, here's the issue -- I know how to create a new trait and add some buffs for X skill, like: CustomTrait:addXPBoost(Perks.Strength, 4) or: CustomTrait:addXPBoost(Perks.Lightfoot, 1) which would add one (1) level on that skill, and a XP boost (75%). But I have no idea on how to make that CustomTrait to have the effects of another (vanilla) trait as well. I.e making my "CustomTrait" to have the effects of "Brave". I've tried testing with: TraitFactory.addTrait("Illiterate", getText("UI_trait_Illiterate"), -8, getText("UI_trait_IlliterateDesc"), false); but it doesn't work -- I guess this only work with professions. Also tried with: player:getTraits():add("MyTrait") Doesn't work either. I supposed that I should use: require('NPCs/MainCreationMethods'); to call the traits from the main folder, but still. Not working. I just wanted to make a simple trait, with minor buffs to skills and to contain the effects of Brave and Outdoorsman.
  3. So I ve been trying to find definitive answers to a few infection questions, but I only found quotes and sayings with no 100% certainty, so I started digging through the Project Zomboid code and here are my findings. All of the game mechanics in this thread are true as of version 39.67.5 (No changes from 38.30) Spoilers here to avoid huge wall of text. Read the TL;DR if you dont care about details: TL;DR By default: Bites are 100% deadly. Scratches are 25% deadly. Both Thick skin and Blunt Guard skills (Blade Guard if wielding a blade weapon) adds in avoiding bites and scratches, and Thick skin further reduces the probability of a deadly scratch. Thin skin worsens everything. More game mechanics: Traits Lucky/Unlucky Prone to Illness/Resilient General Panic Sleep and related effects Melee damage mechanics If someone has suggestions, questions about parts of code and such, or found any errors/things I might have overlooked, feel free to post or msg me about it and I ll do my best to check.
  4. Would it be possible to code in a new button config that provides for a "drop all bags" button? After an unfortunate death last night of a good character, I got caught kinda off guard by a couple zeds, which quickly turned into 4 or 5. I had intended to quickly open inventory to drop my overweight dumbness, but that GUI is just too cumbersome to pull that off in the middle of a shove-swing-stomp fiasco. I could have made it out had there been a key that allows you to drop any equipped bags (hence, overloading weight). Granted that any overloading weight on your immediate self would be tantamount to suicide anyway, but being able to drop bags by keystroke (say, ~ or Backspace) could mean the difference between life and zombification.
  5. I have started modding PZ and I was experimenting with key registry trying to figure out which keys are what by printing them in the console. This failed to print keys to console so I tried spawning something to the players inventory (something I've done before) I have searched and found no info on left click behaviour or detecting it. But this piece of code just doesn't work and through testing Print(); doesn't work in code that does work. The sub directory for this file is media\lua I have also tried media\lua\server and media\lua\client. TTG_Click = {};TTG_Click.characterInfo = nil;TTG_Click.click = function(_keyPressed) local player = getSpecificPlayer(0); local key = _keyPressed; player:getInventory():AddItem("Base.Pistol"); print(key);endEvents.OnKeyPressed.Add(TTG_Click.click);Any Ideas on what's gone wrong? The file is called TTG_Click.lua Edit: Thank you for moving me I was on the help sub forum for mods when I clicked start new topic don't know how it ended up there. Requesting a mod remove this thread. I never found out what the issue was but I was directed to a completely different solution and implementation.
  6. Hi, I am very noob with all this coding thing and Lua files. I tried to do some things for adding to the game, some of them asked before in Suggestion forum. The thing is I managed to do some of them, but find a BIG BUG when I made a Ranged Weapon. At first couldnt shoot with it. Then I thought I fixed some things but instead the weapon became endless ammo. It shoots, it does what was supossed to do in the rest of things, but the ammo don't decrease. Then I messed all up in the ReloadUtil file and ... well, I am a bit lost. At first I tried to make the weapon use the same pistol clip as the default gun, but couldnt do it to reload, so I made a new item, SBerettaclip (it is almost the same as default but with a change in name and I get it from Necroforge spawning by this moment). Here are the Items as part of WeaponsGuns txt file in the folder scripts: And here is the CompilationReloadUtil lua file put in the folder lua/shared/Reloading: Can somebody pleazeeeeed help me with this mess?
  7. First, this all comes from NCrawler, who seems to have left the community 6 months back. It's from a beta of his YAWM that never was released. I have it since I was a beta tester for him at the time he left. The purpose of this is to allow the modder far more flexibility in how his items are spawned, when, and with what. It also allows a modder to set values lower than 0.01 for probability, in fact as low as desired (1 in 10,000, okay!). Some of this has been heavily altered by me for personal use with the KY firearms mod that's currently out in this forum, but it can work with any items mod you like. This works through the media\lua\server\Items subfolder. Add this to the bottom to start. The random value generator is used an awful lot, and the Events line is what calls the script to run each time a container is "filled" by the game engine. Without that, nothing will happen. --From RoboMat's RMUtility Modfunction rnd(_value) return ZombRand(_value) + 1;endEvents.OnFillContainer.Add(spawnNCStuff);Next is the main function. Note that "OnFillContainer" will pass 3 values to this, the room name (the first value we see in SuburbsDistribution tables, like "kitchen"), the type of container (the second value, "all" or "metal_shelves"), and the specific container being filled: function spawnNCStuff(_roomName, _containerType, _containerFilled)-- ALL THE IF AND WHILE LOOPS DISCUSSED BELOW GO IN HEREendNow we can use these in IF statements to specify when to spawn things depending on room type or container type: if _containerType == "wardrobe" then-- STUFFend if _roomName ~= "kitchen" then if _containerType == "counter" or _containerType == "locker" or _containerType == "metal_shelves" then-- STUFFendendWithin these, we can set how rare the spawn is thusly: --Roll for firearm (0.2% chance) if rnd(1000) >= 999 then-- STUFFendThe next part is a bit trickier. It requires two things. First, the code within the above IF statements. Second, a separate array outside of this entire function. Let's start with the array. Here's an example for guns and their respective ammo: gun_array = { "RKFmod.ColtPython", "RKFmod.TaurusModel444RagingBull", "RKFmod.Kimber1911", "RKFmod.Ruger1022ArchangelNomad", "RKFmod.Ruger1022", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795",};ammo_array = { "RKFmod.357Mrounds", "RKFmod.44rounds", "RKFmod.45rounds", "RKFmod.Ruger1022ArchangelNomadMag", "RKFmod.Ruger1022Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag",};Notice how the first member of the array in gun_array matches the first member of ammo_array, and so on to the end? This is important if you want to spawn matching items together. Also notice how we've had the Marlin 795 repeated 3 times, so it takes up 4 of the 8 choices? That means it has a 50% chance of spawning IF any gun is spawned from its array. This is how to make specific entries more or less likely within the array. Now, let's assume we have several such paired arrays, one for long rifles, one for pistols, one for AR-15s, etc. We want to choose randomly which to pick from when spawning. Next the code for the main function: weaponType = rnd(100); if weaponType <= 50 then --pistols-- STUFF elseif weaponType > 50 and weaponType <= 90 then --rifles-- STUFF elseif weaponType > 90 then --AR-15s-- STUFF endSo here you can see we are choosing between which set of arrays to spawn from. Next, to pick a member of the array to spawn: gun_Index = rnd(#gun_array); _containerFilled:AddItem(gun_array[gun_index]);#gun_array means that it counts the number of entires in our gun_array. The rnd function picks a random number within that range. Then we have the main "doer" of this whole thing, the AddItem() command. This adds in the selected item to the specific container. You could just replace (gun_array[gun_index]) with ("mymod.my_gun") and it'd work just as well. Now here's a fun twist. You can add specific ammo/magazines/etc to the spawn as well: NCY_ammovar = rnd(100); if NCY_ammovar >= 40 then --Add 1 magazine for that weapon(60% chance) _containerFilled:AddItem(ammo_array[gun_index]); if NCY_ammovar >= 75 then --Another mag (25% chance) _containerFilled:AddItem(ammo_array[gun_index]); if NCY_ammovar >= 92 then --2 more mags (8% chance) _containerFilled:AddItem(ammo_array[gun_index]); _containerFilled:AddItem(ammo_array[gun_index]); end end endLet's walk through that a bit slowly. First, we have a new random value, this is just used to see if we want to spawn something or not. You could just make this 100, so something always spawns (or nix the IF statements and just follow with an AddItem() command). But here it's random, and the first checks to see if it's >= 40, which means 60% of the time we'll get ammo spawned with the gun. Notice that we're using the SAME gun_index value as before, we haven't rerandomized it, but now with the ammo array? Yes, this is how we get a matching gun/magazine/ammo spawn. Then you can see that there are two additional IF checks, for rarer likelihood of further spare ammo. This can be tailored however you like, once you understand the basic syntax of what's going on here. There's a lot more you can do with this stuff, like spawning a melee if a gun doesn't spawn, using an ELSE statement that follows the original IF statement way above. Sky's the limit. I'm not going to say this is the most streamlined code imaginable, but it works and it's pretty easy to edit on the fly and adjust to how you like it. Anyway, let's look at a finished version of what we just did (different names for some things, but exact same structure/commands): This was altered by me to work with the KY firearms mod, for personal use. I guess now it's open to all. I will also post the original YAWmod lua if anyone wants to experiment with thatj. NOTE: You will want to get rid of all the... table.insert(SuburbsDistributions["garagestorage"]["all"].items, "RKFmod.BoxOf22");...type code if you want to do this, or at least that which is relevant to what you're trying to achieve with these functions. Anyway, thanks should go to NCrawler, wherever he is, as far as I know he was the one to come up with this approach and code for this game.
  8. Hi guys I only just now found out zoom is back in the game (IKR only just 5 minutes ago...) Would it be possible to make a script to auto zoom in the camera all the way as i enter a building(such as every thing you can walk into from the outdoors).Then zoom out to its default zoom as i exit the buildings. How hard would it exactly be? I would think of this being useful maybe not only to me but others aswell.As the thought of this idea popped into my head i was overwhelmed with excitement
×
×
  • Create New...