Jump to content

Community Decision - Standardized Entity Message Format?


TylerH
 Share

Entity Message Format Standardization  

7 members have voted

  1. 1. Should we develop a standard for programmers and artists alike to utilize for Lua entities and the messages they send using the entity message system?

    • Yes
    • No
    • Other (Please post!)
      0


Recommended Posts

This is a simple poll, that can have lasting, constructive results on the community and how we can continue developing thingoids and other entities, both in Lua and C/C++, across multiple developers who may not even know each other, but can build off of other published entities and communicate with them due to a standardized format for message handling.

 

My proposal is this (the theory, not the example formatting I am using):

 

Even though we have the single-state Lua development model for the Editor and the Engine now, entities still will have a level of communication via the Leadwerks Entity Message System. This is key, because it is core in the engine, and works across all language barriers, namely Lua <---> C/C++/Blitzmax.

 

The key theory here, is to have a standard format for the names, values, purpose, function, etc. of various messages, and code base entity classes that have hooks for interface, not necessarily functionality and implementation, of all of these standards.

 

The main points of the idea are as such:

  • A community-managed, standardized, extended core class.lua type file that contains all of the to-be-mentioned functionality
  • A standard form of communication, via messages, between entities through the entity SendMessage, ReceiveMessage, etc. set of methods and callbacks
  • Some type of standard format that all message names would share, that is human-readable/friendly, informs purpose, and provides description. Such an example would be: "Info_Position_Update",a message that an entity would send to another entity to give it its position as an update. Another example could be: "Game_AI_PlayerSeen". Squad AI thingoids could send this message and relay it to other squad members to alert them that the player is seen.

 

Those are VERY specific examples, but standards always help with things like this.

 

You could have a general purpose prefix, like Info, Game, Engine, Render, etc. to indicate what the message will be relaying or functioning FOR. Follow that with a topic, such as Entity, [Position,Rotation,Scale], Model, Force, Joint, Weapon, Projectile, etc. to tell WHAT the message is ABOUT. Follow that with more and more WHAT's to describe the message further (Game_Vehicle_Tank is more descriptive than Game_Vehicle, e.g.). End it with a WHAT it is DOING, for example Update, Kill, Alert, DriveForward, Expload, Enter, Exit, Spawn, etc. (these are the specific parts).

 

This would form a hierarchy similar to:

FOR -> WHAT [specific What] -> HOW/WHY

 

It would simulate:

Namespace -> Class -> Method, but in a message form that all entities could support and share. Someone developing a weapon thingoid, would know from checking the standard that the AI and Player thingoids have messages the Weapon thingoid can utilize to interact with said pawn thingoids (AI and player). And vice versa, and so on.

 

So, what do you all think?

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

That is always an option.

 

Did I miss something during my inactive period that made entity messages obsolete?

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

My original concept was to rely on messaging for everything between multiple Lua states. A single-state ended up being used, which made this approach unnecessary. The disadvantages I see to using messages is the data you can transfer is limited to strings, the parameters you can call are limited, and it is not as simple as just using the lua object function for whatever you want to do.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

It might be better to call Lua class methods directly. You can do this from C++.

 

Unless you made the change of renaming your lua methods you made this can only be done with modifying engine.h. Even then, calling a lua object method from C++ hasn't been demonstrated yet.

Link to comment
Share on other sites

This is how I do it:

size=luastate.stacksize()
lua_getglobal(luastate.L,"objecttable")
If lua_istable(luastate.L,-1)
lua_pushobject(luastate.L,Self)
lua_gettable(luastate.L,-2)
If lua_istable(luastate.L,-1)
	lua_remove(luastate.L,-2)
	lua_getfield(luastate.L,-1,"UpdateMatrix")
	If lua_isfunction(luastate.L,-1)
		lua_pushvalue(luastate.L,-2)
		lua_remove(luastate.L,-3)
		luastate.invoke(1,0)
	EndIf
EndIf
EndIf
luastate.setstacksize(size)

 

It's confusing, but you don't really have to understand what each line does. Just copy and paste that code and you can reuse it.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

That's good stuff. Now the issue of us having to modify engine.h to rename your lua methods so we can use the real lua in our program without conflicts. From what I can see some of those methods you didn't create in engine.h, which would mean we need to bring in lua to our projects, which leads to the function name conflicts.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...