Pivity

Function to get code/variables from a website?

#21

So now one probably nooby question: How can I store the argument from a command to a string Like: WhatsInside Basket1 will change the variable "Basket" to "Basket1" and the same with "WhatsInside Basket2" (variable will be changed to Basket2)?

#22

file.Read and file.Write most likely.

Dumb x 1
#23
ByMomoxat 15th of September 2016 16:39:56
So now one probably nooby question:How can I store the argument from a command to a stringLike:WhatsInside Basket1will change the variable "Basket" to "Basket1"and the same with "WhatsInside Basket2" (variable will be changed to Basket2)?

Baskets = {}

Baskets[1] = {} Baskets[2] = {} Baskets[3] = {}

concommand.Add("SetBasket1",function(ply,cmd,args)

Baskets[1] = "Blabla" -- Or Baskets[1] = { Apple, Orange }

end)

#24

Don't think so. Ok, once again: My Command: SelectNumber My Variable called "Number" I enter "SelectNumber 1" and the variable "Number" will be changed to 1 (so Number==1). If I enter "SelectNumber " the variable "Number" will be changed to 2 (so Number==2) how can I "catch" the argument (in this case the numbers) from my command each time I'm using it?

#25
ByMomoxat 15th of September 2016 16:53:53
Don't think so. Ok, once again:My Command: SelectNumberMy Variable called "Number"I enter "SelectNumber 1" and the variable "Number" will be changed to 1 (so Number==1). If I enter "SelectNumber " the variable "Number" will be changed to 2 (so Number==2)how can I "catch" the argument (in this case the numbers) from my command each time I'm using it?

Use the args ( aka arguments )

#26

Yeah, exactly that's my problem. I already mentioned that I am a lua beginner and I don't know how to use the args.

#27
ByMomoxat 15th of September 2016 17:14:49
Yeah, exactly that's my problem. I already mentioned that I am a lua beginner and I don't know how to use the args.

Concommand.Add

The args var is a table. When you look at an entered command it looks like this "myspecialcommand arg1 arg2", the args table is simply args = { arg1, arg2 }. To call these you use args[1] or whatever the key is. If your table has 5 key which also means 5 values you can go up to args[5] and when it contains 6 keys, args[6] and so on.

In your case you can simply use args[1] to get the first argument from the command. So if the command is something like "SelectNumber 1" then args[1] will be "1"

( Sorry for the messy tutorial )

Friendly x 1
#28

Helped a lot, now the core of my addon is finished, now I just need to do some adjustments, improving the visual and some smaller bug fixes :) I'll soon open a new thread once my idea is finished

Users viewing this thread
Nobody