NivorbiaN Posted July 7, 2010 Share Posted July 7, 2010 As there is no LUA section on the wiki, and LUA being such a big part of LE, is there some tutorial on, how LUA model files should be. i am looking at the LUA files that come along with the models supplied with LE, but there is no explanation. the only explanation i could find was in the "Leadwerks 2.3 - User Guide - 1.01" it said : require("scripts/class") local class=CreateClass(...) *For an exact explanation of what this script does, please ask on the forum with other words, what is the correct syntax of LUA for model files. i looked at some tutorials on LUA but non explain the usage with LE, they just explain the LUA language, i just want to make LUA files for models, not script or program in LUA in any way. Quote "Hmm, don't have time to play with myself." ~Duke Nuke'm Link to comment Share on other sites More sharing options...
Canardia Posted July 7, 2010 Share Posted July 7, 2010 Those 2 lines: require("scripts/class") local class=CreateClass(...) are needed for every model, because without those many things don't even work. For example entitykeys in a model's ini file are not read in. You don't usually need anything else in the Lua file than those 2 lines. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 7, 2010 Share Posted July 7, 2010 I am still on my way to produce game scripts tutorials with Lua. A couple more to go and then I want to cover some basics for class scripting. edit: Here is the wiki. You can find it under 'Scripting'. http://leadwerks.com/wiki/index.php?title=Script Quote Link to comment Share on other sites More sharing options...
NivorbiaN Posted July 7, 2010 Author Share Posted July 7, 2010 thanks you two, now i know what the basics are. so i made an object to store the fog settings and a LUA file like this: ///////////////////////////////////////////////////////////////////////// require("scripts/class") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup( "FogSetting" ) group:AddProperty( "FogOnOff", PROPERTY_BOOL) group:AddProperty( "FOG_R", PROPERTY_FLOAT,'|0.0,1.0,1' ) group:AddProperty( "FOG_G", PROPERTY_FLOAT,'|0.0,1.0,1' ) group:AddProperty( "FOG_B", PROPERTY_FLOAT,'|0.0,1.0,1' ) group:AddProperty( "FOG_A", PROPERTY_FLOAT,'|0.0,1.0,1' ) group:AddProperty( "FogAngleB", PROPERTY_FLOAT,'|0.0,90,1' ) group:AddProperty( "FogAngleE", PROPERTY_FLOAT,'|0.0,90,1' ) group:AddProperty( "FogRangeB", PROPERTY_FLOAT,'|0.0,5000,1' ) group:AddProperty( "FogRangeE", PROPERTY_FLOAT,'|0.0,5000,1' ) group:Expand(1) end function class:CreateObject(model) local object=self.super:CreateObject(model) object.model:SetKey("FogOnOff","1") object.model:SetKey("FOG_R","1") object.model:SetKey("FOG_G","1") object.model:SetKey("FOG_B","1") object.model:SetKey("FOG_A","1") object.model:SetKey("FogAngleB","0") object.model:SetKey("FogAngleE","45") object.model:SetKey("FogRangeB","0") object.model:SetKey("FogRangeE","10") end ////////////////////////////////////////////////////////////// can I just use: group=grid:AddGroup( "FogSetting" ) or are there predefined groupnames? are there reserved group names? it does seem to work though, but i am afraight to use names that are not to be used. thanks for the help! Quote "Hmm, don't have time to play with myself." ~Duke Nuke'm Link to comment Share on other sites More sharing options...
ZioRed Posted July 8, 2010 Share Posted July 8, 2010 If you open class.lua in your Scripts folder you can see the default groups. I don't know LUA very well but may be you have a grid:GetGroup besides to grid:AddGroup. But in my opinion for your own model it should be more handy to have your own property groups for rapidly access them from editor's UI. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 8, 2010 Share Posted July 8, 2010 I never used one of the default class groupnames before, so I don't know for sure. But since you create a new class it takes those groupnames and properties from class.lua. Thats why I think that it can not harm if you use the same groupnames. I still would recommend using your own groupname, to prevent confusion. Quote Link to comment Share on other sites More sharing options...
NivorbiaN Posted July 8, 2010 Author Share Posted July 8, 2010 ok, Thanks! class.lua hold indeed a lot of info. gonna spend the rest of the week on LUA tutorials. Quote "Hmm, don't have time to play with myself." ~Duke Nuke'm 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.