Jump to content

string.find ; lack of documentation


Maccer.

Recommended Posts

Okay, I'm trying to use string.find, but I can't figure out how to use it because it lacks flipping documentation! So, the problem is that, onClientClick doesn't detect any gui elements as part of the world. Also since there is no element named gui, there's only elements named "gui-element." I'm trying to use string.find to check the element name and stop the click if it

if( isSpecialBindActivated == true and not string.find(getElementType(clickedWorld), "gui") ) then

If there are better ways to fix my problem or better documentation of string.find, I'd appreciate it, because all I'm getting is this from debugscript:

ERROR: Untitled 2.lua:17: bad argument #1 to 'find' (string expected, got boolean)

Thanks.

Link to comment

string.find is a function in luas string library, it isnt mta specific so it wont be covered on the mta wiki: http://lua-users.org/wiki/StringLibraryTutorial

onClientClick will never detect a gui element, it only triggers on real-world entities so the error in the code you posted is probably because clickedWorld == nil, therefore you are attempting to string.find on a variable that is not a string

if you want to detect clicks on a gui element you could either use onClientGUIClick, or use onClientClick but track the gui element you are on with onClientMouseEnter, onClientMouseLeave and a global variable

Link to comment
string.find is a function in luas string library, it isnt mta specific so it wont be covered on the mta wiki: http://lua-users.org/wiki/StringLibraryTutorial

onClientClick will never detect a gui element, it only triggers on real-world entities so the error in the code you posted is probably because clickedWorld == nil, therefore you are attempting to string.find on a variable that is not a string

if you want to detect clicks on a gui element you could either use onClientGUIClick, or use onClientClick but track the gui element you are on with onClientMouseEnter, onClientMouseLeave and a global variable

I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world.

Link to comment
I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world.

use my second suggestion then, that is how ive worked around this problem before. store whichever gui element you are hovering over in a global variable, then you can just use onClientClick and check your variable to see if you clicked on gui

Link to comment
I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world.

use my second suggestion then, that is how ive worked around this problem before. store whichever gui element you are hovering over in a global variable, then you can just use onClientClick and check your variable to see if you clicked on gui

It's all in the works! ;)

Too bad I had to use a work-around though. :(

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...