Jump to content




Updater Help


  • You cannot reply to this topic
6 replies to this topic

#1 Zenon

  • Members
  • 50 posts

Posted 21 July 2015 - 06:33 PM

Hi all! Making an updater (as you might have seen in my last post) and am just wondering why this isnt working. Code:
Spoiler

But it works if I do this:
Spoiler

Here is the pastebin its running

Any help is appreciated, because I cant really think of any reason why it wont work :P
Thanks in advance!

Edited by theMCcm, 21 July 2015 - 06:33 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 21 July 2015 - 07:48 PM

Is there an error, or does it do something you don't want it to? Please be specific in describing what you want to happen and what does happen.

#3 Zenon

  • Members
  • 50 posts

Posted 21 July 2015 - 08:13 PM

View PostKingofGamesYami, on 21 July 2015 - 07:48 PM, said:

Is there an error, or does it do something you don't want it to? Please be specific in describing what you want to happen and what does happen.
No error, just doesnt work . . . Though where it prints it says nil, which leaves me to believe its trying to print the table program[1] instead of the input table, although if I use the second code it will use the input table (Im describing that horribly, though hopefully you understand it)

Edit: As for what I want to happen:
I want to use this program by using shell.run, with a singular arguement:
shell.run("themccm/updater", <insert program>)
I want to do this so I can run the program within a program, or seperately, and update the program without having to make a seperate updater for each program.

Edited by theMCcm, 21 July 2015 - 08:32 PM.


#4 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 21 July 2015 - 08:43 PM

If you're running the program with shell.run or through an actual shell all the passed arguments will be strings. Now here:

local name = {...}
program = name[1]

the 'program' variable holds the first argument passed to the program. So if I run the program like so:

# through the code:
shell.run("updater", "my_super_program")

#or through the shell:
> updater my_super_program

the 'program' variable ends up with a string value "my_super_program". After that you try to index that string with the number key '1':

print(tostring(program[1]))

and then with the number key '2':

shell.run("pastebin", "get", program[2], "updatetest")

I don't know what you are expecting to find after indexing a string with those keys, but you can be sure that they will be nil.

#5 Zenon

  • Members
  • 50 posts

Posted 21 July 2015 - 09:30 PM

View PostMKlegoman357, on 21 July 2015 - 08:43 PM, said:

If you're running the program with shell.run or through an actual shell all the passed arguments will be strings. Now here:

local name = {...}
program = name[1]

the 'program' variable holds the first argument passed to the program. So if I run the program like so:

# through the code:
shell.run("updater", "my_super_program")

#or through the shell:
> updater my_super_program

the 'program' variable ends up with a string value "my_super_program". After that you try to index that string with the number key '1':

print(tostring(program[1]))

and then with the number key '2':

shell.run("pastebin", "get", program[2], "updatetest")

I don't know what you are expecting to find after indexing a string with those keys, but you can be sure that they will be nil.
Ohhh I didnt realize it was making it a string . . . Do you know a way to "unstring" a string? Or would I be better off doing what Im doing in a different way?

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 22 July 2015 - 12:42 AM

Er, instead of doing that, would you not just want to do something like this?:

print(program)

shell.run("pastebin", "get", name[2], "updatetest")


#7 Zenon

  • Members
  • 50 posts

Posted 22 July 2015 - 01:07 AM

View PostBomb Bloke, on 22 July 2015 - 12:42 AM, said:

Er, instead of doing that, would you not just want to do something like this?:

print(program)

shell.run("pastebin", "get", name[2], "updatetest")
WOW I feel like an idiot. Thanks Bomb Bloke, youre always helpful :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users