Posted: 16th Nov 2021 1:56
This is basically a data structure and retrival system, external data has to come from somewhere and as I love using Lua I thought it the perfect opportunity to use it now, there will be some AI automation further down the line I'll keep you updated on the code and systems, I will not lean to heavily on Lua .. you'll see where I am going

This "city_placment.lua" is a data file, it will eventfully hold a massive amount of Lua table data and a few functions for C++ to retrieve the data
+ Code Snippet
--#######################################
-- City Data file
--#######################################

-- Define table of city positions
local tCity = {}
tCity["Land 1"] = {}
tCity["Land 1"]["pos"] = {}
tCity["Land 1"]["rot"] = {}
tCity["Land 1"]["pos"]["x"] = 101
tCity["Land 1"]["pos"]["y"] = 102
tCity["Land 1"]["pos"]["z"] = 103
tCity["Land 1"]["rot"]["x"] = 104
tCity["Land 1"]["rot"]["y"] = 105
tCity["Land 1"]["rot"]["z"] = 106

tCity["Land 2"] = {}
tCity["Land 2"]["pos"] = {}
tCity["Land 2"]["rot"] = {}
tCity["Land 2"]["pos"]["x"] = 201
tCity["Land 2"]["pos"]["y"] = 202
tCity["Land 2"]["pos"]["z"] = 203
tCity["Land 2"]["rot"]["x"] = 204
tCity["Land 2"]["rot"]["y"] = 205
tCity["Land 2"]["rot"]["z"] = 206

tCity["Land 3"] = {}
tCity["Land 3"]["pos"] = {}
tCity["Land 3"]["rot"] = {}
tCity["Land 3"]["pos"]["x"] = 301
tCity["Land 3"]["pos"]["y"] = 302
tCity["Land 3"]["pos"]["z"] = 303
tCity["Land 3"]["rot"]["x"] = 304
tCity["Land 3"]["rot"]["y"] = 305
tCity["Land 3"]["rot"]["z"] = 306

-- Called by C++ to get city position
function GetCityPosition(sName)
	return tCity[sName]["pos"]
end

-- Called by C++ to get city rotation
function GetCityRotation(sName)
	return tCity[sName]["rot"]
end


And this is the C++ code that runs the script and retrieves the data (the Lua C API does seem a little complex but its a piece of cake when you understand the stack system, and what seems like a overly complicated data system really does have massive advantages, thus why a lot of AAA games use it)
+ Code Snippet
	int ipX, ipY, ipZ;
	int irX, irY, irZ;

	if (luaL_dofile(m_Lua, "scripts/city_placment.lua") == LUA_OK) 
	{

		// get city position
		lua_getglobal(m_Lua, "GetCityPosition");
		if lua_isfunction(m_Lua, -1)
		{
			lua_pushstring(m_Lua, "Land 2");
			if (lua_pcall(m_Lua, 1, 1, NULL) == LUA_OK)
			{

				if (lua_istable(m_Lua, -1)) 
				{
					// Get X position
					lua_getfield(m_Lua, -1, "x");
					if (lua_isnumber(m_Lua, -1)) {ipX = lua_tonumber(m_Lua, -1);}
					lua_pop(m_Lua, 1);// pop this value off the stack

					// Get Y position
					lua_getfield(m_Lua, -1, "y");
					if (lua_isnumber(m_Lua, -1)) {ipY = lua_tonumber(m_Lua, -1);}
					lua_pop(m_Lua, 1);// pop this value off the stack

					// Get Z position
					lua_getfield(m_Lua, -1, "z");
					if (lua_isnumber(m_Lua, -1)) {ipZ = lua_tonumber(m_Lua, -1);}
					lua_pop(m_Lua, 1);// pop this value off the stack

					lua_pop(m_Lua, 1);// pop the table off the stack

					// debug show position
					char buffer[255];
					std::sprintf(buffer, "City Position: X=%i Y=%i Z=%i", ipX, ipY, ipZ);
					agk::Message(buffer);

				}
			}
			else 
			{
				agk::Message(lua_tostring(m_Lua, -1));
			}
		}
		else 
		{
			agk::Message("GetCityPosition: Not Found!");
		}

		// Get city rotation
		lua_getglobal(m_Lua, "GetCityRotation");
		if lua_isfunction(m_Lua, -1)
		{
			lua_pushstring(m_Lua, "Land 2");
			if (lua_pcall(m_Lua, 1, 1, NULL) == LUA_OK)
			{

				if (lua_istable(m_Lua, -1))
				{
					// Get X rotation
					lua_getfield(m_Lua, -1, "x");
					if (lua_isnumber(m_Lua, -1)) { irX = lua_tonumber(m_Lua, -1); }
					lua_pop(m_Lua, 1);// pop this value off the stack

					// Get Y rotation
					lua_getfield(m_Lua, -1, "y");
					if (lua_isnumber(m_Lua, -1)) { irY = lua_tonumber(m_Lua, -1); }
					lua_pop(m_Lua, 1);// pop this value off the stack

					// Get Z rotation
					lua_getfield(m_Lua, -1, "z");
					if (lua_isnumber(m_Lua, -1)) { irZ = lua_tonumber(m_Lua, -1); }
					lua_pop(m_Lua, 1);// pop this value off the stack

					lua_pop(m_Lua, 1);// pop the table off the stack

					// debug show position
					char buffer[255];
					std::sprintf(buffer, "City Rotation: X=%i Y=%i Z=%i", irX, irY, irZ);
					agk::Message(buffer);
				}
			}
			else
			{
				agk::Message(lua_tostring(m_Lua, -1));
			}
		}
		else
		{
			agk::Message("GetCityRotation: Not Found!");
		}
	}
	else 
	{
		agk::Message(lua_tostring(m_Lua, -1));
	}

	// assuming everything went ok (no script errors, city name found, bla bla bla)
	// create and position city here!

	// START AGK CODE
	// agk::LoadObject()
	// agk::SetObjectPosition()
	// agk::SetObjectRotation()


