Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Add support for arguments in command triggers #21

Closed
soliddanii opened this issue Sep 2, 2017 · 6 comments
Closed

[Suggestion] Add support for arguments in command triggers #21

soliddanii opened this issue Sep 2, 2017 · 6 comments

Comments

@soliddanii
Copy link
Contributor

I believe that right now you can't create a command trigger that takes arguments. Can you please add this feature? 馃槃

@soliddanii soliddanii changed the title [Sugestion] Add support for arguments in command triggers [Suggestion] Add support for arguments in command triggers Sep 2, 2017
@wysohn
Copy link
Member

wysohn commented Sep 3, 2017

You can take arguments in fact :)

CommandTrigger has its own variables that hold the arguments

Variables Link
command String -- it's the actual command string
args Array(of String) -- the arguments that the player have entered. args[0] for first argument, args[1] for second, ...
argslength Number -- number of argumenets. Equivalent to args.length

@wysohn wysohn closed this as completed Sep 3, 2017
@soliddanii
Copy link
Contributor Author

Thank you very much 馃槃
For some reason I couldn't find it in the wiki.

@wysohn
Copy link
Member

wysohn commented Sep 3, 2017

Yeah current wiki has a little low readability c.f.

I would appreciate if you fix it a little if you want to :p

@DontActLikeMe
Copy link

can you provide an example of how i could take arguments? i see that you have args but idk how to type the command

@wysohn
Copy link
Member

wysohn commented Oct 13, 2017

The args is the Array of String, so to access the values in it, you need the square bracket.

For example, if you would need the first argument of the command, simply use args[0]

#MESSAGE args[0]

This will print out 'boom' if you have a command trigger 'test,' and typed something like /test boom.

But be aware of that the number you put there can be out of bound depends on how many arguments are originally passed to the Trigger.

You can check that by using argslength variable or args.length.

IF args.length > 1
    ....
ENDIF

This will make sure that there is at least one argument before executing the code in the IF block

You may find this wiki useful too: https://github.com/wysohn/TriggerReactor/wiki/Array

@DontActLikeMe
Copy link

i actually figured it out lol while waiting for you XD but thank you so much. this will definitely help others along the way! i actually designed a command that lets you make other players say whatever you want XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants