Jump to content
kittyDAR1

What is wrong with this script?

Recommended Posts


menu = gg.choice({'Infinite money','Exit'})

if menu == 1 then

  menu1 = gg.choice({'Start','Finish'})
  
   if menu1 == 1 then
  
    prompt = gg.prompt({'How much money do you have?'})
    
    gg.searchNumber(prompt,gg.TYPE_DOUBLE)
    
    gg.alert('Get some money. Then press finish.')  
    end
   if menu1 == 2 then
     prompt1 = gg.prompt('Enter the final money count.')
     gg.refineNumber(prompt1,gg.TYPE_DOUBLE)
     gg.getResults('100')
     gg.editAll('999999999999',gg.TYPE_DOUBLE)
     end
 end
 gg.alert('Sub to C_ffeeStain. He made this script.')

It says there is an error on line 13.

Share this post


Link to post
Share on other sites

The answer is present in the description of returned value of prompt function from the documentation.

In your case the call to the function (if dialog was not cancelled) returns a table with one element that has the key 1. Here is an example of how such table may look like: 

t = {[1] = 'Value from the field'}

To access value that is associated with key, you need to index the table with that key. For the example above it would be: 

t[1]

So in your code, you need to change usages of returned value by "prompt" function to access value of table element, not the table itself. For example: 

gg.searchNumber(prompt[1], gg.TYPE_DOUBLE)

Share this post


Link to post
Share on other sites
menu = gg.choice({'Infinite money','Exit'})

if menu == 1 then

  menu1 = gg.choice({'Start','Finish'})
  
   if menu1 == 1 then
      prompt = gg.prompt({'How much money do you have?'})
      gg.searchNumber(prompt[1],gg.TYPE_DOUBLE)   
      gg.alert('Get some money. Then press finish.')
      end
   if menu1 == 2 then
     prompt1 = gg.prompt({'Enter the final money count.'})
     gg.refineNumber(prompt1[1],gg.TYPE_DOUBLE)
     gg.getResults(100)
     gg.editAll('999999999',gg.TYPE_DOUBLE)
     end
     end
 gg.alert('Sub to C_ffeeStain. He made this script.')

like this....??

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...