Jump to content
  • 0

Scripting issue


Mofo50

Question

Umm so guys I ran into an issue while creating a script. Here's an example of the script

function doSomething()

   does something

end

function main()
local option = gg.prompt('High damage')
if option == 1 then
doSomething()
goto START
end
end

gg.setVisible(false)

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

 

Basically what i want it to do is check for icon being pressed...when the icon is pressed it runs the main menu, and then when someone chooses a main menu option high damage for example it does something but I don't want the script to end I want it to go back to waiting for the icon to be pressed. I need this because after the high damage thing it needs to wait for the user to do something in game and then go back to the script.

I know this is possible as I've seen it happen in many different scripts before but I don't know how to do it. And I'd appreciate the help. If this isn't possible is there at least a way for the script to restart itself? Thanks in advance guys.

 

I tried it like the method I showed above but it gave me an error saying there is no start label visible in the main() function which makes sense since I'm calling START before it's defined but I don't know how to solve this problem

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

13 minutes ago, Enyby said:

Remove label and goto. All must work as you expected.

ye i figured it out...the error i was getting wasnt because it wasnt finding main it was because out of habit i put colons after main(). Its because i mostly code in Python and in python to define a function you have to do "def function():" but in lua you dont need :

Link to comment
Share on other sites

28 minutes ago, Enyby said:

Remove label and goto. All must work as you expected.

I have another question tho Enyby...is there a way to add an option in the choice menu to close the menu and wait until the icon is pressed again?

Link to comment
Share on other sites

5 minutes ago, Enyby said:

Yes. Detect returned nil value and return from your function. nil returned if dialog canceled.

OOH yes you just press the cancel button im so dumb thanks so much man

Link to comment
Share on other sites

43 minutes ago, Enyby said:

Yes. Detect returned nil value and return from your function. nil returned if dialog canceled.

One more question Enyby. Ok so say i do getResult() and store the results in a table. How can i then load this table again and edit its values?

Link to comment
Share on other sites

4 hours ago, Mofo50 said:

One more question Enyby. Ok so say i do getResult() and store the results in a table. How can i then load this table again and edit its values?

Use gg.setValues

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.