Hello Guest

Can't append external File

  • 4 Replies
  • 791 Views
*

Saaho2019

  • *
  • 4
  • +0/-0
    • View Profile
Can't append external File
« on: November 20, 2019, 02:47:42 pm »
Hey i was trying to implement this
Code: [Select]
chance  = 98
nextbet = 0.00015
bethigh = true

local rollsData = {}
function dobet()
    local betIdString     = tostring(lastBet.Id)
    local betIdNonce     = tostring(lastBet.nonce)
    local betIdRoll     = tostring(lastBet.Roll)

    print(betIdNonce .. betIdString)
    local f = assert(io.open("quicksave.txt", "w"))
    io.output(f)
    f:write(betIdString, "\t")
    f:write(betIdNonce, "\t")
    f:write(betIdRoll, "\n")
    f:close()

end

Where i want to save few bet properties to an external text file.
but i can't perform append operation as i am getting this error.
[string "chunk"]:10: quicksave.txt: error #-1

*

Seuntjie

  • *****
  • 479
  • +13/-2
    • View Profile
Re: Can't append external File
« Reply #1 on: November 20, 2019, 02:58:10 pm »
Before addressing the append issue, why do you want to save it to a file?

Are you aware that all of your bets are stored in a sqlite database called dicebot.db? You can browse and query the database using a program like sqlitebrowser.

*

Saaho2019

  • *
  • 4
  • +0/-0
    • View Profile
Re: Can't append external File
« Reply #2 on: November 20, 2019, 03:07:37 pm »
didn't knew that all bets are stored inside sql database dicebot.db.

Will check that out thank you :)

*

vineeee

  • **
  • 14
  • +0/-0
    • View Profile
Re: Can't append external File
« Reply #3 on: December 16, 2019, 09:14:28 am »
Hello,

me again, i really want to use append mode, not for the bet result, but for other stuff.
I have exact the same problem write to file works, but write erase all previous data in that file.. Maybe is something with path..
Which version of LUA is used in this program?
Thank you for great work again!

*

Seuntjie

  • *****
  • 479
  • +13/-2
    • View Profile
Re: Can't append external File
« Reply #4 on: December 20, 2019, 02:14:43 pm »
It uses sharplua: https://github.com/efrederickson/SharpLua

I haven't tried writing to files, but I know others have and IIRC they also had issues appending files. It might have been on the forum, but I'm not sure, I also don't know if they solved the issue. It was a long time ago