Jump to content

problem i/o lua & insert.table


Recommended Posts

Well dev, actually im trying to do a table with io and table.insert but when i do i only have 1 value in my insert.table not 2.

 

This is my quest:

quest pet_system begin
	state start begin

function get_io_path()
	return "/usr/home/mt2/share/locale/germany/pet_system/"..pc.get_name()..".txt"
end


function write()

	local t = io.open(pet_system.get_io_path(), "w")

	t:io_write("HitBye")
	t:close()
end


function read()
	local PetSkill = {}	
		for line in io.lines(pet_system.get_io_path()) do
			table.insert(PetSkill, line)
		end
	return PetSkill
end

		when 53001.use begin
			pet.summon(34001, "Fenix", false)
			pet_system.write()
			say(pet_system.read()[1])
		end
	end
end

The output on my server is Hi Bye, not: Hi

 

Any idea¿

:D

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

quest pet_system begin
    state start begin
 
function get_io_path()
    return "/usr/home/mt2/share/locale/germany/pet_system/"..pc.get_name()..".txt"
end
 
 
function write()
 
    local t = io.open(pet_system.get_io_path(), "w")
 
    t:write("HinBye")
    t:close()
end
 
 
function read()
    local PetSkill = {}
        for line in io.lines(pet_system.get_io_path()) do
            table.insert(PetSkill, line)
        end
    return PetSkill
end
 
        when 53001.use begin
            pet.summon(34001, "Fenix", false)
            pet_system.write()
            say(pet_system.read()[1])--Hi
            say(pet_system.read()[2])--Bye
        end
    end
end

You did 2 mistakes:

 

a)You're using t:io_write which is wrong,so use t:write

 

b)You're writing ("HitBye") t = tab so use n

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 3

      Auto Potion refill event

    2. 0

      Different Staff Wanted!!

    3. 11

      Voooxy aka m2core.tech scammer

    4. 1

      QUESTS only appear on CH1

    5. 4

      Rubinum - Serverfiles [VDI]

    6. 1

      QUESTS only appear on CH1

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.