Jump to content

RAINBOW

Member
  • Posts

    103
  • Joined

  • Last visited

Everything posted by RAINBOW

  1. RAINBOW

    Lua - File I/O

    This function is in my include file. It's a way to do a "Check if File Exists()". If it returns nil, well... You know the routine by now --prints an error message if file not exist in dir. function checkFileExist(_sFile) local string sFile = _sFile; local file = getFileReader(sFile, false); -- dir: C:\Users\User\Zomboid\Lua if file == nil then --does anything exist there? print("RAENBOW : Could not find file : ".. sFile .. " in C:\Users\User\Zomboid\Lua"); else -do nothing. File exists. end endSo if you wanted to check a file existed in your code, the format of the function would be: checkFileExist("Item_ m4a1.png");The file extension doesn't matter in this very basic function. Note the path I have commented actually, you'll see what RoboMat was saying- We aren't able to do what are known as i.o write/read from our wee lua files to anywhere except this directory. So any custom files we want people to be using have to be in
  2. Holy smokes. You are quite right, I do apologise. There's an event in there: Events.OnWorldMessage.Add(ISChat.addLineInChat); I use this website HERE to look up my events. Is there a more (regularly) updated one I can check out, out there?
  3. Turbo, there's no Event for: "OnWorldMessage" I, likewise, wanted to create some server specific commands relating to the chat. I discovered only lua relating to drawing UI although there was some methods in the "media/lua/Chat/" folder that would fire a "Command" like the method you mentioned, the sendWorldMessage stuff. Good link for the java class tho
  4. Dude. Totally fucking works. Hard to believe someone who created a "Pillow Case silencer" could stumble upon this beauty! Also, that is the most horrendously commented tutorial I've ever read!
  5. Solved it! Whoever it is that made the "Pillow Silencer" mod, (He doesn't leave his name!) has written this: http://pz-mods.net/guide/get-what-data-getmoddata/ It's how to save a table of values to ANY item we want in the game. Kickass.
  6. Is that a no Aricane? I'll have to put a value into a lua file too? Gonna try it first, might be just THIS simple after all?
  7. Anyway, lol! THANKS! 12.5 , thanks! Lol! Realised I seemed a bit ungrateful there, haha soz!
  8. Someone didn't study "Limits" in maths! The problem is not that my function is firing "EveryTenMinutes", but rather it is/will be doing so over an extended period of time. The idea behind a player being able to call my(custom) function and access the stored variable means I don't want it to be off by hours(real time) which if I am a second 'off' will be amplified by two, by two by two etc... Don't you see the merit in a player being able to simply type a command to see how long the server has been up? It shows how long it has been since the last reset for example! As I said before tho, using Ticks is overkill for this too, I don't need it THAT accurate, but a modicum of accuracy is called for. I doubt our server will stay up for longer than a week ever at a time, without a soft reset. Ours is a persistent world however. So, needs must.
  9. I wasn't too sure about this script business. I read This and I'm beginning to wonder. "Is creating my own custom variable and attaching it to an item, as simple as adding a line of code in here?" For example: item EnergyDrink{HungerChange = 10,Weight = 1.0,Type = Food,UnhappyChange = 10,ThirstChange = -5,DisplayName = Energy drink,ReplaceOnUse = PopBottleEmpty,Icon = Pop4,CustomContextMenu = Drink,}Can I just 'add' in a line here? such as item EnergyDrink{HungerChange = 10," " " " " "CharacterTokenFaction = Bandit," " " " " "CustomContextMenu = Drink,} Surely it can't be that simple?
  10. Came up with some code that checks for a custom item I've modded in called "Ctoken". Have a look if you like, I have gotten to the point where I access the server specific item, then realised I don't have a clue if I can just 'add' in values to it. The idea behind storing it on an item is for our persistent server, each character will get the item when they join (If they don't already possess one that is!). The event OnGameStart is serving fine for this purpose, anyway, boolean (true or false) values such as "Trusted Player" and custom player factions such as "Trader" are going to be set on this wonderific "do it all" item. Here's my code: --+ Raenbow +----+ 9th May 2014 +-- --+ CHARACTER TOKEN HANDLER. +---- function loadToken(_player)local player = _player;local token = player:getInventory():FindAndReturn("Raenbow.Ctoken");--local string sDebug = token:getName(); --returns "Character Token" --How can I add in 'another' value to the object token? end function raenbow_ctoken() local player = getPlayer(); --Check if a ctoken exists in inventory or not here:if player:getInventory():contains("Item_Ctoken") == false then--No Ctoken exists, create one and move on:print("Raenbow: No CTOKEN FOUND. CREATING ONE:");getPlayer():getInventory():AddItem("Raenbow.Ctoken");elseprint("Raenbow: CTOKEN FOUND!");end --to do here, Check there is not more than one ctoken here: --Execute next part here:loadToken(player);end Events.OnGameStart.Add(raenbow_ctoken); I'm entirely unsure if I can just 'add' in a value somehow, like with a simple "SetValue()" command or whatever, all I managed to trawl up from the javadocs and gleaming the forums was these: setScriptItem(token);ScriptManager():getItem(); But from what I see on the forums, the scripting stuff is getting binned or whatever anyway. Surely there must be a simple way to attach a bunch of string/int/bools to an inventory item object? Thanks in advance! This one has me stumped
  11. You're certain every 24 hours (1 day) game time is equal to 30 minutes in real time? I couldn't find anywhere on the forums that clarified that. I can't be off, not even by 1 millisecond. If you're certain you read that somewhere I'll believe you, and thanks Aricane
  12. Viceroy: The one you are looking to hook into is the perform() function in a TimedAction. Overwrite the "perform" function to do your check, for example, for my "Vegetarian" custom trait, I wanted to be able to check the ISEAT.lua which would then fire a timed action in the perform in it's 'require' at the top, I always think a wee bit of code speaks volumes anyway, here's my code: require 'TimedActions/ISEatFoodAction' --Hooked into here for "Vegetarian Trait" when they eat ham. function ISEatFoodAction:perform() -- CUSTOMISED FOR SANCTUARY local player = self.character;local item = self.item;local string whatIam = item:getName(); print("1: is working"); player:Say("AAAAAA"); --If the player eats some ham has the veg trait:if whatIam == "Ham" and player:HasTrait("vegetarian") then print("I ate some " .. whatIam .. " but I'm a bloody vegetarian! eek");else--call the original "Perform" code here: self.item:getContainer():setDrawDirty(true);self.item:setJobDelta(0.0);self.character:Eat(self.item);self.character:getBodyDamage():JustAteFood(self.item);self.item:UseItem(); -- needed to remove from queue / start next.ISBaseTimedAction.perform(self);end-- END CUSTOM HOOK end Events.OnFillInventoryObjectContextMenu.Add(ISEatFoodAction:perform());The code fires every time an item is eaten. And checks if it is ham. It fires a print statement. Pretty self explanatory eh? Oh! You might need to alter the require statement at the top if you are using build 26+ because the directory structure is changing now that PZ has gone multiplayer. The event "Onfillinventory" blah blah blah, is what fires when a player right clicks inventory. The function name ISEatFoodAction:perform is pinched from the Timed Action which links into that. Anyway, private message me if you need more help.
  13. MOODLEFACTORY() Moodles as it stands require a tremendous amount of work for us to alter. The function "MoodleFactory()" needs to be put in. Sure, we can alter moodles with item use (such as cigarettes), but firing a moodle change from a player object is much harder. One of the classes not inherited to the player object(but inherited by item obj's) is moodleChange(), for example "boredomChange()" or "panicChange()". That's one other possible solution to this prob.
  14. Nice to know you dev's are listening to the community! After a soft reset we've noticed all the world data remains persistent except for the zombies, that is to say, the zombies no longer re-populate the map afterwards. We're currently kludging it by having our admins log on and populate it themselves!
  15. We're doing soft resets, by changing the batch file etc etc as instructed on the forums, but Z's are not appearing! Everything else is persistent except this! Anyone else experienced this problem? We're currently logging on as admins and spawning them in manually.
  16. Hahaah, its funny how sometimes taking a double look at your stuff will explain it all! I had it in the client folder, despite it having to be acted upon in the server folder! So unbelievably simple, how these little networking nuances can catch you out:
  17. I'm almost certain I am having an issue with directory structure since the new move to multiplayer. I have this (Working) example of code here: --+ Raenbow +----+ 2nd May 2014 +-- --+ CHECK FILE EXISTS +---- --prints an error message if file not exist in dir. function checkFileExist(_sFile) local string sFile = _sFile;local file = getFileReader(sFile, false); -- dir: C:\Users\User\Zomboid\Luaif file == nil then --does anything exist there?print("RAENBOW : Could not find file : ".. sFile .. " in C:\Users\User\Zomboid\Lua");elseprint("RAENBOW : Successfully found file :" .. sFile .. " in C:\Users\User\Zomboid\Lua");--File exists, do nothing.--line = file:readLine(); --Could go further, and identify file type (e.g. .png, .txt)end end function raenbow_includeMain()checkFileExist("Item_Ctoken.png"); end Events.OnGameStart.Add(raenbow_includeMain);The code came from my desire to add in a "CheckFileExists" functionality to my main include file. It's position in my folder structure is: So far everything looks good huh? I create a wee server with my computer, to test it will be okay in multiplayer- that's when things get interesting! On the same computer, I boot up my PZ client, that is to say, the one with the "Join Server" option. Still with me? cool. In the join server option, I pop in the loopback, 127.0.0.1, and voila! What once was working when I tried in "Survival" or "Sandbox" will not work! no print statement is returned! What do you think is going on?
  18. Haha, RoboMat, You troll you! It's about ten seconds yeah? I'm writing a quick "Server Up Time" chat command, and using TenMinutes rather than ticks. CPU cycles is overkill in this instance. I need a modicum of accuracy however, because the difference of a second is fairly big once you take into the fact the 'scale' of it. i.e) If a server is up for 40 hours, then that little innacuracy (the difference of a second) becomes amplified.
  19. Nice easy one. Wasn't able to find anything about it in the lua files. "How long is Ten minutes (Clock) in real time?"
  20. Sad news is. This project is too ambitious for the support I got in response. I've decided to move over to Aggressive gamings server, and code for them, since they already have loads of modders and coders over there, and it seems like "The place to be". I'll probably be implementing alot if not all of the changes listed here, I just won't have full creative control but will have a great team beside me. Three java coders and two mappers over there, I'll post a link here when I can be bothered.
  21. The HOTFIX 3 file "recipes.txt" has a mistake in it. You've typed a recipe twice in it. Screenie: They are identical recipes! EDIT: One uses twine the other uses Fishing line. Ignore this post
×
×
  • Create New...