• Lua Error
    9 replies, posted
Hi. I've got a LUA Error local model = tostring(self.Entity.GetModel()) I need to know if they are using a male model if string.find(model, "male" or "Male", 1, false ) != nil then self in this manner means LocalPlayer() I'm trying to retrive the model name but it won't work
jesus you buy gold membership and you don't even know we have a LUA subforum? [editline]18th July 2011[/editline] [url]http://www.facepunch.com/forums/337-Questions[/url] ask there, not in fast threads
This is for your "Post Your" and "Question" threads.
This is not the place for that kind of problem.
[QUOTE=jamie1130;31187651]This is for your "Post Your" and "Question" threads.[/QUOTE] you'll find more people that can help you in the appropriate subforum.
Ah, Ok. Sorry. I actually can't delete this so if a mod could lock it or delete it that'd be helpful
Remember to wrap your code in [noparse][lua][/lua][/noparse] tags. A mod must've moved this to Lua questions, so try this: [lua]local model = tostring(self.Entity:GetModel())[/lua]
[QUOTE=wakeboarderCWB;31189750]Remember to wrap your code in [.lua] \*code*\[./lua] tags (without the .'s).[/QUOTE] Just a useful tip, you can use [noparse][noparse][/noparse][/noparse] tags instead of dots, it's a little less confusing for people :v:
[QUOTE=wakeboarderCWB;31189750]Remember to wrap your code in [noparse][lua][/lua][/noparse] tags. A mod must've moved this to Lua questions, so try this: [lua]local model = tostring(self.Entity:GetModel())[/lua][/QUOTE] or just [lua]local model = self.Entity:GetModel()[/lua]
[lua] local model = tostring(self.Entity.GetModel()) [/lua] This is wrong, you call functions on an object using : ("self.Entity:GetModel()") This rule can be confusing, because sometimes when calling a function you use a dot, and sometimes a colon. As a general rule, if you're doing something to the part before the function, you use a colon, otherwise a dot. For example, "self.Entity:GetModel()" is correct, because you're doing something to self.Entity (you're getting its model). On the other hand "string.lower('hi')" is also correct, because you're not doing anything to the string library (you're doing something to a string, but not the string library itself) Also, GetModel returns a string, so there's no need for the tostring (though it doesn't hurt anything) [lua] if string.find(model, "male" or "Male", 1, false ) != nil then [/lua] This is also wrong, because "or" is used to combine two boolean (true or false) values, as in "if a == 2 or c == 3". You could either search for each one separately, or you could convert the model to lowercase with string.lower(model) and then search for the lowercase "male".
Sorry, you need to Log In to post a reply to this thread.