Suomiboi Posted August 13, 2013 Posted August 13, 2013 So here goes nothing: I've been learning some lua on my freetime and gotten in to the point where I'll be publishing my first mod. I've gotten the code working so that it changes the getting wet values to 0 but there's still some problems with the events and execution of the stuff (that will hopefully start going thanks to RJ and the .14patch! Thanks man invaluable stuff!)... The Umbrella can (when released) be found in wardrobes in bedrooms and maybe in the small storage shelves. The umbrella, when found is closed and can be used as a stabbing weapon (KittenKnife stats for now...). It can also be opened and when held in primary slot provides you shelter from the cough inducing evil that is rain. Since I was going to keep this to myself until somewhat done there's still major flaws that need to be fixed but I'm slowly but surely getting there. I just had to put this out there because kinyoshi as clever a detective he is, found my secret! thanks a lot no pressure now... First I'll try and make it work like it should (I'll take all the help I can get!) and then I'll release the hopefully working version at some point. Definitely no ETAs (I'm a busy bee at the moment)! After that I'll try and take some suggestions, but again no promises I'm only learning the stuff. So in due time I will present to you teh UmbrellaMod! Aricane, TheConstructionWorker and kinyoshi 3
kinyoshi Posted August 13, 2013 Posted August 13, 2013 (edited) I was testing out my whipping mod and I was soaked and it dawned on me, Umbrella!! my suggestions:It would require both hands to use and would open in three seconds but take ten seconds to shake dry and close. Both of those timers would require you to be standing still. The noise from the water hitting the umbrella would make more noise than the rain around it making you a little more noticeable when walking around in the rain if zombies are about. It would be usable as a very limited bat like weapon and would break pretty fast, maybe one to three uses. It would have the close combat jaw kill move like knives, maybe four to five uses. If in multi-player, two or three people can stand under it and not get wet. It would wear out over time from the wear and tear and from the water damaging it (long-term). And if hot and sunny, you stay cool when using it. I bet it will be awesome Edited August 13, 2013 by kinyoshi
Liva98989 Posted August 13, 2013 Posted August 13, 2013 I was testing out my whipping mod and I was soaked and it dawned on me, Umbrella!! my suggestions:It would require both hands to use and would open in three seconds but take ten seconds to shake dry and close. Both of those timers would require you to be standing still. The noise from the water hitting the umbrella would make more noise than the rain around it making you a little more noticeable when walking around in the rain if zombies are about. It would be usable as a very limited bat like weapon and would break pretty fast, maybe one to three uses. It would have the close combat jaw kill move like knives, maybe four to five uses. If in multi-player, two or three people can stand under it and not get wet. It would wear out over time from the wear and tear and from the water damaging it (long-term). And if hot and sunny, you stay cool when using it. I bet it will be awesome I agree on everything beside the "you'll have to stand still part." I usually if in a hurry run out of my door, and open the umbrella while running, I can't run as fast, but I think you should be able to run or atleast walk while opening it.
kinyoshi Posted August 13, 2013 Posted August 13, 2013 (edited) I agree on everything beside the "you'll have to stand still part." I usually if in a hurry run out of my door, and open the umbrella while running, I can't run as fast, but I think you should be able to run or atleast walk while opening it.You're right, ignore my standing still part. Still ten seconds though (my vote), to shake it and close it. Edit: Spelling. Edited August 13, 2013 by kinyoshi
Suomiboi Posted August 13, 2013 Author Posted August 13, 2013 The weapon part is almost done. It will for now usein the knife animations and be more of a stabbing weapon with low durability. I'm planning on making different icons for the open and closed umbrella. As for your other suggestions I'd say the more noise is a definite yes. I like the idea and think it's doable. The other Ideas have to sit for a while as I said I'm extremely busy for the next two weeks and am only able to work on the mod late in the evenings. But we'll see what I'll come up with
Suomiboi Posted August 15, 2013 Author Posted August 15, 2013 Ok, need some serious help right now... I've been stuck in a nerve wrecking dead end for quite some time and can't seem to get past it. I've gotten the umbrellas to spawn right and they're closable openable, but everytime I get somewhere with the staying dry code bit, at some point it somehow just stops working altogether. I've done it from the start a few times and every time it comes back to this. the functions don't seem to be doing anything at all or the events aren't triggered for some reason. If somebody can help me through this I'd be very greatful! The code is very rough and there might be some major flaws that I don't simply just know enough about. In NO way is this finished and working! Note also that the Events will only work on 2.9.9.14 and later versions!Warning Warning Warning Warning Warning WarningPossibly save breaking stuff!!https://www.dropbox.com/s/i0ttne0p048qo8c/UmbrellaMod.zipWarning Warning Warning Warning Warning Warning Some clydes for motivation: (clyde) (clyde) EDIT: I'm talking about the Umbrella_StayDry.lua
Aricane Posted August 15, 2013 Posted August 15, 2013 Wohoo. Umbrella... Know that we'll still have each otherYou can stand under my umbrella, ella ella ella. Remember to submit this dope to pz-mods.net, cuz' we're having a partaayy over there and it's craayzzy! Woohoo.
Suomiboi Posted August 15, 2013 Author Posted August 15, 2013 Oh god now that song is in my head... Wohoo. Umbrella... Know that we'll still have each otherYou can stand under my umbrella, ella ella ella. Remember to submit this dope to pz-mods.net, cuz' we're having a partaayy over there and it's craayzzy! Woohoo. Yeah, will do once I get it even nearly to a working point, but meanwhile I'm bumping my head to the wall learning this stuff.
Gingerdick Posted August 21, 2013 Posted August 21, 2013 Raincoat is much better. Your hand are free and your ass don`t get wet
kinyoshi Posted August 21, 2013 Posted August 21, 2013 Raincoat is much better. Your hand are free and your ass don`t get wet But you can't stab a zombie in the face with a raincoat .
Suomiboi Posted August 21, 2013 Author Posted August 21, 2013 I've been thinking about raincoats but even this isn't working yet so.... made some small progress on the code though... yayy! If anyone's still up for helping. I'm taking whatcha givin'.
RoboMat Posted August 21, 2013 Posted August 21, 2013 Well what do you need help with? In my mod utils that I've posted there is a function that attracts zombies to the player ... you could call that every ten minutes or so when he has the umbrella equipped.
Suomiboi Posted August 21, 2013 Author Posted August 21, 2013 No I think it's just mostly small typing errors that I can't find in the Umbrella_StayDry.lua. and also if you'd have any ideas or tips how to clean up the code 'coz I think it's gonna get messy if I continue to do it like this as there's loads more to add. I've been looking a lot at your and aricane's coding but there's just so much stuff that I don't always grasp how things are handled (but getting there). here's what the basic function looks like now (worked at some point now doesn't):function UmbrellaMod.StayDry() local player = getPlayer(0); local weapon = player:getPrimaryHandItem(); print "woot" -- please remember to remove this... ------------ How to not get wet ---------------- ------------------------------------------------ if weapon:getType() == "UmbrellaOpen" then if season.weather() == "rain"; getPlayer:Say("It's raining!"); -- Remember to edit this out!!! print ZomboidGlobals["WetnessIncrease"]; -- to check the original value ZomboidGlobals["WetnessIncrease"] = 0.0; -- this is the key of not getting wet! Yay!! print ZomboidGlobals["WetnessIncrease"]; -- to check if it's working right elseif season.weather() ~= "rain" then getPlayer:Say("It's not even raining..."); print ZomboidGlobals["WetnessIncrease"]; -- to check if it's able to turn itself to original value without command. probably not... end else ZomboidGlobals["WetnessIncrease"] = 0.025; -- for testing purposes REMOVE IF NOT ABSOLUTELY NECESSARY!!! print ZomboidGlobals["WetnessIncrease"]; -- to check if it's able to turn itself to original value with command. endend The thing is that I'm always coming to a point where I do some sort of an error and then the .lua doesn't load at all. I've started to take baby steps for now and it seems to be working so far (not the one above...), but it's hell to do it via trial and error. Edit: there's alot of testing stuff still going on here so it's mostly a mess
RoboMat Posted August 21, 2013 Posted August 21, 2013 What event do you use to call that function? I see a few problems in your code syntax:To get the player it is either getPlayer() (without a number) or getSpecificPlayer(0) (with either 0 or 1).You store the player in a local variable, but never use it in the actual code The second if has a semicolon instead of a "then" at its line ending.print is a function call so you need to put the thing you want to print in brackets.function UmbrellaMod.StayDry() local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); ------------ How to not get wet ---------------- ------------------------------------------------ if weapon:getType() == "UmbrellaOpen" then if season.weather() == "rain" then player:Say("It's raining!"); -- Remember to edit this out!!! ZomboidGlobals["WetnessIncrease"] = 0.0; -- this is the key of not getting wet! Yay!! elseif season.weather() ~= "rain" then player:Say("It's not even raining..."); print(ZomboidGlobals["WetnessIncrease"]); -- to check if it's able to turn itself to original value without command. probably not... end else ZomboidGlobals["WetnessIncrease"] = 0.025; -- for testing purposes REMOVE IF NOT ABSOLUTELY NECESSARY!!! print(ZomboidGlobals["WetnessIncrease"]); -- to check if it's able to turn itself to original value with command. endend You should get an IDE like IntelliJIdea because that showed me half of the problems as problems in the editor Besides that I'm not sure if your code works of course, but afaik you can use this RainManager.isRaining() to test if it is raining or not. Suomiboi 1
Suomiboi Posted August 21, 2013 Author Posted August 21, 2013 Allright thanks a lot, will try this when I get home!(I'm slacking at the office atm and the computer here doesn't run PZ) I know there are just things like you mentioned but I get so blind to them after trying and trying... I did download the IntelliJIdea trial but haven't gotten to using it. It looked scary. (I just saw the community version... meh.. thought it was gonna cost me some bucks I don't have, but yay!) But anyways, many thanks! (clyde) Edit: atm I use Events.OnEquipPrimary.Add(UmbrellaMod.StayDry);I had a problem with OnPlayerUpdate just spamming too much I had to try something different
Suomiboi Posted October 24, 2013 Author Posted October 24, 2013 Ok here's finally a progress update: I've gotten the Umbrellas working when equipped primary but can't get past the first if function when the umbrella isn't equipped. The console throws somekind of a Stack Trace: https://www.dropbox.com/s/t9jy8mg2qgb1fm7/StackTrace.pngSo I'm using the getType code as follows:UmbrellaMod.EveryTenMinutes = function() player = getSpecificPlayer(0) weapon = player:getPrimaryHandItem() if weapon:getType() == "UmbrellaOpen" and player:isOutside() then -- Here's where the stacktrace shows the "error" when nothing is equipped print("UmbrellaMod:: Has Umbrella Equipped and outside."); if RainManager.isRaining() and player:getBodyDamage():getWetness() > 0.1 then print("Umbrella Mod:: Is Raining and wet."); player:getBodyDamage():setWetness(21); player:getStats():setEndurance(player:getStats():getEndurance() - 0.01); print("Umbrella Mod:: You seem to remain somewhat dry in the rain."); end endend Events.EveryTenMinutes.Add(UmbrellaMod.EveryTenMinutes);Credits to Kinyoshi's Raincoat Mod which helped me through the worst problems I had. So if anyone could help me with this it would be greatly appreciated!
RoboMat Posted October 24, 2013 Posted October 24, 2013 The error comes from "weapon" which is nil the moment you don't have anything equipped. Simply add a test for a nil object or end the function early. This should do the trick: local function checkUmbrella() local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); if weapon then local type = weapon:getType(); if type ~= "UmbrellaOpen" then return; end if type == "UmbrellaOpen" and player:isOutside() then print("UmbrellaMod:: Has Umbrella Equipped and outside."); if RainManager.isRaining() and player:getBodyDamage():getWetness() > 0.1 then print("Umbrella Mod:: Is Raining and wet."); player:getBodyDamage():setWetness(21); player:getStats():setEndurance(player:getStats():getEndurance() - 0.01); print("Umbrella Mod:: You seem to remain somewhat dry in the rain."); end end endendEvents.EveryTenMinutes.Add(checkUmbrella);It is a bit late here ... so I might have missed something. If so, just holler Suomiboi 1
Suomiboi Posted October 24, 2013 Author Posted October 24, 2013 Yeah it's 4am in here too. Hmm... seemed to work for the stack trace but now I get nada for the print function. I actually tried something very close to this but was short with the return command . I tried changing the local type to something else (it was showing on light blue) but didn't make a difference... I'm going to sleep now so I'll get back to this when my brain isn't this smushy.... Thanks for the help anyways!! EDIT: got it working (I had forgotten to change the event!) Btw what's the difference between using a local function and the one I used where it's for example: UmbrellaMod.checkUmbrella? Thanks again!
Suomiboi Posted October 24, 2013 Author Posted October 24, 2013 Another update plus questionnaire: The umbrellas are now working correct when in primary, secondary and already wet and I'm thinking about releasing the first version as soon as I've tweaked the distribution and some other small things! Wohoo! Now the latest problem I got is similar to the last one where I get a stack trace from a function. But this time it's a function that was working right when I started making the mod and I haven't touched it since... Here's the link for the trace:https://www.dropbox.com/s/nf5mjpqrl46pbbs/StackTrace2.png Here's the whole lua for the staying dry part:UmbrellaMod = {}UmbrellaMod.Mod_Version = "0.1.1";UmbrellaMod.Mod_Author = "Suomiboi";UmbrellaMod.Mod_Name = "Umbrella Mod";--- --------------------------------------------------- Functions--- ------------------------------------------------------ Prints out the mod info on startup.function UmbrellaMod.info() print("Mod Loaded: " .. UmbrellaMod.Mod_Name .. " by " .. UmbrellaMod.Mod_Author .. " (v" .. UmbrellaMod.Mod_Version .. ")"); -- <----------------This is where the stack trace pointsendfunction UmbrellaMod.loadTextures() local umbrellaopen = getTexture("Item_SB_UmbrellaOpen.png"); local umbrellaclosed = getTexture("Item_SB_UmbrellaClosed.png");end--Created from the basis of Kinyoshi's Raincoat mod. Thanks and credits to him!----Huge thanks to RoboMat for help with the code and awesome mods that helped me learn lua!!----Also thanks to RegularX, Kjulo and Aricane whos mods I've also been using to learn the lua!----Function for umbrella in primary slot--local function checkUmbrella() local player = getSpecificPlayer(0); local weapon = player:getPrimaryHandItem(); local weapons = player:getSecondaryHandItem(); local getwetness = player:getBodyDamage():getWetness(); --When Umbrella is in Primary-- if weapon then local wtype = weapon:getType(); if wtype ~= "UmbrellaOpen" then return; end if wtype == "UmbrellaOpen" and player:isOutside() then --print("UmbrellaMod:: Has Umbrella Equipped as Primary and outside."); --boundaries between wetness: -- x < 14 dry -- 14 <= x > 39 damp -- 39 <= x > 69 wet -- 69 <= x soaking if RainManager.isRaining() and getwetness > 14 and getwetness < 39 then --print("Umbrella Mod:: Is Raining and damp."); player:getBodyDamage():setWetness(21); --print("Umbrella Mod:: You seem to remain somewhat dry in the rain!"); end if RainManager.isRaining() and getwetness >= 39 and getwetness < 69 then --print("Umbrella Mod:: Is Raining and wet."); player:getBodyDamage():setWetness(45); --print("Umbrella Mod:: You're not getting any wetter!"); end if RainManager.isRaining() and getwetness >= 69 then --print("Umbrella Mod:: Is Raining and soaked."); player:getBodyDamage():setWetness(75); --print("Umbrella Mod:: You're not getting any wetter!"); end end endend--Function for umbrella in secondary slot--local function checkUmbrellaSecondary() local player = getSpecificPlayer(0); local weapons = player:getSecondaryHandItem(); local getwetness = player:getBodyDamage():getWetness(); --When Umbrella is in Primary-- if weapons then local wstype = weapons:getType(); if wstype ~= "UmbrellaOpen" then return; end if wstype == "UmbrellaOpen" and player:isOutside() then --print("UmbrellaMod:: Has Umbrella Equipped as Secondary and outside."); if RainManager.isRaining() and getwetness > 14 and getwetness < 39 then --print("Umbrella Mod:: Is Raining and damp."); player:getBodyDamage():setWetness(21); --print("Umbrella Mod:: You seem to remain somewhat dry in the rain!"); end if RainManager.isRaining() and getwetness >= 39 and getwetness < 69 then --print("Umbrella Mod:: Is Raining and wet."); player:getBodyDamage():setWetness(45); --print("Umbrella Mod:: You're not getting any wetter!"); end if RainManager.isRaining() and getwetness >= 69 then --print("Umbrella Mod:: Is Raining and soaked."); player:getBodyDamage():setWetness(75); --print("Umbrella Mod:: You're not getting any wetter!"); end end endendEvents.OnGameBoot.Add(UmbrellaMod.info);Events.OnGameBoot.Add(UmbrellaMod.loadTextures);Events.EveryTenMinutes.Add(checkUmbrella);Events.EveryTenMinutes.Add(checkUmbrellaSecondary);Now I know that it isn't necessary for the mod to work but I'm curious as to why it is happening since I haven't basically done anything to that function or event. And also in future cases how do I avoid this?
RoboMat Posted October 24, 2013 Posted October 24, 2013 I think it might have something to do with the local functions you are using. I had some strange problems with those before because they need to be declared in the order in which they are called later on apparently. Move the "info" stuff to a different file and see if you still get those problems.
Recommended Posts