Grizzly Adam
Member
Posts: 252 Joined: Sat Aug 05, 2017 01:28
GitHub:
Grizzly-Adam
Location: Lost in America
Contact:
by Grizzly Adam » Wed Feb 21, 2018 23:44
Post
How do I make lua recognize that I am using two words here? It is just giving me the regular HELP command at this point, instead of the help for CLS.
Code: Select all
elseif exec_command == "help cls" then
add_outline(data.outlines, ' CLS Clears the screen.')
Last edited by
Grizzly Adam on Thu Feb 22, 2018 04:54, edited 1 time in total.
Tmanyo
Member
Posts: 196 Joined: Mon Sep 29, 2014 01:20
GitHub:
Tmanyo
IRC: Tmanyo
In-game: tmanyo
Location: United States
Contact:
by Tmanyo » Thu Feb 22, 2018 03:10
Post
You could do,
Code: Select all
elseif exec_command:match("^help cls$") then
add_outline(data.outlines, ' CLS Clears the screen.')
I don't know if that will make any difference or not, but you can try.
Grizzly Adam
Member
Posts: 252 Joined: Sat Aug 05, 2017 01:28
GitHub:
Grizzly-Adam
Location: Lost in America
Contact:
by Grizzly Adam » Thu Feb 22, 2018 03:14
Post
Nope, same result. It just overlooks it.
Messing around with match, it works fine until the space.
ExeterDad
Member
Posts: 1717 Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A
by ExeterDad » Thu Feb 22, 2018 03:34
Post
What about:
Code: Select all
elseif exec_command:match("^help%s*cls$") then
add_outline(data.outlines, ' CLS Clears the screen.')
Grizzly Adam
Member
Posts: 252 Joined: Sat Aug 05, 2017 01:28
GitHub:
Grizzly-Adam
Location: Lost in America
Contact:
by Grizzly Adam » Thu Feb 22, 2018 03:38
Post
ExeterDad wrote: What about:
Code: Select all
elseif exec_command:match("^help%s*cls$") then
add_outline(data.outlines, ' CLS Clears the screen.')
Still the same thing :/ Once we get this working I will be definiately using match to tell me if its a help command, should simplify the code a bit.
Grizzly Adam
Member
Posts: 252 Joined: Sat Aug 05, 2017 01:28
GitHub:
Grizzly-Adam
Location: Lost in America
Contact:
by Grizzly Adam » Thu Feb 22, 2018 04:38
Post
bell07 came up with this one. Works like a charm.
Code: Select all
elseif exec_command == "help" then
local help_command = exec_all[2]
if help_command == "cls" then
add_outline(data.outlines, help_command.." - bla bla")
bell07
Member
Posts: 604 Joined: Sun Sep 04, 2016 15:15
GitHub:
bell07
by bell07 » Wed Feb 28, 2018 09:16
Post
For reference, the "full" solution was
Code: Select all
local exec_all = data.inputfield:split(" ")
local exec_command = exec_all[1]
if exec_command == nil then --empty line
elseif exec_command == "help" then
local help_command = exec_all[2]
if help_command == "cls" then
add_outline(data.outlines, help_command.." - bla bla")
Users browsing this forum: No registered users and 1 guest