E1M1 Posted August 8, 2009 Share Posted August 8, 2009 (edited) Hello, I made include file for autoit 3 than allows you read and write lua files, it works just like iniread and iniwrite, but this include file is made for lua files >_< It's my 1-st script I ever released for public File contains 3 functions: _LuaRead($hFile, $sKey, $sDefault) - Reads key from lua file _LuaWrite($hFile, $sKey,$sValue) - writes key to lua file _RemoveSpace($sString) - remove spaces and tabs at the beginning of lua E1M1's LuaReadWrite.au3 expandcollapse popup#include <file.au3> ; #FUNCTION# ;=============================================================================== ; ; Name...........: _LuaRead ; Description ...: Returns key value ; Syntax.........: _LuaRead($hFile, $sKey, $sDefault) ; Parameters ....: $hFile - The filename of the .lua file. ; $sKey - The key name in the in the .lua file. ; $sDefault - The default value to return if the requested key is not found. ; Return values .: Success - Key value ; Failure - Returns $sDefault and Sets @Error: ; |0 - No error. ; |1 - File not found ; |2 - Key not fund ; |3 - File might be invalid ; Author ........: E1M1 ; Modified.......: ; Remarks .......: ; Related .......: _LuaWrite ; Link ..........; ; Example .......; Yes ; ; ;========================================================================================== Func _LuaRead($hFile, $sKey, $sDefault) If Not FileExists($hFile) Then SetError(1) Return $sDefault EndIf $array = StringSplit(FileRead($hFile), @CRLF,1) If @error Then SetError(3) EndIf For $i = 1 To $array[0] If StringInStr($array[$i], $sKey) Then If StringInStr($array[$i], $sKey) <> 1 Then If StringInStr(StringLeft($array[$i], StringInStr($array[$i], $sKey) - 1), 2) <> "--" Then SetError(0) Return _RemoveSpace(StringTrimLeft($array[$i], StringInStr($array[$i], "="))) EndIf Else SetError(0) Return _RemoveSpace(StringTrimLeft($array[$i], StringInStr($array[$i], "="))) EndIf EndIf Next SetError(2) Return $sDefault EndFunc ;==>_LuaRead ; #FUNCTION# ;=============================================================================== ; ; Name...........: _RemoveSpace ; Description ...: Removes spaces and tabs at beginning of string ; Syntax.........: _RemoveSpace($sString) ; Parameters ....: $sString - Input string ; Return values .: $sString with out spaces and tabs at the beginning of string ; Author ........: E1M1 ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; No ; ; ;========================================================================================== Func _RemoveSpace($sString) While 1 If StringLeft($sString, 1) = " " Or StringLeft($sString, 1) = @TAB Then $sString = StringTrimLeft($sString, 1) Else Return $sString EndIf WEnd EndFunc ;==>_RemoveSpace ; #FUNCTION# ;=============================================================================== ; ; Name...........: _LuaWrite ; Description ...: Writes a value to a standard format .lua file. ; Syntax.........: _LuaWrite($hFile, $sKey,$sValue) ; Parameters ....: $hFile - The filename of the .lua file. ; $sKey - The key name in the in the .lua file. ; $sValue - The value to write/change. ; Return values .: Success - 0 ; Failure - Sets @Error: ; |0 - No error. ; |1 - File not found ; |2 - Key not fund ; |3 - File might be invalid ; Author ........: E1M1 ; Modified.......: ; Remarks .......: ; Related .......: _LuaRead ; Link ..........; ; Example .......; Yes ; ; ;========================================================================================== Func _LuaWrite($hFile, $sKey,$sValue) If Not FileExists($hFile) Then _FileCreate($hFile) SetError(1) EndIf $array = StringSplit(FileRead($hFile), @CRLF,1) If @error Then SetError(3) EndIf For $i = 1 To $array[0] If StringInStr($array[$i], $sKey) Then If StringInStr($array[$i], $sKey) <> 1 Then If StringInStr(StringLeft($array[$i], StringInStr($array[$i], $sKey) - 1), 2) <> "--" Then SetError(0) _FileWriteToLine($hFile,$i,StringLeft($array[$i], StringInStr($array[$i], "="))&$sValue,1) Return 0 EndIf Else SetError(0) _FileWriteToLine($hFile,$i,StringLeft($array[$i], StringInStr($array[$i], "="))&$sValue,1) Return 0 EndIf EndIf Next SetError(2) _FileWriteToLine($hFile,_FileCountLines($hFile),$sKey&" = "&$sValue,1) EndFunc ;==>_LuaWrite Here is example script to show you how to use it. #include "LuaReadWrite.au3" MsgBox(1, "test", _LuaRead("settings.lua", "Settings.ChickenOnHostileMessage", "Failed to read")) _LuaWrite("settings.lua", "Settings.ChickenOnHostileMessage",'"Come and get pwnt"') MsgBox(1, "test", _LuaRead("settings.lua", "Settings.ChickenOnHostileMessage", "Failed to read")) Here is settings.lua used by example expandcollapse popupSettings = {} ------------------Char Builds-------------------------------- Settings.Build = "Hammerdin.lua" --Settings.Build = "LightSorc.lua" --Settings.Build = "Trapsin.lua" --Settings.Build = "Zmiter.lua" ------------------ Pickit Revolution ------------------ --Settings.Pickit = "Greedy" --Settings.Pickit = "Moderate" Settings.Pickit = "Strict" ------------------ GAME DELAYS ------------------------- Settings.WalkDelay=250 Settings.FindNpcStoreDelay = 500 Settings.MaxGameTime=600 Settings.KillDelay=100 Settings.SellDelay = 500 Settings.StashDelay = 500 ------------ POTION & CHICKEN SETTINGS ----------------- Settings.PotRow = {} Settings.PotRow[1]=PotionType.Blue Settings.PotRow[2]=PotionType.Red Settings.PotRow[3]=PotionType.Purple Settings.PotRow[4]=PotionType.Purple -- percentage life values Settings.RedPot = 85 -- Life percentage required to chug down a red pot Settings.BluePot = 50 -- same for mana Settings.PurplePot = 50 -- Life percentage required to chug down a purple pot Settings.PurplePotMana = 0 -- Same for mana, usually happens when youre out of bluepots Settings.ChickenTown= 30 Settings.ChickenExit= 15 Settings.ChickenOnHostile = false Settings.ChickenExitMessage="CLUCK!" Settings.ChickenTownMessage="CLUCK!" Settings.ChickenOnHostileMessage ="Come and get pwnt" --------- MERC POTION & RESURRECT SETTINGS ------------- Settings.UseMerc = true Settings.MercRedPot = 60 Settings.MercPurplePot = 20 Settings.AutoResurrect = false Settings.ChickenTownOnIronMaiden = false Settings.ReEquipMercWeapon = true ------------ BOT ACTIONS & BEHAVIORS ------------------- Settings.AttackDistance=0 Settings.UseRedemption = true --switches redemption on for 0,75s after finishing some things... Settings.KillIMCasters = true --Gets Oblivion knights first when using clearpath, cleararea etc. Settings.ClearPath = false --Clear the path of enemies while moving from point A to point B Settings.UseTeleport = true --walking bot or a teleportin bot? hmm... Settings.KillMinions = true Settings.UseAnyasPortal = false Settings.KillHostiledPlayer = false --Make that bastard pay for the insult. Settings.UseCta = true --Self explanatory Settings.GambleFrom = 1000000 Settings.GambleTo = 10000 Settings.StashGold=10000 --Minimum amount of gold to stash Settings.StashEveryWhere = false --Warning if enabled this may or may not get you banned. The bot will stash items without moving to the Stash in Town and its reliable. Be advised and pray to god Settings.DropInventoryGold=0 Settings.DumpItems = false Settings.AutoDump = false Settings.InstantDump = false Settings.TownPick = true Settings.KillHeroes = false Settings.OpenChests = false Settings.ShopHealth=70 Settings.ShopMana=50 Settings.ShopBlue=4 Settings.ShopRed=4 Settings.ShopTp=10 Settings.ShopId=10 Settings.UseCube = true Settings.CastTp= false Settings.PrecastTime = 90 --ExitMethod=0 ----------- GAME CONFIGURATION & OPTIONS --------------- Settings.PublicChat = false Settings.PublicBot = false Settings.SquelchLevel = 10 Settings.AutoParty = true Settings.AcceptParty = true Settings.StopOnDiaClone = true --------------- IMMUNITY SETTINGS ---------------------- Settings.SkipImmunePhysical = false Settings.SkipImmuneMagic = false Settings.SkipImmuneFire = false Settings.SkipImmuneLightning = false Settings.SkipImmuneCold = false Settings.SkipImmunePoison = false --------------- AURA SKIP FUNCTIONS -------------------- Settings.SkipAuraFanatics = false ------------------ INVENTORY LOCK ---------------------- -- 0=STASH OR SELL 1=LOCK INTO INVENTORY -- -------------------------------------------------------- Settings.Inventory = {} Settings.Inventory[1]= { 0,0,0,0,0,0,0,1,1,1 } Settings.Inventory[2]= { 0,0,0,0,0,0,0,1,1,1 } Settings.Inventory[3]= { 0,0,0,0,0,0,0,1,1,1 } Settings.Inventory[4]= { 0,0,0,0,0,0,1,1,1,1 } -------------------------------------------------------- -- BAAL SETTINGS -- -- DONT MODIFY UNLESS U KNOW WUT TO DO -- -------------------------------------------------------- ------------ BAAL MESSAGES & SETTINGS ------------------ Settings.BaalStartMessage="Welcome to my baal runs!" Settings.BaalHotMessage="TP is HOT! High lvls plz help clear" Settings.BaalWarmMessage="TP is WARM. %d near tp, %d total" Settings.BaalColdMessage="TP safe" Settings.WaveMessage = {} Settings.WaveMessage[1]="" Settings.WaveMessage[2]="" Settings.WaveMessage[3]="" Settings.WaveMessage[4]="" Settings.WaveMessage[5]="" Settings.WaveMessage[6]="" Settings.NgMessage="New Game" Settings.BaalKillMessage="Baal!" --Settings.VoteMessage="Type .vote if you want to kill Baal" Settings.KillBaal = true --Settings.VoteBaal=0 ------------- WAVE-BASED AURA CHANGES ------------------ Settings.WaveSkill = {} Settings.WaveSkill[1]=SkillType.Redemption Settings.WaveSkill[2]=SkillType.Cleansing Settings.WaveSkill[3]=SkillType.Redemption Settings.WaveSkill[4]=SkillType.Cleansing Settings.WaveSkill[5]=SkillType.Redemption Settings.WaveSkill[6]=SkillType.Cleansing -------------------------------------------------------- -- ADVANCED BAAL OPTIONS -- -- DON'T MODIFY UNLESS YOU KNOW WHAT TO DO -- -------------------------------------------------------- ---------------- PRECAST LOCATION ---------------------- Settings.Precast = {} Settings.Precast.x=15092 Settings.Precast.y=5025 ------------ THRONE TELEPORT LOCATION ------------------ Settings.Teleport = {} Settings.Teleport.x=15090 Settings.Teleport.y=5005 ----------- THRONE TOWN PORTAL LOCATION ---------------- Settings.Tp = {} Settings.Tp.x=15117 Settings.Tp.y=5003 ----------- BAAL WAVE-SPECIFIC LOCATION ---------------- --[[-Precast[0].x=15092 -Precast[0].y=5025 -Precast[1].x=15092 -Precast[1].y=5025 -Precast[2].x=15092 -Precast[2].y=5025 -Precast[3].x=15092 -Precast[3].y=5025 -Precast[4].x=15092 -Precast[4].y=5025 -Precast[5].x=15092 -Precast[5].y=5025]] -------------------------------------------------------- -- DIABLO SETTINGS -- -- DON'T MODIFY UNLESS YOU KNOW WHAT TO DO -- -------------------------------------------------------- ----------- CHAOS-DIABLO-GRUSH MESSAGES ---------------- Settings.DiabloStartMessage="Welcome to my chaos run!" Settings.DiabloHotMessage="Lots of minions. Please wait..." Settings.DiabloWarmMessage="High levels plz come help" Settings.DiabloColdMessage="OK, TP's safe for leechers!" Settings.DiabloKillMessage="Let's Kill D then I make NG" Settings.NextBossMessage="New game" ------------- SEAL ORDER - TP LOCATION ----------------- Settings.Seal1="right" Settings.Seal2="top" Settings.Seal3="left" Settings.DiabloTp = {} Settings.DiabloTp.x=7793 Settings.DiabloTp.y=5555 -------------------------------------------------------- -- MEPHISTO SETTINGS -- -------------------------------------------------------- Settings.LetMercHoldMeph = false Settings.UseMoat = false post all bugs and feature requests here. Edited August 8, 2009 by E1M1 edited Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now