Jump to content

Stormy

Member
  • Posts

    64
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Stormy got a reaction from Keshash in Launch Procedures   
    Not gone forever. This makes me happy 
  2. Like
    Stormy got a reaction from Batsphinx in Launch Procedures   
    Not gone forever. This makes me happy 
  3. Like
    Stormy reacted to Bourbon in Launch Procedures   
    I REAAALY want the advanced Reloading Mode. Zomboid is one of the few games were this kind of micromanagement makes sense. It is one of my favorite features.
  4. Like
    Stormy got a reaction from WaffleFish in Help with reload system   
    Ok... as a sanity check, can you just try removing the space from the item name.... 'Homemade Bow' -> 'HomemadeBow'
     
    Also, check every field in the item (I can't remember and don't have the code in front of me... apologies). My concern is that one of the reloading scripts is using the name to identify the weapon type and there is some sort of mismatch or the name is null
  5. Like
    Stormy got a reaction from d0v3r in Adding more guns   
    I've seen two threads already and wanted to try and consolidate all the questions about this here.
     
    I've made some changes to the reloading scripts to make it easier to add extra weapons. Provided I can fix the remaining bugs, this should mean that the original lua scripts will not need tampering with in order to have additional weapons take advantage of the reloading scripts.
     
    Preparing the mod directory
     
    Find  your zomboid mod directory, if you launch the game, click mods, you'll find the path at the bottom of the mod window. Mine is:
     
    C:\Users\Stormy\Zomboid\mods\
     
    Where Stormy would be your windows user name.
     
    Next, extract the following zip to that directory:
     
    WARNING: It seems the files in the mod directory do not replace the original lua scripts perfectly. Override the files in the \Steam\steamapps\common\ProjectZomboid\media\lua\Reloading directory with those in the following archive:
     
    http://download1653.mediafire.com/62216je2q0wg/cue340cf05muivz/Reloading+-+moddable.zip
     
    And extract the following to the mod directory explained above.
     
    http://download856.mediafire.com/8x5fpe7hgqyg/tttr0ci0smpr924/moreguns.zip
     
    I've sorted out the mod structure for you, so you can continue building on the files inside. Once extracted, the file structure should resemble:
     
    C:\Users\Stormy\Zomboid\mods\moreguns
    C:\Users\Stormy\Zomboid\mods\moreguns\media
    C:\Users\Stormy\Zomboid\mods\moreguns\media\lua
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts
     
    The devs have been clever so that if you name the lua files the same in the mod directory, the game will replace the originals. Therefore, from now on, you can just modify these files to get the results you want. Remember, you'll have to enable the mod once upon starting the game and from then on it will use the mod until you disable it.
     
    Note this means REPLACE not MERGE. If a zomboid update changes the original files, the change will not be brought across to the custom files meaning potential bug fixes would be missed. Once I figure out the remaining bugs I ask for these versions to be made 'official'.
     
    Defining the items
     
    In the directory:
     
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns
     
    there is an items.txt. This is where the majority of information about the item is found.
     
    module MoreGuns{    item Colt45    {          item info here    }     item ColtClip    {          item info here    }} I've defined the module name 'MoreGuns' which is the same as my mod name. This helps to reduce the difficulty of finding your particular items. Both the module name and the item name must contain no spaces or special characters. I won't go into details about the various fields in the item's information. I've copied mine directly from the existing pistol and changed only the display name. 
    There is an important script that I noticed to do with languages which must have additional entries for each weapon you add for the mod to work. These are to do with language translations. It's not immediately obvious (I don't fully understand it) but goes something like this.
     
    In the C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Translate there is a file called Items_empty.txt. You need to create entries for your weapons in there. 
     
    For your Colt where the weapon name is Colt .45 I've created the entry:
     
    DisplayNameColt_.45 = "",
     
    Replacing the space with an underscore. Same for the magazine
     
    DisplayNameColt_Magazine = "",
     
    Compare this with the items.txt in 
     
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns
     
    Here's the shorter entry (the magazine) as an example:
     
    item ColtClip{   CanStack = FALSE,   Weight = 0.2,   Type = Normal,   DisplayName = Colt Magazine,   Icon = BerettaClip,} You'll see the name in the Items_empty.txt corresponds to the DisplayName of the item in the items.txt.  Updating the LUA files  In the folder: C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Reloading You should be able to see the file ZMoreGuns.lua. It is named 'ZMoreGuns' rather than 'MoreGuns' because files are loaded in alphabetical order and I need it to load after storymysReload.lua Anyway, if you open the file, you should be able to see two entries. One for the magazine and one for the weapon. I've declared the magazine first. Here is the information broken down: local coltClip = { name = getItemText("Colt Magazine"), -- Make sure this is the same as the display name in items.txtmoduleName = 'MoreGuns',-- The module the weapon was defined under in items.txtreloadClass = 'ISReloadableMagazine', -- The type of reloading this item will follow (see below)clipType = 'ColtClip',-- The item type as defined in the items.txtammoType = 'Bullets9mm',-- The type of ammo this item takes. You can create a new ammo type in items.txtshootSound = 'none',-- The sound to play when this weapon firesclickSound = nil,-- The sound to play when this weapon dry firesejectSound = 'none',-- The sound to play when a magazine is ejectedinsertSound = 'stormyRevolverInsertRound',-- The sound to play when a round/magazine is insertedrackSound = 'stormyRevolverInsertRound',-- The sound to play when this weapon is rackedcontainsClip = 0,-- Whether the item contains a magazinemaxCapacity = 15,-- The maximum capacity of this itemreloadTime = 30,-- The time taken to insert one round/magazinerackTime = 10};-- The time taken to rack the item For the colt itself there is one extra value: clipData = coltClip This is just pointing to the local maagzine declared above it. Finally, the following statements are called: ReloadUtil:addWeaponType(colt)ReloadUtil:addMagazineType(coltClip) These add the weapon and its magazine to the list of weapons and magazines the reload utility is currently managing. Reload Types There are currently three reload types: ISReloadableMagazineISSemiAutoWeaponISShotgunWeapon A revolver type has not yet been implemented but would likely be restricted to a fixed number of chambers were I to implement it (for reasons to do with saving the reload data). Provided everything compiles there should be no extra steps required. I've left a debug key in the lua. The code for which can be found in the stormysReload.lua script. Press L and the game will give you the original Pistol, the new Colt,  a magazine for each and some ammo. Both use the 9mm ammo type. (I may have commented out the important lines though, make sure you remove the dash that start of any line for which you want to create an item). 
    There seems to be some glitches about the magazine appearing in your inventory. I need to look at these too. Hopefully though, there is enough here for you to make a start with.
  6. Like
    Stormy got a reaction from JaxTheGuy in Explosions - again   
    Been working off and on with this for a while now. Scraped enough together for a short video.
     
    http://youtu.be/cmrYgd1Ys9c
     
    If indoors, explosions fill the space they're in. I think fire is turned off in the version of zomboid I'm running. There are a few things I'm still struggling to work out such as knocking back zombies; Sprites are drawing in a funny way; really should be animating the explosions. I also need to factor in the z axis and door/window destruction.
  7. Like
    Stormy reacted to hardcoreymp in Multiplayer - Tracking Mod   
    Hey Zomboiders,
     
    Just a quick one.  Wanting to see if anyone wants a tracking mod.
     
    Essentially I want to create a mod for the single player that can be ported over to MP for tracking people. Sort of how Daryl tracks ppl in the walking dead
     
    Essentially it will work like this.
    Wherever player "Steve" walks foot prints are placed every 10 steps.  The first marked step would be 100% marked, it would log the time in game and every X minutes / hours it fades by Y %.
     
    If there is enough support I will have a crack at doing it
     
    Peace out
  8. Like
    Stormy got a reaction from EnigmaGrey in Explosions - again   
    Been working off and on with this for a while now. Scraped enough together for a short video.
     
    http://youtu.be/cmrYgd1Ys9c
     
    If indoors, explosions fill the space they're in. I think fire is turned off in the version of zomboid I'm running. There are a few things I'm still struggling to work out such as knocking back zombies; Sprites are drawing in a funny way; really should be animating the explosions. I also need to factor in the z axis and door/window destruction.
  9. Like
    Stormy reacted to turbotutone in Erosion - Nature takes over   
    Thanks
     
    Been working on the nature objects under the new system, ill post some screens,
     
    you will also see some cracks in the screenshots but they are just placeholders, im still working on their spawning rules.
     
    Screenshots:
  10. Like
    Stormy got a reaction from d00de in Explosions - again   
    Been working off and on with this for a while now. Scraped enough together for a short video.
     
    http://youtu.be/cmrYgd1Ys9c
     
    If indoors, explosions fill the space they're in. I think fire is turned off in the version of zomboid I'm running. There are a few things I'm still struggling to work out such as knocking back zombies; Sprites are drawing in a funny way; really should be animating the explosions. I also need to factor in the z axis and door/window destruction.
  11. Like
    Stormy got a reaction from RoboMat in Explosions - again   
    Been working off and on with this for a while now. Scraped enough together for a short video.
     
    http://youtu.be/cmrYgd1Ys9c
     
    If indoors, explosions fill the space they're in. I think fire is turned off in the version of zomboid I'm running. There are a few things I'm still struggling to work out such as knocking back zombies; Sprites are drawing in a funny way; really should be animating the explosions. I also need to factor in the z axis and door/window destruction.
  12. Like
    Stormy got a reaction from LeoIvanov in Explosions - again   
    Been working off and on with this for a while now. Scraped enough together for a short video.
     
    http://youtu.be/cmrYgd1Ys9c
     
    If indoors, explosions fill the space they're in. I think fire is turned off in the version of zomboid I'm running. There are a few things I'm still struggling to work out such as knocking back zombies; Sprites are drawing in a funny way; really should be animating the explosions. I also need to factor in the z axis and door/window destruction.
  13. Like
    Stormy reacted to Thuztor in Erosion - Nature takes over   
    Ah, that are only about 100 tiles!
    No problem! Now I play a little bit: "Life After People"   
  14. Like
    Stormy reacted to turbotutone in Erosion - Nature takes over   
    The idea
     
    To slowly have the map detoriate over time, nature grows wild and the urban areas slowly decay.
     
    What will the mod do?
     
    Currently the planning is for Erosion to add the following effects to the game:
     
    Plantlife:Nature will slowly start to take over, popping up on natural tiles. Currently plants have 6 stages (low grass to tree), only the most fertile spots will reach the maximum. Random special objects with a very low chance of spawning (imagine a dead campfire and the likes). Streets:Big cracks in the road that gradually become more intense. Patches of cracked road where grass and stuff grows through. More litter and garbage appearing over time. Random special objects with a very low chance of spawning (a pile of zombie corpses for example). Houses (exterior):Cracks that can appear on over time. Vines that slowly takover a part of a wall. Windows have a chance to be broken over time (idea by RobertJohnson) Doors have a tiny chance to pop open at some point. Random stuff like smudges and what not.  
     
    Textures by Thutzor
     
    Thutzor will be doing the extensive list of additional artwork for the mod. Thank you Thutzor!
     
    build 27 version:
    pz build 27 click here
    Post 25 march 2014 steam update:
    pz build 26B click here
    Pre 25 march 2014 steam update:
    pz build 26A click here
     
    Download Erosion Alpha 0.1
     
     
    Modding Erosion
     
    Videos
     
    Screenshots
     
    Screenshots Archive
    Outdated screenshots from the very first functional version:
  15. Like
    Stormy got a reaction from umoito in need help with sprites/icons, and much more to come   
    I've implemented this. Going to sort out bolt action next and sort some more bugs. Will upload it all in a few days.
  16. Like
    Stormy got a reaction from umoito in need help with sprites/icons, and much more to come   
    Ok,
     
    First thing, I've noticed some bugs with this and I need some extra time to look into them. For example you seem to be able to put more ammo than you need to inside a magazine.
     
    There were also a few things that meant you were unable to add extra weapons. So, I fixed these problems and I've made the following mod for you which you can then use to expand upon. You mentioned that you were modifying the original zomboid files in the \Steam\steamapps\common\ProjectZomboid folder.
     
    First step, revert these. Whenever zomboid updates it will automatically do this so it's safer to use the mod folder. That way you won't lose any hard work. If you to need restore the steam version manually, right click on the game in steam and select properties, go to the local files tab and click verify local cache.
     
    Next step, find  your zomboid mod directory, if you launch the game, click mods, you'll find the path at the bottom of the mod window. Mine is:
     
    C:\Users\Stormy\Zomboid\mods\
     
    Where Stormy would be your windows user name.
     
    Next, extract the following zip to that directory:
     
    http://download846.mediafire.com/4fl0g3m6c3wg/tttr0ci0smpr924/moreguns.zip
     
    I've sorted out the mod structure for you, so you can continue building on the files inside. Once extracted, the file structure should resemble:
     
    C:\Users\Stormy\Zomboid\mods\moreguns
    C:\Users\Stormy\Zomboid\mods\moreguns\media
    C:\Users\Stormy\Zomboid\mods\moreguns\media\lua
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts
     
    The devs have been clever so that if you name the lua files the same in the mod directory, the game will replace the originals. Therefore, from now on, you can just modify these files to get the results you want. Remember, you'll have to enable the mod once upon starting the game and from then on it will use the mod until you disable it.
     
    There is an important script that I noticed to do with languages which must have additional entries for each weapon you add for the mod to work. These are to do with language translations. It's not immediately obvious (I don't fully understand it) but goes something like this.
     
    In the C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Translate there is a file called Items_empty.txt. You need to create entries for your weapons in there. 
     
    For your Colt where the weapon name is Colt .45 I've created the entry:
     
    DisplayNameColt_.45 = "",
     
    Replacing the space with an underscore. Same for the magazine
     
    DisplayNameColt_Magazine = "",
     
    Compare this with the items.txt in 
     
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns
     
    Here's the shorter entry (the magazine) as an example:
     
    item ColtClip{CanStack = FALSE,Weight = 0.2,Type = Normal,DisplayName = Colt Magazine,Icon = BerettaClip,} You'll see the name in the Items_empty.txt corresponds to the DisplayName of the item in the items.txt. I've made sure the item name (that follows the 'item' declaration above the '{' )doesn't have any spaces or unusual characters (like a period/full stop). The rest is essentially what you managed to do in the ISReloadUtil.lua now found in: C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Reloading I added the entries for the Colt and the Colt magazine and made sure they were added to the lua tables. I've left a debug line in for you as well. The code for which can be found in the stormysReload.lua script. Press L and the game will give you the original Pistol, the new Colt,  a magazine for each and some ammo. Both use the 9mm ammo type. 
    There seems to be some glitches about the magazine appearing in your inventory. I need to look at these too. Hopefully though, there is enough here for you to make a start with.
  17. Like
    Stormy got a reaction from RoboMat in Adding more guns   
    I've seen two threads already and wanted to try and consolidate all the questions about this here.
     
    I've made some changes to the reloading scripts to make it easier to add extra weapons. Provided I can fix the remaining bugs, this should mean that the original lua scripts will not need tampering with in order to have additional weapons take advantage of the reloading scripts.
     
    Preparing the mod directory
     
    Find  your zomboid mod directory, if you launch the game, click mods, you'll find the path at the bottom of the mod window. Mine is:
     
    C:\Users\Stormy\Zomboid\mods\
     
    Where Stormy would be your windows user name.
     
    Next, extract the following zip to that directory:
     
    WARNING: It seems the files in the mod directory do not replace the original lua scripts perfectly. Override the files in the \Steam\steamapps\common\ProjectZomboid\media\lua\Reloading directory with those in the following archive:
     
    http://download1653.mediafire.com/62216je2q0wg/cue340cf05muivz/Reloading+-+moddable.zip
     
    And extract the following to the mod directory explained above.
     
    http://download856.mediafire.com/8x5fpe7hgqyg/tttr0ci0smpr924/moreguns.zip
     
    I've sorted out the mod structure for you, so you can continue building on the files inside. Once extracted, the file structure should resemble:
     
    C:\Users\Stormy\Zomboid\mods\moreguns
    C:\Users\Stormy\Zomboid\mods\moreguns\media
    C:\Users\Stormy\Zomboid\mods\moreguns\media\lua
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts
     
    The devs have been clever so that if you name the lua files the same in the mod directory, the game will replace the originals. Therefore, from now on, you can just modify these files to get the results you want. Remember, you'll have to enable the mod once upon starting the game and from then on it will use the mod until you disable it.
     
    Note this means REPLACE not MERGE. If a zomboid update changes the original files, the change will not be brought across to the custom files meaning potential bug fixes would be missed. Once I figure out the remaining bugs I ask for these versions to be made 'official'.
     
    Defining the items
     
    In the directory:
     
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns
     
    there is an items.txt. This is where the majority of information about the item is found.
     
    module MoreGuns{    item Colt45    {          item info here    }     item ColtClip    {          item info here    }} I've defined the module name 'MoreGuns' which is the same as my mod name. This helps to reduce the difficulty of finding your particular items. Both the module name and the item name must contain no spaces or special characters. I won't go into details about the various fields in the item's information. I've copied mine directly from the existing pistol and changed only the display name. 
    There is an important script that I noticed to do with languages which must have additional entries for each weapon you add for the mod to work. These are to do with language translations. It's not immediately obvious (I don't fully understand it) but goes something like this.
     
    In the C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Translate there is a file called Items_empty.txt. You need to create entries for your weapons in there. 
     
    For your Colt where the weapon name is Colt .45 I've created the entry:
     
    DisplayNameColt_.45 = "",
     
    Replacing the space with an underscore. Same for the magazine
     
    DisplayNameColt_Magazine = "",
     
    Compare this with the items.txt in 
     
    C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns
     
    Here's the shorter entry (the magazine) as an example:
     
    item ColtClip{   CanStack = FALSE,   Weight = 0.2,   Type = Normal,   DisplayName = Colt Magazine,   Icon = BerettaClip,} You'll see the name in the Items_empty.txt corresponds to the DisplayName of the item in the items.txt.  Updating the LUA files  In the folder: C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Reloading You should be able to see the file ZMoreGuns.lua. It is named 'ZMoreGuns' rather than 'MoreGuns' because files are loaded in alphabetical order and I need it to load after storymysReload.lua Anyway, if you open the file, you should be able to see two entries. One for the magazine and one for the weapon. I've declared the magazine first. Here is the information broken down: local coltClip = { name = getItemText("Colt Magazine"), -- Make sure this is the same as the display name in items.txtmoduleName = 'MoreGuns',-- The module the weapon was defined under in items.txtreloadClass = 'ISReloadableMagazine', -- The type of reloading this item will follow (see below)clipType = 'ColtClip',-- The item type as defined in the items.txtammoType = 'Bullets9mm',-- The type of ammo this item takes. You can create a new ammo type in items.txtshootSound = 'none',-- The sound to play when this weapon firesclickSound = nil,-- The sound to play when this weapon dry firesejectSound = 'none',-- The sound to play when a magazine is ejectedinsertSound = 'stormyRevolverInsertRound',-- The sound to play when a round/magazine is insertedrackSound = 'stormyRevolverInsertRound',-- The sound to play when this weapon is rackedcontainsClip = 0,-- Whether the item contains a magazinemaxCapacity = 15,-- The maximum capacity of this itemreloadTime = 30,-- The time taken to insert one round/magazinerackTime = 10};-- The time taken to rack the item For the colt itself there is one extra value: clipData = coltClip This is just pointing to the local maagzine declared above it. Finally, the following statements are called: ReloadUtil:addWeaponType(colt)ReloadUtil:addMagazineType(coltClip) These add the weapon and its magazine to the list of weapons and magazines the reload utility is currently managing. Reload Types There are currently three reload types: ISReloadableMagazineISSemiAutoWeaponISShotgunWeapon A revolver type has not yet been implemented but would likely be restricted to a fixed number of chambers were I to implement it (for reasons to do with saving the reload data). Provided everything compiles there should be no extra steps required. I've left a debug key in the lua. The code for which can be found in the stormysReload.lua script. Press L and the game will give you the original Pistol, the new Colt,  a magazine for each and some ammo. Both use the 9mm ammo type. (I may have commented out the important lines though, make sure you remove the dash that start of any line for which you want to create an item). 
    There seems to be some glitches about the magazine appearing in your inventory. I need to look at these too. Hopefully though, there is enough here for you to make a start with.
  18. Like
    Stormy got a reaction from Ramibuk in how to start fire and stop zombie from moving   
    gridSquare:AddTileObject(IsoFire.new(gridSquare:getCell(), gridSquare, true, 2))
     
    Not sure what that end number is for and the fire seems to spawn long after I call the function but that definitely does add a fire to a square.
  19. Like
    Stormy got a reaction from Ramibuk in How to set character on fire?   
    There's a public static class called IsoFireManager... you could try
     
    IsoFireManager:StartFire(IsoCell cell, IsoGridSquare gridSquare, boolean IgniteOnAny, int FireStartingEnergy) 
     
    Can't remember the exact methods but I guess it would be something like:

    IsoFireManager:StartFire(getPlayer():getGridSquare():getCell(), getPlayer():getGridSquare(), true, 10)
  20. Like
    Stormy got a reaction from RegularX in Event Scheduler   
    Originally posted in this thread: http://theindiestone.com/forums/index.php/topic/1931-how-to-delay-processing-of-a-function/#entry29744
     
    I've been needing something like this and thought it might be useful to other folks.
     
    Zomboid essentially runs a loop and updates the game world every cycle of the loop. Each cycle is commonly referred to as a 'Tick'. So on each 'tick', zomboid does things like detecting whether any keypresses have been made, calculates AI, draws the world, animates things etc etc.
     
    When you use the event hook onTick you are essentially adding an additional function to those that zomboid is already executing each tick. Some things, like detecting keypresses, are likely intended to stay in there indefinitely. However there are certain events that you may wish to fire once when a certain condition is met. Adding these to the onTIck mean that after that condition is met and the event fires, the check will continue to made afterwards, even if the conditions are never met again, or perhaps, the conditions are met again and the same event fires unintentionally.
     
    To counter this I've written these utility classes. By creating ScheduledEvents and adding them to the ScheduledEventsManager, you can have the events remove themselves from the onTick hook or chain events together.
     
    Instead of the adding functions to onTick and letting zomboid's loop handle the execution of events, you add them to the ScheduledEventsManager which will handle them in its own loop.
     
    Here's an explanation of how to work it:
     
     
    As an example mod that could be a treasure hunt, where the conditions check for the presence in the players inventory of an item. Upon finding the item, a new event is created that starts checking for the next item. The final item found then triggers a reward event or whatever.
     
    http://download1591.mediafire.com/tf9c84cj3jkg/lk48iyy5e178fhg/Scheduler.zip
     
    [url=http://theindiestone.com/forums/index.php/topic/2530-mod-permissions/#entry36476]
  21. Like
    Stormy got a reaction from harakka in Event Scheduler   
    Originally posted in this thread: http://theindiestone.com/forums/index.php/topic/1931-how-to-delay-processing-of-a-function/#entry29744
     
    I've been needing something like this and thought it might be useful to other folks.
     
    Zomboid essentially runs a loop and updates the game world every cycle of the loop. Each cycle is commonly referred to as a 'Tick'. So on each 'tick', zomboid does things like detecting whether any keypresses have been made, calculates AI, draws the world, animates things etc etc.
     
    When you use the event hook onTick you are essentially adding an additional function to those that zomboid is already executing each tick. Some things, like detecting keypresses, are likely intended to stay in there indefinitely. However there are certain events that you may wish to fire once when a certain condition is met. Adding these to the onTIck mean that after that condition is met and the event fires, the check will continue to made afterwards, even if the conditions are never met again, or perhaps, the conditions are met again and the same event fires unintentionally.
     
    To counter this I've written these utility classes. By creating ScheduledEvents and adding them to the ScheduledEventsManager, you can have the events remove themselves from the onTick hook or chain events together.
     
    Instead of the adding functions to onTick and letting zomboid's loop handle the execution of events, you add them to the ScheduledEventsManager which will handle them in its own loop.
     
    Here's an explanation of how to work it:
     
     
    As an example mod that could be a treasure hunt, where the conditions check for the presence in the players inventory of an item. Upon finding the item, a new event is created that starts checking for the next item. The final item found then triggers a reward event or whatever.
     
    http://download1591.mediafire.com/tf9c84cj3jkg/lk48iyy5e178fhg/Scheduler.zip
     
    [url=http://theindiestone.com/forums/index.php/topic/2530-mod-permissions/#entry36476]
  22. Like
    Stormy got a reaction from RoboMat in Event Scheduler   
    Originally posted in this thread: http://theindiestone.com/forums/index.php/topic/1931-how-to-delay-processing-of-a-function/#entry29744
     
    I've been needing something like this and thought it might be useful to other folks.
     
    Zomboid essentially runs a loop and updates the game world every cycle of the loop. Each cycle is commonly referred to as a 'Tick'. So on each 'tick', zomboid does things like detecting whether any keypresses have been made, calculates AI, draws the world, animates things etc etc.
     
    When you use the event hook onTick you are essentially adding an additional function to those that zomboid is already executing each tick. Some things, like detecting keypresses, are likely intended to stay in there indefinitely. However there are certain events that you may wish to fire once when a certain condition is met. Adding these to the onTIck mean that after that condition is met and the event fires, the check will continue to made afterwards, even if the conditions are never met again, or perhaps, the conditions are met again and the same event fires unintentionally.
     
    To counter this I've written these utility classes. By creating ScheduledEvents and adding them to the ScheduledEventsManager, you can have the events remove themselves from the onTick hook or chain events together.
     
    Instead of the adding functions to onTick and letting zomboid's loop handle the execution of events, you add them to the ScheduledEventsManager which will handle them in its own loop.
     
    Here's an explanation of how to work it:
     
     
    As an example mod that could be a treasure hunt, where the conditions check for the presence in the players inventory of an item. Upon finding the item, a new event is created that starts checking for the next item. The final item found then triggers a reward event or whatever.
     
    http://download1591.mediafire.com/tf9c84cj3jkg/lk48iyy5e178fhg/Scheduler.zip
     
    [url=http://theindiestone.com/forums/index.php/topic/2530-mod-permissions/#entry36476]
  23. Like
    Stormy got a reaction from RegularX in how to delay processing of a function?   
    Okay so here's a little program I've tested in zomboid:
     
    http://www.mediafire.com/download/lk48iyy5e178fhg/Scheduler.zip
     
    Essentially, the effects can largely be summed up from the temp.lua and you don't really need to pay much attention to the other two classes. The code there is as follows:
    local checkFunction = function(ticksAtCreation, ticks) print("ticksAtCreation"..ticksAtCreation) print("ticks"..ticks) return ticks - ticksAtCreation> 5endlocal performFunction = function() print("Action performed")endlocal postFunction = function() return nilendlocal newEvent = ScheduledEvent:new(ticks, checkFunction, performFunction, postFunction)EventManager.onTickTable[1] = newEventI create three local variables that each hold a function. The check function should return a boolean. It checks the conditions at any given moment and returns true or false. For example, in the above example it checks if 5 ticks have passed (this is a very short amount of time).
     
    The ScheduledEventManager is forced to pass those exact parameters to that function. However, if you could access a global variable (like the in-game date, or the player) you could have any type of condition here (e.g. the player has an item in their inventory or a certain date has been reached).
     
    The performFunction is the action that is performed when the condition is met. In this case, it just prints out to the console.
     
    The postFunction should return the next ScheduledEvent that you want to execute. After the performFunction executes, the postFunction is called and the value it returns replaces the 1 index in the onTickTable.
     
    A ScheduledEvent takes those functions in its constructor. So if you want a new function to execute after the current one you'd write three more functions, add them to a ScheduledEvent, have the postFunction of the first one return that object. If you don't want any more to execute, do as I do and return nil.
     
    The last step is adding the ScheduledEvent we wish to execute first to the EventManager's onTickTable.
     
    I've left some debug statements in there for assistance.
  24. Like
    Stormy got a reaction from Rathlord in Reloading A Shotgun Should Be Way Faster   
    I fail to see what relevance the video posted has when its title is "World's Fastest Shotgun Load". Show me the video of "Person who's never used a gun before attempts to load a shotgun without instruction under stress in a combat situation" and I'll start paying attention.
  25. Like
    Stormy got a reaction from The_Real_Al in how to delay processing of a function?   
    EDIT: Answered my own question. Add a function to OnTick that executes functions in a table and checks first if the table is empty and doesn't do anything if it is. Add your desired function to that table and have it remove itself from the table once executed.
     
    Here is a short program that shows it working:
    print('Start')timesExecuted = 0onTickTable = {}local newFunction = function()            print(timesExecuted)            if(timesExecuted > 5) then             return timesExecuted            else             return nil            end         endonTickTable[1] = newFunctionlocal checkTickTable = function()         local removeIndex = 1             local functionToRemove = {}             for i,method in ipairs(onTickTable) do             if method ~= nil then             local temp = method()             if temp == nil then                print('fail')             else                print('success')                  functionToRemove[removeIndex] = i                removeIndex = removeIndex + 1             endend             end             for i=1, removeIndex-1 do             onTickTable[functionToRemove[i]] = nil             endend-- Mock OnTick functionwhile(timesExecuted < 10) do    local temp = checkTickTable() -- Add this to OnTick    timesExecuted = timesExecuted + 1endprint('Finish')Output:
     
    Start0fail1fail2fail3fail4fail5fail6successFinish After 6 is printed, the function is removed from the table and never executes again. Therefore no fear of overhead. The only overhead you have now comes from the checkTicksTable which effectively does nothing because the table is empty.  Because of the way Lua uses nil to determine whether the end of an array has been met I'm not sure if this works if onTickTable look like {function1, function2, nil, function3}. But still, with only one function, you should be fine. In your function you'd be checking that the current ticks value is greater than 5secs + the ticks value at the time the function was created. This may take a little more work passing value around but I'm fairly sure it's all possible.
×
×
  • Create New...