[SOLVED]More than One Word Input

Post Reply
User avatar
Grizzly Adam
Member
Posts: 252
Joined: Sat Aug 05, 2017 01:28
GitHub: Grizzly-Adam
Location: Lost in America
Contact:

[SOLVED]More than One Word Input

by Grizzly Adam » 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.
Check out my Mods: BBQ Mod Crops Plus

User avatar
Tmanyo
Member
Posts: 196
Joined: Mon Sep 29, 2014 01:20
GitHub: Tmanyo
IRC: Tmanyo
In-game: tmanyo
Location: United States
Contact:

Re: More than One Word Input

by Tmanyo » 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.
Tmanyo
http://www.rrhmsservers.ml
Servers I Host:
Tmanyo-Realism
Mods of mine that I don't totally hate:
Bank Accounts
T-Rating
Tmusic Player

User avatar
Grizzly Adam
Member
Posts: 252
Joined: Sat Aug 05, 2017 01:28
GitHub: Grizzly-Adam
Location: Lost in America
Contact:

Re: More than One Word Input

by Grizzly Adam » Post

Nope, same result. It just overlooks it.

Messing around with match, it works fine until the space.
Check out my Mods: BBQ Mod Crops Plus

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: More than One Word Input

by ExeterDad » Post

What about:

Code: Select all

elseif exec_command:match("^help%s*cls$") then
        add_outline(data.outlines, ' CLS     Clears the screen.')

User avatar
Grizzly Adam
Member
Posts: 252
Joined: Sat Aug 05, 2017 01:28
GitHub: Grizzly-Adam
Location: Lost in America
Contact:

Re: More than One Word Input

by Grizzly Adam » 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.
Check out my Mods: BBQ Mod Crops Plus

User avatar
Grizzly Adam
Member
Posts: 252
Joined: Sat Aug 05, 2017 01:28
GitHub: Grizzly-Adam
Location: Lost in America
Contact:

Re: More than One Word Input

by Grizzly Adam » 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")
Check out my Mods: BBQ Mod Crops Plus

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: [SOLVED]More than One Word Input

by bell07 » 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")

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest