ivan wrote:s-ol wrote:I strongly disagree. Many types of content are not suited to be represented in Lua code (for example images, audio), but a lot are. In a lot of cases, lua code is a great serislization target/format
I agree as long as the serialized file only contains tables, numbers and strings.
If your serialized file contains functions (or function calls), then it's no longer "pure data".
It's not a big deal for smaller projects,
but a clear separation between code and content is a good coding practice in my opinion.
Still, sometimes code
is content. Things like dialogue or behaviour (-scripts) can be written very clearly, nicely and succinctly that way IMO.
For example my last project was a point and click; everything intractable is a script that gets passed the layer data. There is an importable function that turns a dialogue coroutine into a clickable dialogue with walk-to animation, text output layers and a character talk/idle animation. That fits 80% of the interactions, but some differ; sometimes theres no walk-to, sometimes the walk-to is after thr dialogue, sometimes theres no character there that would have an animation change etc.
To cover one of these cases I just do the same things the function above does, with the necessary changes and specifics the case requires.
I would definetely call these scripts content since they are even loaded from within the level file and tied to a specific part of that. The scripts often contain actual logic and I don't even want to think about how my dialogue-engine Interface would have to look like to accomodate all it needs to cover if my data was "pure data".
I can see that one might disagree with writing logic and defining functions, but function calls are immendly useful as data-transformers (aka DSL) to make writing he data less repetitive and error-prone.