thehankinator Posted April 22, 2015 Share Posted April 22, 2015 I'm looking at Object:GetClass() ( http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/object/objectgetclass-r19 ) I'd like to use this function to determine if an entity is a light. Is there a constant some place that these numbers are defined? I know I could find out what the magic number is for say a SpotLight but I have no way of knowing that the value for SpotLight would not change in a later release. Quote Link to comment Share on other sites More sharing options...
thehankinator Posted April 22, 2015 Author Share Posted April 22, 2015 Of course I figured it out soon after I posted this. It's missing from the documentation but apparently you can do something like: if entity:GetClass() == Object.SpotLightClass then blah blah end The lua example is somewhat misleading in that it uses a magic number of 2 to check for a model class. It'd be better if it used Object.ModelClass instead. Also maybe list these as members of Object so we know what class ids we could check for. Or maybe it's there and I am looking in the wrong spot? Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 3, 2015 Share Posted May 3, 2015 The lua example is somewhat misleading in that it uses a magic number of 2 to check for a model class. It'd be better if it used Object.ModelClass instead. Also maybe list these as members of Object so we know what class ids we could check for. Or maybe it's there and I am looking in the wrong spot? It is hidden in the forums here: http://www.leadwerks.com/werkspace/topic/10139-leadwerks-map-class/#entry75115 Hopefully this will be one of the things that Josh and Aggror add to the revamped documentation/tutorials. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
thehankinator Posted May 3, 2015 Author Share Posted May 3, 2015 Thanks! This is exactly what I was looking for. If the reference page wont be updated, someone should put this info in the comments section (It doesn't look like I have permission) or at least a link to that thread. Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 3, 2015 Share Posted May 3, 2015 Added. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/object/objectgetclass-r19 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
thehankinator Posted May 3, 2015 Author Share Posted May 3, 2015 Perfect! Quote Link to comment Share on other sites More sharing options...
Josh Posted May 4, 2015 Share Posted May 4, 2015 You don't need to know what the value is, just use the declared constant. The values may change without warning. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted May 4, 2015 Share Posted May 4, 2015 I know I could find out what the magic number is for say a SpotLight but I have no way of knowing that the value for SpotLight would not change in a later release. That's what the OP was saying. These constants don't seem to be available in the docs. Mack added to the comment section so we can see the constant name (and we make the assumption it's the same name in Lua). Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 4, 2015 Share Posted May 4, 2015 You don't need to know what the value is, just use the declared constant. The values may change without warning. And thats fine but like what everyone is pointing out, we don't know the name of the constants. And the one's that are mentioned, there might be confusion on what the lua declared constant is or in some cases the declared constants do not work as advertised. The lua code example for Camera Get/Set ProjectionMode is one such example. I have to use the values 1 or 2 because the supposed declared constants 'Camera.Perspective' and 'Camera.Orthographic' will cause an error because they are nil. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted May 4, 2015 Share Posted May 4, 2015 Why would you need to know the name? It is just the name of the class. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted May 4, 2015 Share Posted May 4, 2015 Why would you need to know the name? It is just the name of the class. huh? you dont see how we would we need to know the name of the constants you are using? Without that, it makes using some of the Get/Set commands kind of difficult to use. The second post here shows exactly why we would need that information. thehankinator figured it out by trial and error but why should everyone have to guess what the constants would be named? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted May 4, 2015 Share Posted May 4, 2015 Why would you need to know the name? It is just the name of the class. You may know that but a new person coming into LE and only has Lua version isn't going to know that. Quote Link to comment Share on other sites More sharing options...
thehankinator Posted May 5, 2015 Author Share Posted May 5, 2015 This type of documentation problem isn't limited to the subject I presented in this thread. Take Context::DrawRect for example. It has an optional argument for style which is a 0 by default. What does 0 mean? I suspect there is a constant some place but without access to the C++ source I have no way of determining what style means or could be(without brute force checking every possible value). Same with the class id, these constants need to be in the API documentation for those who do not have (or want) access to C++ headers. Some things do have the constants defined like collisiontype argument for Entity::Pick but there is not a link or blurb of text that points the reader to the Collision class documentation. MSDN is a great example of how the API could be documented, each argument of a function that takes a constant has every acceptable constant listed and described. While it'd be nice to have that kind of detail I think it would be acceptable to simply have a link to the page that has all the constants defined(not the value but what the constant means) that apply to that particular function or argument. As someone who is a programmer by trade this has tripped me up more than once guessing how to test the result of a return value or possible values of an argument. Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted July 18, 2017 Share Posted July 18, 2017 On 04/05/2015 at 8:47 PM, Rick said: You may know that but a new person coming into LE and only has Lua version isn't going to know that. Good point. Anyone know the name of the classes? I don't have visual studio instaled yet Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
gamecreator Posted July 18, 2017 Share Posted July 18, 2017 They are in the thread macklebee linked in his first post. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.