awgsknite Posted December 8, 2015 Share Posted December 8, 2015 Does anyone know of a js to lua converter ? I seen some sln projects on github that are too complex for me to use even though they have some instructions. I'm not an expert with lua yet so I'm trying to convert some js to lua scripts by myself with no success. Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
aiaf Posted December 8, 2015 Share Posted December 8, 2015 I suggest you start with the lua tutorials from this site and after the Lua reference manual. Here you go http://www.lua.org/docs.html Take a few days for this or how long you need to be confident with your lua knowledge. After doing this you should be able to convert this js by yourself if you still need it. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
awgsknite Posted December 8, 2015 Author Share Posted December 8, 2015 Thanks aiaf ! I learnt some new things from there ! One of them: global variables are ordinary variables ! After taking those tutorials it says that I'm a Lua expert ! On the tutorials page found here: http://www.leadwerks.com/werkspace/page/tutorials/ but I still can't place decals in my game yet lol so I don't feel like an expert just yet Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
awgsknite Posted December 10, 2015 Author Share Posted December 10, 2015 stuck on this part: anyone know how to convert this to lua ? : switch( footprintType ) case 1 : uvOffset = Vec2( 0.5, 1.0 ) break case 2 : Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
thehankinator Posted December 10, 2015 Share Posted December 10, 2015 stuck on this part: anyone know how to convert this to lua ? : switch( footprintType ) case 1 : uvOffset = Vec2( 0.5, 1.0 ) break case 2 : Lua doesn't have a switch statement but you could do it with an if statement. if footprintType == 1 then uvOffset = Vec2(0.5, 1.0) elseif footprintType == 2 then --blah blah end 1 Quote Link to comment Share on other sites More sharing options...
awgsknite Posted December 10, 2015 Author Share Posted December 10, 2015 ah thats why..Thanks ! Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
awgsknite Posted December 11, 2015 Author Share Posted December 11, 2015 var corners : Vector3[] = new Vector3[ 4 ]; to Lua How ? Vector3 is Vec3 in Lua but what about the square brackets and colon ? Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
shadmar Posted December 11, 2015 Share Posted December 11, 2015 var corners : Vector3[] = new Vector3[ 4 ]; to Lua How ? Vector3 is Vec3 in Lua but what about the square brackets and colon ? I believe corners is declared as a array of 4 vec3 values. I think you only need to do this in lua: corners = { } 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
thehankinator Posted December 11, 2015 Share Posted December 11, 2015 I believe corners is declared as a array of 4 vec3 values. I think you only need to do this in lua: corners = { } That would make an array but to make equivalent code, wouldn't you need to fill it with the 4 Vec3 elements? Like: corners = {Vec3(), Vec3(), Vec3(), Vec3()} 1 Quote Link to comment Share on other sites More sharing options...
shadmar Posted December 11, 2015 Share Posted December 11, 2015 yes, but you don't really need to declare anything in a table like that. just table.insert when needed I guess. (I don't know whats next in line in the js script :-) ) Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
awgsknite Posted December 11, 2015 Author Share Posted December 11, 2015 Thanks ! but idk what to use but this is the first part of it: public function AddFootprint( pos : Vector3, fwd : Vector3, rht : Vector3, footprintType : int ) { // - Calculate the 4 corners - // foot offset var footOffset : float = footprintSpacing; if ( isLeft ) { footOffset = -footprintSpacing; } var corners : Vector3[] = new Vector3[ 4 ]; // corners = position + left/right offset + forward + right corners[ 0 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Upper Left corners[ 1 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Upper Right corners[ 2 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Lower Left corners[ 3 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Lower Right That function idk how to write that for lua. It has me so stumped and i cant find any lua script that looks like that to see how to make it Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
thehankinator Posted December 11, 2015 Share Posted December 11, 2015 Thanks ! but idk what to use but this is the first part of it: public function AddFootprint( pos : Vector3, fwd : Vector3, rht : Vector3, footprintType : int ) { // - Calculate the 4 corners - // foot offset var footOffset : float = footprintSpacing; if ( isLeft ) { footOffset = -footprintSpacing; } var corners : Vector3[] = new Vector3[ 4 ]; // corners = position + left/right offset + forward + right corners[ 0 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Upper Left corners[ 1 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Upper Right corners[ 2 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Lower Left corners[ 3 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Lower Right That function idk how to write that for lua. It has me so stumped and i cant find any lua script that looks like that to see how to make it I think shadmar's line of code would fit better for this function than mine. What part exactly has you stumped? Quote Link to comment Share on other sites More sharing options...
awgsknite Posted December 11, 2015 Author Share Posted December 11, 2015 Like i said b4 the function part. This line: public function AddFootprint( pos : Vector3, fwd : Vector3, rht : Vector3, footprintType : int ) Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
thehankinator Posted December 12, 2015 Share Posted December 12, 2015 Like i said b4 the function part. This line: public function AddFootprint( pos : Vector3, fwd : Vector3, rht : Vector3, footprintType : int ) You may want to look up some basic lua examples. This site seems decent http://www.tutorialspoint.com/lua/lua_functions.htm Regardless, this is how you make a similar function in lua: function AddFootprint( pos, fwd, rht, footprintType) --blah blah end Quote Link to comment Share on other sites More sharing options...
awgsknite Posted December 12, 2015 Author Share Posted December 12, 2015 Thanks ! but i tried that and the other line that changes to corners = { } or the other way corners = {Vec3(), Vec3(), Vec3(), Vec3()} and then it gives an error at the start of this near = : --// corners = position + left/right offset + forward + right corners[ 0 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Upper Left corners[ 1 ] = pos + ( rht * footOffset ) + ( fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Upper Right corners[ 2 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( -rht * footprintSize.x * 0.5 ); // Lower Left corners[ 3 ] = pos + ( rht * footOffset ) + ( -fwd * footprintSize.y * 0.5 ) + ( rht * footprintSize.x * 0.5 ); // Lower Right Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
Rick Posted December 12, 2015 Share Posted December 12, 2015 Show us the full code in question and if it's a function give us some test parameters to pass to it. Quote Link to comment Share on other sites More sharing options...
awgsknite Posted December 12, 2015 Author Share Posted December 12, 2015 I scrapped that script cos i couldnt convert it and i started over but now i got this : How do i get normal footprints and not cubes ? I used a decal material. Should i be using a texture instead ? Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
awgsknite Posted December 13, 2015 Author Share Posted December 13, 2015 nvm it was the material. I had copied another material instead of making a new material. Quote http://steamcommunity.com/profiles/76561197977392956/7977392956/ Link to comment Share on other sites More sharing options...
Rick Posted December 13, 2015 Share Posted December 13, 2015 This would be handy for others. You should share the code for others! 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.