runOnChat(1) and lastSaid()
Look under Chat in the wiki.
how do you make so the expression 2 gate picks upp chat commands like
!open 1 to ex open a door or
!dial ABCDEFG to dial with a gate from chat![]()
runOnChat(1) and lastSaid()
Look under Chat in the wiki.
If I understood correctly, you are looking for it to recognize a command then take a sub-string of that as input. The way to do this is:
[highlight=e2]
@outputs Door
@persist LastSaid:string Open
runOnChat(1)
LastSaid=owner():lastSaid()
if(LastSaid:left(5)=="!open") {Open=LastSaid:sub(7,Text:length()):toNumber()}
if(Open) {Door=1} else {Door=0}
[/highlight]
This is saying first of all that LastSaid is the last thing that the chip's owner said. Then it says with the
[highlight=e2]
if(LastSaid:left(5)=="!open")
[/highlight]
that if the first 5 characters from the left of LastSaid are !open, then do the next action which is
[highlight=e2]
{Open=LastSaid:sub(7,Text:length()):toNumber()}
[/highlight]
This says that Open equals the sub-string from character 7 to the end of the text. If you were to type !open 1 then Open would equal 1, if you were to type !open 574263 then open would equal 574263. Hope this helped.
Why has everyone coppied my chat dialing stargate?
SVN Tutorial
My SVN:Get dropbox and get 250 MB extra space: DropboxCode:http://divranspack.googlecode.com/svn/trunk/%20divranspack/
i saw one on garrysmod.org http://www.garrysmod.org/downloads/?a=view&id=68419
thanks i will try
SVN Tutorial
My SVN:Get dropbox and get 250 MB extra space: DropboxCode:http://divranspack.googlecode.com/svn/trunk/%20divranspack/
i cant make the E2 work when im writing
!door 1 the output wont change
Please explain further. Do you mean to say that when you place the chip and you say your command the output value will not change? Maybe you forgot to put the strings in quotes, or maybe you forgot to make your output equal your persist. Make sure runOnChat(1) is in there.
Bookmarks