-
Posts
339 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Paul Thomas
-
-
The above was edited again because if the object was selected to not randomize it wouldn't save the rotation once you've saved the scene. Multiple attempt to fix this lead to "C stack overflow" errors including when attempting to use; object.model:Fix(). Not exactly sure what the deal with that is.
-
Edited Again: Thanks to macklebee for adding to this.
Edit: Code revised
Here is a script to do just that, with a property grid. Thanks to macklebee for the help with my confusion. My second day of learning Lua after-all, lol.
require("scripts/class") local class = CreateClass(...) function class:InitDialog(grid) --self.super:InitDialog(grid) group=grid:AddGroup("Positioning") group:AddProperty("Rotation", PROPERTY_VEC3) group:AddProperty("randomize", PROPERTY_BOOL, "0", "Random Rotation") group:Expand(1) end function class:CreateObject(model) local object = self.super:CreateObject(model) object.randomize = "1" object.model:SetKey("randomize", "1") function object:Reset() if object.randomize == "1" then object:randomRotate() end end function object:SetKey(key, value) if key == "randomize" then object.randomize = value if value == "1" then object:randomRotate() end else return self.super:SetKey(key, value) end return 1 end function object:GetKey(key, value) if key == "randomize" then return object.randomize else return self.super:GetKey(key, value) end return 1 end function object:randomRotate() object.model:SetRotation(Vec3(0, math.random(0, 359), 0), 1) end function object:Free(model) self.super:Free() end end
I have this with all my tree models. However, you may have to set default values for collision, mass, and so forth.
-
Was posting this in a locked topic right when it was locked.
Not sure if it'll help anyone but you can randomly set the rotation of the tree's when the object is created, with Lua. The only flaw is that the rotation will always rotate whenever it's loaded. Probably not always wanted but you could easily make a property grid for a "Random Rotation: True/False" if you wanted.
function class:CreateObject(model) local object = self.super:CreateObject(model) object.model:SetRotation(Vec3(0, math.random(0, 359), 0), 1) end
I just found it annoying to change the rotation each time I placed down a tree or any other vegetation. Not as easy as painting the tree's but figured I'd share anyways.
-
Just taking a shot, I think it would be like;
function Lights() local light = {} light.spot = CreateSpotLight(100) function light:Update() light:Movef(0,1,0) end return light end lights = Lights() lights:Update()
I'm still new to Lua but that's what I've gathered in my day of learning by trial and error. If you mean to automatically update then maybe you'd make it an added hook?
-
If your fw.renderer.DrawShadowText() isn't exposed to Lua (remove {hidden} for lugi.generator) and you want to use this function just add this (a fairly simple copy):
function DrawShadowText(text, x, y) SetColor(Vec4(0, 0, 0, 1)) DrawText(text, x+1, y+1) SetColor(Vec4(1, 1, 1, 1)) DrawText(text, x, y) SetColor(Vec4(1, 1, 1, 1)) end
I also added these lines within "constants/engine_const.lua"
--Blending BLEND_NONE=0 BLEND_ALPHA=1 BLEND_LIGHT=2 BLEND_SHADE=3 BLEND_MOD2X=4
Didn't see it in any other Lua file.
-
Not sure if anyone else had a problem but I couldn't hide the waterplane. I tend to set the waterplane first and then paint terrain. Extremely difficult to do with the underwater effect once I had finished painting around the water.
I fixed this by changing a few things in the environment_waterplane.lua file:
Remove "fw.renderer:SetWater(1)" from the object:Refresh() portion and place the "fw.renderer:SetWater(1)" under "object.model:SetKey("wavespeed","1.0") (or anywhere, just out of object:Refresh() but you can't remove it completely).
Within object:SetKey(key,value) add this before "else":
elseif key == "hidden" then if value == "1" then fw.renderer:SetWater(0) elseif value == "0" then fw.renderer:SetWater(1) end
Hope this helps anyone.
At the moment I'm unsure if the property grid changes the text to lowercase, else you may have to change it to "Hidden." I had changed my default property grid so I don't exactly remember how it was before.
My default property grid for "Hidden" is:
group:AddProperty("hidden", PROPERTY_BOOL, "", "Hide")
I have to refresh the editor after changing the default property grid or it doesn't show up after saving. Not sure if it's just me or not.
-
This is sort of an old post but I get this type of error all the time. Once it happened when I loaded the editor for the first time, as well as the script editor, hit tab, and I got the error. I don't think it's a Lua error. Not exactly sure what it is, but I'm going to switch over to Notepad++ until anything with this is fixed.
I also tried the in-editor and standalone Lua editor, both do this, computer specs are always in my signature (Windows XP):
-
Yeah, I figured that out when I was doing my testing, and of course that would have been time saved if I had read that post, lol. Just curious what the point of the "commands.bmx" file is for, which is included at the end of "framework.bmx." It's almost like it's an old file meant for everything to work before he made the update to Lua, changing it to single state.
I have no idea, but my project now works as it always did, but now with Lua, so I'm happy about that.
-
What is this file used for? The forum post http://leadwerks.com/werkspace/index.php?/topic/1089-lua-and-framework/page__gopid__10112entry10112 is about a project of mine that failed when trying to make my framework a lua global object. Once this file (commands.bmx) was removed, lugi.generator regenerated, everything worked fine.
So, I'm just curious what this file is for, as it doesn't seem very important. Everything works. The fire pit. Water. Everything as far as I can tell.
Thanks.
-
This issue has been solved and I'm attempting to figure out how exactly.
I had rebuilt the whole project adding file by file attempting to find the problem. I first started with a simple program that did nothing but quickly setup the abstract path, graphics, and the loop. I added the "setobjectscript()" functions as well.
I first included the framework files that I had in the last project, made them a Lua global, recreated the lugi.generator generated file and bam; worked fine without a problem. I eventually erased the quickly added code and slowly added file by file determined to find what the issue was. I added the last file and still no error.
The only difference is that I didn't use lugi.generator with the file "framework/commands.bmx" included. This is the only difference between the two projects. Within the lugi.generator generated bmx file, there is no TFrameworkCommands and everything works perfectly fine.
Thanks everyone for your help. In these forum replies as well as in PM's.
-
Hmm, I'll try some tests then. Thanks, Mika.
-
I have, the setscriptobject() is being called and is passing the object to Lua. In Lua "fw" isn't nil but methods like "fw.main.camera" don't work.
I had first tried using my own framework which is several weeks worth of programming to use different types of effects, cloud system, weather system, etc., so I was attempting to salvage my last framework. I ended up with the same problem, Lua couldn't use the "fw" global correctly.
So then I tried using the new framework and ended up with the same problem.
It only seems to work successfully using the "normal" way of using framework. Worse case scenario I'll reprogram my whole framework/engine/client for this but it isn't ideal. It's a lot of reprogramming simply because I can't pass the framework object correctly to Lua.
I'm hoping I'm just missing something.
-
I'm probably missing something obvious but I've tried multiple things. Even if I got this done correctly I would have to expand the "commands.bmx" portion for any additional methods I create. This is honestly becoming less ideal for programs that are going the more custom route when it comes to framework. Either it is very lenient and I'm missing something, or it isn't.
Lua is really fun so I'm desperately trying to get this to work. Not to mention Lua could make multiple things easier for the project instead of hard-coding every single aspect of the project.
-
I changed it to a global just to test but no, it doesn't work, and with the setup like this is, it technically is global to all other programs/files. I can use RM in every included file and so forth.
Thanks for the suggestion though.
-
Was going to say that but was thinking maybe something changed in 2.3. Was about to test multiple terrains but now I don't need to.
-
I had spent hours converting my project from 2.27/2.28 to 2.3. One of the important portions of the project move to me was the render classes, which was basically a full customized version of the 2.27 framewerk. I was able to get everything running as it should except of course the Lua scripts. "fw" was never nil but things like "fw.renderer" failed.
I then decided to just grab the newest framework from the 2.3 folders, get Lua working properly, and then I can rewrite the framework for my project needs (cloud/weather system, custom post-processing effects, etc.). That didn't go very well because of how the project is overall structured. I can't understand why either and that is the point of this post.
The normal way is to do the following:
import "framework.bmx" global fw:tframework = tframework.create() setscriptobject("fw", fw)
fw.main.world would work, fw.renderer would work, and so forth. However, since my project is structured a certain way, doing it this way would destroy the organization, so my first attempt (and I will be skipping all my other two+ hours of other attempts) was the following (with some explanation of my projects structure for clarity):
'//-- main.bmx/main.exe global E:engine = new engine E.initialize() while not E.S.Quit() E.update() E.draw() wend E.unload() End
'//-- engine.bmx include "database/manager.bmx" include "debug/manager.bmx" include "content/manager.bmx" '//-- etc include "render/manager.bmx" '//-- etc type engine field DB:databasemanager = new databasemanager field DM:debugmanager = new debugmanager field CM:contentmanager = new contentmanager '//-- etc field RM:tframework = new tframework ' -- tried multiple variations and naming '//-- etc method initialize() DB.initialize() DM.initialize() CM.initialize() '//-- etc RM.initialize() ' -- does the same as tframework.create() does endmethod endtype
RM.main.world works fine, RM.renderer works fine, but this will completely fail:
setscriptobject("fw", RM)
Having Lua give error about "fw.renderer" or "fw.transparency.world" and so forth, even though RM.renderer and RM.transparency.world work just fine in bmax.
Not really sure what I'm missing. Anyone know who has tried the same thing? Anyone know why my version doesn't exactly work correctly?
-
++
-
Nice work Kevin.
-
lmao
-
Scale
in Programming
And here it is:
-
Scale
in Programming
Yeah, started to think about that. However, I just wanted the scale for the dimensional information. I wanted to make arrows around a model/object which will represent x/y/z and figured I'd use the scale to position the arrows correctly. I started using aabb for this, so for it's working ok. At the moment I'm not sure how everything will react when the object is rotated.
-
Scale
in Programming
How does one get the scale of a model? EntityScale just returns 1, 1, 1. Using GetEntityAABB isn't accurate enough and I doubt I should use that to get the scale of a model.
-
3dsm
in Game Artwork
What is the scale to use in 3DSM? Having a hard time exporting to LE with correct scales/dimensions. Anyone know the correct scales and so forth for export?
-
Yeah man, LE is a great engine, I was hooked on it since I got my license.
Random Rotation
in Programming
Posted
This script is virtually useless because the additional added tree's won't save with the scene and it won't add the tree's to scene object list. However, it was just for a challenge to learn Lua, and it works.
Place down a tree, right-click -> properties, mark "Create Batch" true, set how many additional tree's ("Batches"), hit Apply and then Ok. Then translate the tree.
Again, was just for a learning experience. If anyone knows of the correct way to force create the same model correctly, please let me know. I couldn't figure out a way.