I'm only going on my experience with my own script. Here it is.
function spawn3_init(e)
Hide(e);
end
function spawn3_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 7000 then
Show(e);
else
Hide(e);
end
end
Very similar to yours you will see. It worked great, but when applied to many objects I started to get worse performance. I used a couple of versions with different distances for different buildings rather than add a variable or array for it, just lazy sometimes, lol. Especially with Lua as I am still pretty new. Certainly as you say a more refined system may work better. Not sure what the return values are you use in your script? I'm used to return sending you back to a gosub
. I hope you find a good boost from your tests! I just know from mine I was disappointed. An hour changing entity scripts to find none or worse performance gain. Again I wish I had called it default.lua ;p The thought just didn't occur to me.
@smallg, It really ran as badly as it did without the script for me, or with the one above applied to many of them. I only made a small zone to test it at the start, rather than a large zone around the entire level. Perhaps that would have worked better. I was too busy getting my game working to worry about it, fps was reasonable I was just being greedy , even 1 fps would have been worth it
I have a Nvidia Geforce 660 GTX now rather than my older 260, but things still struggle more than I would have thought. Maybe my old Q6600 is starting to struggle with some aspects of Reloaded possibly. It should cope though to be honest
The 660 was certainly not the boost I imagined it would be, although it was a boost non the less
It may be with more time it would have shown performance boosts, but from the first test I figured, hmm, not looking good, lol. Mainly because I remember the old DB days of doing the same to little effect. I have seen people who have had great success though, so maybe it was just me being too quick to move on.
I'm surprised they haven't got a speed boost from quads, as I know from tests in DB that the plugin for DB helps maintain a lot of performance. I'm sure I may have made something half decent (half decent to look at, the ai would have been dreadful
), if I hadn't moved to AGK very shortly after. I think that it used quads, not sure, but whatever it did, it made a great difference to rendering speed! It will be nice to see proper occlusion implemented, as whatever we do with Lua, it is not going to be as fast as TGC can do with C++ in the main engine.
We as users can only twiddle so much. My twiddling didn't amount to much, but that is not to say yours will end up the same. If you or smallg, or anyone makes a script that will give better performance I and I am sure many will gladly use it! You never know we might give TGC some ideas they can improve on within the engine
SPECS: Q6600 CPU. Nvidia 260GTX. 8 Gig Memory. Win 7.