The project will end up having a dozen or so scripts like this for various assets, AI decisions and anything else I need to store externally, the benefit of this is I can tweak things while the game is running, offer modding capabilities, and of course, show off my coding skills

Approved?

For anyone else wondering what on earth this is all about, As I am now making my project in Tier2 I asked the Mods if I could incorporate Lua, external data has to come from somewhere this is no different to using XML or SQLite its just way more flexible, anyway, the Mods said they want to see code and examples of how I would be using Lua as its an AppGameKit competition, the AppGameKit API must take precedence, but as you can see from the code it really is no different to using RapidXML, just a million times more flexible
Posted: 16th Nov 2021 2:31
Approved?

yup
Posted: 16th Nov 2021 2:43
Excellent, Thanks

When I get to the AI part I will post further snippets and a working example, like I said I want it for the "yield" or "Sleep" functionally, even C++ can not yield in the middle of a function call without locking the program up, Lua can it just sits there and waits for permission to continue, like magic lol, it can cut a state machine in half and simplify a whole bunch of things.
Posted: 19th Nov 2021 3:31
Ah, Like VN found out I am hitting "real estate" issues and I foresee a finite cap on playability ... so a rethink is in order "open up another section of the map" ... has given me an idea, I can use most of what I have written so far and add "something else" ... TBC.......
Posted: 19th Nov 2021 5:44
screenshot or it doesn't exist!
Posted: 19th Nov 2021 6:17
Wires are hanging out ... going to take a few days to put it all back together .... will post a video when I got the new framework up n running, pretty much the same system as I was going for with the globe thing just with an added *something* to give me a million percent more real estate.....

It will make sense when you see it
Posted: 20th Nov 2021 4:27
Main Menu, Game Title (Finalised!), Prop Badges, I will stick a rendered backdrop of a battle scene in when I am ready, might even animate it if I got time, cant show now though as it will give too much away ....

Posted: 23rd Nov 2021 20:49
Just a quick render, not feeling the code today so messing around in blender.

The invasion looms!

Posted: 23rd Nov 2021 20:53
I love the cartoon look, the more cartoon the better.

Do you have a working system for any game play yet?
Posted: 23rd Nov 2021 21:03
i have been waiting for a request from you to change this thread's name but couldn't take it any longer

"

good stuff!
Posted: 23rd Nov 2021 21:07
any game play yet?


Almost ..... all in good time

There will be 2 modes to the game play, the second part is fighting back (but I got Flu and cant think straight, hence the blender stuff) on the plus side, 2 weeks off work coz everyone thinks I got the lurgies!!

It wont look exactly like that in game as that's an Eevee render but I am going to try to get it as close to that as I can, I quite like it too, looks like plasticine, I said from the start I want that Futurama look

Edit:

but couldn't take it any longer


HaHa, thanks
Posted: 23rd Nov 2021 22:38
The concept art is looking great, just wish I could export to AppGameKit looking like this!

Posted: 23rd Nov 2021 22:41
looks great, ptc

so, with 8 fingers per "hand", it's gonna tickle its target into submission?

very futurama
Posted: 23rd Nov 2021 22:56
just wish I could export to AppGameKit looking like this!

Bake the textures
Posted: 23rd Nov 2021 23:30
it's gonna tickle its target into submission?


Yes, Gatling tickles, nuclear kisses and love bombs...lol

Bake the textures


Yea I have not got that far with blender, I have done basic diffuse and AO, but not done lightmaps yet, but with the shader pack and some patience (and some YT tuts) I am sure I can get it looking close (just been looking at the self illuminating stuff)
Posted: 24th Nov 2021 0:09
I would go with a diffuse and normal. Using a normal will give you the shininess (specular)
Posted: 24th Nov 2021 8:45
I thought normal was for the texture... so much to learn lol

Thanks for the vid
Posted: 24th Nov 2021 10:26
Looks great.
I'm curious how the models will look and work in the game.
Posted: 24th Nov 2021 11:02
I am working on the looks, I had backtracked and decided modularity was the answer so I am soaking up lots of knowledge from YT lol

As to how they will work, I am playing with 2 aspects of gameplay if I can incorporate them both and have it work seamlessly then I will stick with it but not going to revile to much yet as I may end up scrapping one or the other.

But basic turret setup will be pitch and yaw (rotation, elevation), I might use a rig for this, still need to experiment to see what works best

First set of game ready turrets are almost ready, just got to hone the workflow once I got that I can go on a asset binge

Posted: 24th Nov 2021 16:39
That 40 second solution was indeed to good to be true, it only works on the most basic of models, with the mods I am using (mirror, bevel, boolean) and the setup it fails....

Need to use a "Cage" object



Thanks Grant .... again, lol

I have only done the base for now, getting to grips with the workflow has been a days work!!

The detail on the base object is baked from the high poly, some of it looks naff but I went overkill just to see some results, now time to go back and do it all properly, proper unwrap and apply a diffuse, now I know I can go mad on the detail and not worry about polycount... let the fun begin! lol