Revision 3674

Date:
2019-09-18 00:39:22
Author:
dsb
Revision Log:
Make sure the save directory exists before trying to write the automatizer
file into it.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • tome2/trunk/class/Automatizer.lua

     
    189 189
    190 190 function _M:playerFilename(auto)
    191 191 local short_name = game.save_name:gsub('[^a-zA-Z0-9_-.]', '_'):lower()
    192 local save_dir = '/save/'..short_name..'/'
    192 193 local auto_sfx = auto and '-auto' or ''
    193 return '/save/'..short_name..'/automatizer'..auto_sfx..'.lua'
    194 local filename = save_dir .. 'automatizer'..auto_sfx..'.lua'
    195 return filename, save_dir
    194 196 end
    195 197
    196 198 function _M:loadForPlayer()
    197 local short_name = game.save_name:gsub('[^a-zA-Z0-9_-.]', '_'):lower()
    198 self:loadDefinition(self:playerFilename(true), true)
    199 self:loadDefinition(self:playerFilename(false))
    199 local filename = self:playerFilename(true)
    200 self:loadDefinition(filename, true)
    201 local filename = self:playerFilename(false)
    202 self:loadDefinition(filename)
    200 203 end
    201 204
    202 205 function _M:validateAutomatizerRule(t)
     
    721 724 --
    722 725 ]]
    723 726
    727 -- Perhaps overkill, but just in case...
    728 fs.mkdir('/save/')
    724 729 local f = fs.open(self.WORLD_AUTOGEN_FILE, 'w')
    725 730 f:write(hdr)
    726 731 f:write('-- Auto-generated rules that apply to all characters.\n')
     
    729 734 end
    730 735 f:close()
    731 736
    732 f = fs.open(self:playerFilename(true), 'w')
    737 local filename, save_dir = self.playerFilename(true)
    738 fs.mkdir(save_dir)
    739 f = fs.open(filename, 'w')
    733 740 f:write(hdr)
    734 741 f:write('-- Auto-generated rules that apply to '..game.save_name..'.\n')
    735 742 for _, rule in ipairs(self.atm_rules) do