Jump to content


vyse's Content

There have been 7 items by vyse (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#276806 [1.7.10] CubeSpace Creative [CC 1.75] [24/7]

Posted by vyse on 12 April 2018 - 01:14 AM in Servers

Ign: Vyse1962
Hi, id like to join the server cause I'm looking for a great community to join, with the fun of mods, and CC. Joining a server and becoming part of the community would be a wonderful experience.



#276772 Trouble with Reading a table off of a disk

Posted by vyse on 10 April 2018 - 10:39 PM in Ask a Pro

View PostKingofGamesYami, on 10 April 2018 - 10:17 PM, said:

You used serialize instead of unserialize.
oh lol, I didn't see that haha.
well, it's not in my program but it was in here. must have been from transferring whoops my bad :D



#276770 Trouble with Reading a table off of a disk

Posted by vyse on 10 April 2018 - 09:40 PM in Ask a Pro

So I have this program I've been working on but now I've run into a problem with the function disk() not properly reading the disk right. Its suppose to read the file on the disk which contains the Table of the same on the computer. It opens both of them reads them and then is suppose to compare them and either grant you access or deny it. And all it does is deny it..

local Tbe = {}


function Disk()
  while true do

  local driveSide
	for _, side in ipairs(rs.getSides()) do
	   if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
		   driveSide = side
		   break
		end
	 end
   Login()
   D = os.pullEvent()
   Page.setCursorPos(17, 10)
   Page.write("checking...")
   sleep(0.2)
	if disk.hasData(driveSide) == true then
		Page.setTextColor(colors.green)
		Page.setCursorPos(17, 10)
		Page.write("Disk inserted!")
		sleep(0.2)
	  if fs.exists("disk/USERS.txt") then
		   local Dbe = {}
		   d = fs.open("disk/USERS.txt","r")
		   Dbe = textutils.unserialize(d.readAll())
		   Dpass = Dbe.pass
		   side1 = Dbe.side
		   s = fs.open("saves/USERS.txt","r")
		  Tbe = textutils.unserialize(s.readAll())
		   pass1 = Tbe.pass
		  s.close()
		  d.close()
		if (Dpass == pass1) then
		   disk.eject(driveSide)
		   pass()
		 else
		  Inv()
		  P()
		 end
	   else
	   disk.eject(driveSide)
	   Page.setCursorPos(17, 10)
	   Page.write("Invaild disk type!")
	   sleep(0.5)
	   P()
	  end
	
	else
	Page.setCursorPos(17,10)
	Page.write(" no disk is inserterd.")
	sleep(1)
	P()
	end
  end
end

This is just the one spot I'm having trouble with.
I'd rather not paste all of it haha.



Solved.



#276736 Trying to read a table and make it display the username.

Posted by vyse on 09 April 2018 - 05:58 PM in Ask a Pro

View PostEveryOS, on 09 April 2018 - 05:47 PM, said:

I've modified it, try the new code, you will first have to delete saves/user.txt
Thank you! i got it to work. so the problem was i didnt have a way to read the table in SecureV() so I just went ahead and put

local u = fs.open("saves/USER.txt", "r")
local Mt = textutils.unserialize(u.readAll())
u.close()
local name = Mt.name
and works great now thank you!



#276733 Trying to read a table and make it display the username.

Posted by vyse on 09 April 2018 - 05:38 PM in Ask a Pro

View PostEveryOS, on 09 April 2018 - 05:27 PM, said:

local Tbe = {}
local function SecureV()
   term.setCursorPos(2, 19)
   write("username"..Tbe.user)
end
local function reg( user )
  local f = fs.open("saves/USERS.txt", "w")
  f.write(textutils.serialize({user}))
  f.close()
end
local function Regist()
  if not fs.exists("saves/USERS.txt") then
	local user = {}
	write("Creating new profile\nUsername: ")
	user.name = read()
	print("Password:")
	user.pass = read("*")
	reg( user )
  else
	print("starting..")
  end
end
local function login()
  local s = fs.open("saves/USER.txt", "r")
  Tbe = textutils.unserialize(s.readAll())
  s.close()
   local user1 = Tbe.user
   local pass1 = Tbe.pass
   local password = read("*")
	 if password == pass1 then
	   SecureV()
	   redstone.setOutput("right", true)
	   sleep(2)
	   redstone.setOutput("right", false)
	 else
		print("incorrect")
	 end
end
Regist()
login()
Try this
Hmmm.. I get this..
startup:15: attempt to concentrate string and nil -- this is the write("username:"..Tbe.user)

edit: I was able to successfully login when i took the write("username"..Tbe.user) out. and it successfully stored the data. but now i just need to read the username properly.



#276731 Trying to read a table and make it display the username.

Posted by vyse on 09 April 2018 - 05:15 PM in Ask a Pro

View PostEveryOS, on 09 April 2018 - 05:12 PM, said:

Mismatched quotes, Tbe vs tbe is case-sensitive, you are defining tbe locally but trying to access it in a function defined before the variable (outside scope), et cetera, et cetera
So what your saying is I should have Tbe = Tbe instead of making different ones like Tbe and tbe. see I wasn't sure what to do there soI just started fiddling around but it's not going so well haha.

Edit: so I've changed some things around. like taking out the username part for right now and it seems the password part fails every time. so I'm not sure how reading the table is supposed to work.
I have looked at many types of ways to do it but I can't get it right for some reason.



#276729 Trying to read a table and make it display the username.

Posted by vyse on 09 April 2018 - 05:06 PM in Ask a Pro

Hey there, I'm having trouble with reading a file and making it a variable so I can display the username.
{
  {
	 name = "Vyse",
	 pass = "test",
   },
}
how the table is inside the file.

So to give you more info I have a password system I'm trying to create with an ability to ask for one's name and pass. which then are put on the table like so.

The trouble I'm having is actually making the serialized table become variable I can use in print or a statement.

local function SecureV()
	term.setCursorPos(2, 19)
   write("username"..Tbe.user)
end
local function reg( user )
  local tbl = {}
			 table.insert(tbl, user)
			  local f = fs.open("saves/USERS.txt", "w")
			   f.write(textutils.serialize(tbl))
			   f.close()
end
local function Regist()
  if fs.exists("saves/USERS.txt") == false then
		local user = {}
		  user.name = read()
		  user.pass = read("*")
		reg( user )
  else
	print('starting..")
  end
end


local function login()
  
		  local s = fs.open("saves/USER.txt", "r")
		   Tbe = textutils.unserialize(s.readAll())
		   s.close()
			local Tbe = {}
				 local user1 = Tbe.user
				 local pass1 = Tbe.pass
			local password = read("*")
		 if password == pass1 then
				 redstone.setOutput("right", true)
				 sleep(2)
				  redstone.setOutput("right", false)
		else
		  print("incorrect")
	   end
end

Regist()
login()

I took out what I thought I could use help or some advice on. I'm honestly just trying to get the name, copy it into a table named USERS.txt then go open it with it only asking for a password, and displays the name.

any help would be appreciated :)