Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

TheJebForge

Members
  • Content Count

    3
  • Joined

  • Last visited

Posts posted by TheJebForge

  1. bankAccounts folder exists. Just it can't make a filestream. Error is: error to get global fil (got a nil).

    When I try to switch from wb to w. Nothing happens. Same error.

    With events anything is okay. Error appears when computer got a message and tries to make changes to file system.

  2. I want to make my bank system for my server, but I got problem when making bank network.

     

    When server tries write a file, it got an error like fil = nil. I can't solve the problem, so please help me!

    There's the code:

    local com = require("component")
    local ev = require("event")
    local fs = require("filesystem")
    local net = com.modem
    net.open(15)
    print("Opened Net. Waiting for commands")
    while true do
      local _,_,from,port,_,message,nick,balance = ev.pull("modem_message")
      if message == "getInfo" then
        if fs.exists("bankAccounts/"..nick) then
          local fil = io.open("bankAccounts/"..nick,"r")
          bal = fil:read(1000)
          fil:close()
          net.send(from,15,nick,bal)
        else
          net.send(from,15,"no info")
        end
      end
      if message == "setInfo" then
        local fil = io.open("bankAccounts/"..nick,"wb")
        fil:write(balance)
        fil:close()
        net.send(from,15,"done it")
      end
    end
    
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.