Original Post
Hi there! I wasn´t exactly sure where to put this, but here seems fitting to me. I´m rather unsure how to deal with interaction with my graphics engine, that is how to handle input (not only by the player, but by a script for instance)... my current idea would be to use some kind of message / event system. All the logic and graphical entities would "subscribe" at one hub for the events and messages it wants to receive. Every message / event will first be handled by the hub, which just passes it on to the entities that subscribed to it. The Mediator pattern seems to describe the same or a similar setup. I think this system would work fine for input, but would fail for things requiring output. The problem is that it is not known when a message / event will be processed and there is no possibility to return a value through this system (except sending another message containing the return value, but again it is not known when this message would be processed). For example if someone writes a script that would require the knowledge where the player character currently is. With the event / message system this information cannot easily be retrieved, as you don´t know when your request for it will be processed. Normally I´d say it would be nice to have some sort of function in the engine that can be called from the script, something like GetPlayerPosition() or anything like that. But I obviously don´t want implement loads of specific GetThis() GetThat() GetFoobar() functions for every logical entity and every property they might have. So, to sum it up: I´m interested in how to design an interface to use with a scripting language like LUA, or an application built using the engine, or with a console inside such an app and so on... of course I know there isn´t something like _the_ solution to this problem, but I would really appreciate any insights and tips, perhaps someone wants to share how he / she solved this. Thx for reading and your help!