Jump to content
  • 0

Script error


cloniu

Question

Posted

Hello. Today, while writing a script, I encountered an error. The whole point is that I wanted to make a menu with functions for a separate game, and gave this error:

Quote

Script complete:
Script error: luaj.o: /storage/emulated/0/DCIM/SharedFolder/Tutorial.lua:16
`if games == 1 then somenu() end`
attempt to call a nil value (global 'somenu')
level = 1, const = 16, proto = 1, upval = 1, vars = 4, code = 54
CALL v0..v0
 ; PC 45 CODE 0080401D OP 29 A 0 B 1 C 1 Bx 513 sBx -130558
stack traceback:
    /storage/emulated/0/DCIM/SharedFolder/Tutorial.lua:16 in main chunk
    [Java]: in ?
    at luaj.LuaValue.a(001B.java:2)
    at luaj.LuaValue.Z(001B.java)
    at luaj.LuaValue.l(001B.java)
    at luaj.LuaClosure.a(0105.java)
    at luaj.LuaClosure.l(0105.java)
    at android.ext.Script.d(004E.java:22)
    at android.ext.Script$ScriptThread.run(0022.java)

I hope you can help me and give me the corrected script. It's just that I'm just starting to remember how to write scripts, and I don't remember anything I did a year ago.

Full script below

if gg.isVisible(true) then
gg.setVisible(false)
end
goto menu
::menu::

menu = gg.choice({'Games💕','Exit💕'},nil,'MultiScript by CloniuStudio💕')

if mine == 1 then games() end
if mine == 2 then exit() end

::games::

games = gg.choice({'Standoff 2💕','Back💕'},nil,'MultiScript by CloniuStudio💕')

if games == 1 then somenu() end
if games == 2 then menu() end

function somenu()
somenu = gg.choice({'SkinChanger [🖌]','Back💕'},nil,'Standoff2 Menu💕')

if somenu == 1 then sochangermenu() end
if somenu == 2 then games() end

::exit::
gg.toast('MultiScript by CloniuStudio💕')
os.exit() end

Thanks!

2 answers to this question

Recommended Posts

Posted

Lua starts from the top to bottom so somenu() is defined after its used. Also your indentation makes it super hard to read. I would not use goto and make everything functions. It also looks like you are redefining somethings like games, its a function and then used for the return index. Take a look at how I do menus jad3d-menu-framework

if gg.isVisible(true) then
	gg.setVisible(false)
end
goto menu

function somenu()
  somenu = gg.choice({'SkinChanger [🖌]','Back'},nil,'Standoff2 Menu')

  if somenu == 1 then sochangermenu() end
  if somenu == 2 then games() end
end

::menu::
menu = gg.choice({'Games','Exit'},nil,'MultiScript by CloniuStudio')
if mine == 1 then games() end
if mine == 2 then exit() end

::games::
games = gg.choice({'Standoff 2','Back'},nil,'MultiScript by CloniuStudio')
if games == 1 then somenu() end
if games == 2 then menu() end

 ::exit::
 gg.toast('MultiScript by CloniuStudio')
 os.exit() 

 

Posted

maybe like this?

local gg = gg

function main()
local menu = gg.choice({
       'Games',
       'Exit'},
nil,'MultiScript by CloniuStudio')

if menu == nil then return
elseif
menu == 1 then games()
elseif
menu == 2 then 
gg.toast('MultiScript by CloniuStudio')
os.exit()
end
end


function games()
local games = gg.choice({
       'Standoff 2',
       'Back'},
nil,'MultiScript by CloniuStudio')

if games == nil then return
elseif
games == 1 then somenu()
elseif
games == 2 then main()
end
end


function somenu()
local somenu = gg.choice({
        'SkinChanger [🖌]',
        'Back'},
nil,'Standoff2 Menu')

if somenu == nil then return
elseif
somenu == 1 then sochangermenu()
elseif
somenu == 2 then games()
end
end


function sochangermenu()
gg.alert('- Coming Soon -')
end


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

 

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.