Jump to content
  • 0

Help to write a script


NIKITAOFF

Question

I want to save to file the text that I entered in gg.prompt

function main()

m = gg.choice({

"Write",

"Exit"

},nil,"test")

if m == nil then else

if m == 1 then write() end

if m == 2 then exit() end

end

farm = -1

end

 

function write()

local writename = "/sdcard/Download/log.txt"

local write

write = io.open(writename,"w")

  

  write:write(gg.prompt(

    {'test'},

    {[1]='write here'},

    {[1]='text'}

))

  if crashw == nil then

    gg.alert("You did not enter anything")

    main()

    end

gg.setVisible(true)

print('Yeah!!!')

os.exit()

end

 

function exit()

os.exit()

end

 

while true do

  if gg.isVisible(true) then

    farm = 1

    gg.setVisible(false)

  end

  if farm == 1 then main()

  end

  end

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

On Thu Dec 13 2018 at 8:00 AM, Revoxtical said:

 

Try this :


function main()
  local m = gg.choice({"Write", "Exit"}, nil, "test")
  if m ~= nil then
	if m == 1 then write() end
	if m == 2 then exit() end
  end
end

function write()
  local txt = gg.prompt({'test'}, {'write here'}, {'text'})
  if txt ~= nil and #txt[1] > 0 then
	local f = io.open("/sdcard/Download/log.txt", "w")
	f:write(txt[1])
	f:close()
	gg.setVisible(true)
	print('Yeah!!!')
	exit()
  else
    gg.alert("You did not enter anything")
  end
end

function exit()
  os.exit()
end

while true do
  if gg.isVisible() then
    gg.setVisible(false)
    main()
  end
  gg.sleep(100)
end

 

Thank you very much!!

Link to comment
Share on other sites

14 hours ago, NIKITAOFF said:

I want to save to file the text that I entered in gg.prompt

function main()

m = gg.choice({

"Write",

"Exit"

},nil,"test")

if m == nil then else

if m == 1 then write() end

if m == 2 then exit() end

end

farm = -1

end

 

function write()

local writename = "/sdcard/Download/log.txt"

local write

write = io.open(writename,"w")

  

  write:write(gg.prompt(

    {'test'},

    {[1]='write here'},

    {[1]='text'}

))

  if crashw == nil then

    gg.alert("You did not enter anything")

    main()

    end

gg.setVisible(true)

print('Yeah!!!')

os.exit()

end

 

function exit()

os.exit()

end

 

while true do

  if gg.isVisible(true) then

    farm = 1

    gg.setVisible(false)

  end

  if farm == 1 then main()

  end

  end

 

Try this :

function main()
  local m = gg.choice({"Write", "Exit"}, nil, "test")
  if m ~= nil then
	if m == 1 then write() end
	if m == 2 then exit() end
  end
end

function write()
  local txt = gg.prompt({'test'}, {'write here'}, {'text'})
  if txt ~= nil and #txt[1] > 0 then
	local f = io.open("/sdcard/Download/log.txt", "w")
	f:write(txt[1])
	f:close()
	gg.setVisible(true)
	print('Yeah!!!')
	exit()
  else
    gg.alert("You did not enter anything")
  end
end

function exit()
  os.exit()
end

while true do
  if gg.isVisible() then
    gg.setVisible(false)
    main()
  end
  gg.sleep(100)
end

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.