Jump to content
  • 0

What is wrong with this script?


kittyDAR1

Question


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.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

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)
Link to comment
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....??

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.