Jump to content


  • Content Count

  • Joined

  • Last visited


    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 forma
  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 t
  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 b
  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 o
  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
  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.
  • Create New...