Author Topic: How To  (Read 1541 times)

0 Members and 1 Guest are viewing this topic.

Offline EXNET OWNER

  • Member
  • ***
  • Posts: 43
  • Karma: +0/-0
How To
« on: 01 September, 2004, 14:25:15 »
I have a bot with the following variables and i am having no luck at creatniga working .ini file so that the variables are read from the file rather than the script. Could someone please make create a .ini file for a bot witht the following variables, thankyou...

BotName = "-???OwL???-"
Description = ""
Connection = "DSL"
Version = "0.500"
Mode = "A"
HubsOp = "1"
HubsReg = "0"
HubsGuest = "0"
Slots = "3"
Tag = "<++ V:"..Version..",M:"..Mode..",H:"..HubsGuest.."/"..HubsReg.."/"..HubsOp..",S:"..Slots..">"
Email = "None"
Share = 6958739042 -- In Bytes not KB, MB or GB

I hope somoen could help me as I am finding this really hard :)

PtokaX forum

How To
« on: 01 September, 2004, 14:25:15 »

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #1 on: 01 September, 2004, 14:28:58 »
can u post the script to?


Otherwise check get Black_Pearl to read settings from cfg file for a similar example
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline nErBoS

  • Emperor
  • **
  • Posts: 1 149
  • Karma: +3/-1
(No subject)
« Reply #2 on: 01 September, 2004, 21:47:38 »
Hi,

Simple as this...

Code: [Select]
fSetting = "setting.ini" -- Path of the file

function Main()
assert(dofile(fSetting),"File Setting.ini was not Found.")
end

Best regards, nErBoS
« Last Edit: 01 September, 2004, 21:48:17 by nErBoS »
--## nErBoS Spot ##--

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
(No subject)
« Reply #3 on: 02 September, 2004, 03:49:23 »
this is one way to load settings from an ini style file.

Code: [Select]

--//LUA4 / PTOKAX
readfrom("yourfile.bleh")
while 1 do
   local line = read()
   if (line == nil) then
      break
   else
      if strsub(line,1,9) =="Status =" then
         setting1=strsub(line,9,srlen(line))
      elseif strsub(line..........................
         setting2=strsub(line...............
      end
end
readfrom()

this show u 'HOW TO' do it. it does not do it for you.  

saveing in an ini style file.
Code: [Select]
--BotName = "-???OwL???-"
--Description = ""
--Connection = "DSL"
--Version = "0.500"

function inistyledata()
local tmp = ""
local tmp = "[Settings]\r\n"..
                     "BotName = "..BotName.."\r\n"..
                     "Description = "..Description.."\r\n"..
                     "Connectoin = "..Connectoin.."\r\n"..
                     "Versoin = "..Versoin.."\r\n"
return tmp
end

local f,e = openfile( "yourfilename.bleh", "w+" )
   if f then
     write(f, inistyledata() )
     closefile(f)
   end

Is the ini file for the user of the script to change??? or just for saving data... if it is just for saving data i recommend putting all you data in 1 table, and user serialization to save and dofile() to load. much faster and more reliable than the way you are doing it now.

i'm working on a lil 'how to' for saving and loading strings and tables, and creating files and paths..... keep an eye out for it.


:D

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

PtokaX forum

(No subject)
« Reply #3 on: 02 September, 2004, 03:49:23 »