Closed Frityet closed 1 year ago
(missclicked the close button, sorry!)
if
statement from HOI4? It probably is possible, but I can't think of an language that can implement it sanely (fill me in if there is one). And depending on the language, the learning curve could be so much higher than of just learning HCL or the pre-built HOI4 scripting that the user would just forget it and not learn it (the goal is to retain as much of the ease of use and learning from the base HOI4 scripting language as much as possible while making the syntax much better).Apologies if my original comment seemed aggressive, I mainly am saying that lua would be a better fit due to it having a long standing use, and already used in hoi4 and hoi4 mods, having similar syntax to hoi4 scripting, and being simple and easy to use
--This can also be turned into an implicit global
local pdx = require("libpdx")
pdx.removeFolder("build/output")
--also legal
pdx.createFolder "build/output"
local mod = pdx.mod.create {
name = "test mod",
game_version = "1.12.*"
}
local ev = pdx.event.create {
title = "bro",
id = 2,
description = [[
This ain't fr!!!!!!!!!!!!!!!
]],
image = "res/remtard.jpg"
}
ev:addoption("nice")
I totally understand if you wanna make a new language though, this is an amazing project!
lua was created for these types of tasks, so in my mind it makes sense to use it
While Lua does sound nice and I might consider not only learning it but also porting libpdx to it in the future, I have quite a few concerns with it. As I mentioned in my previous comment, I don't even know Lua, so I obviously didn't pick it for the task of trying to replace HOI4 scripting.
However, as you brought this topic to the table, I still had my biggest concern - implementation. How well would Lua implement stuff like result scopes, Hoi4 scripting's if
statements and for loops in result scopes, among other things? I already know how I would plan these things out in HCL as I have full creative control as to what the syntax will look, but in Lua or in any other language? No clue. I would be interested to see if Lua can offer such implementations, however I kinda doubt it and I definitely can't answer this unless I actively would start learning Lua for months to figure it out, which everyone can agree is stupid to do. I'll provide a few HCL implementations of things I mentioned above and see if a Lua port would be possible or even better. I doubt the end result will change HCL's course path, however I'll definitely keep in mind from these results.
For how HCL would deal with scope results, refer to this part of the README.md. Not sure how Lua would implement scope results, using a function-based method (can't imagine that looking good)?
In HCL statements would behave differently in a scope
variable (a scope result) than in normal use. Instead of actually checking if a logic is valid, it would convert the line to HOI4 scripting (this is why I mention possible backwards compatibility in scope
typed variables in the README.md). However, the syntax doesn't change between these two modes so it becomes really convenient for devs as not only you don't have to learn more syntax, but also makes the code more consistent, understandable and readable.
An example of how it would look
bool includeEvents = true
if (includeEvents) { // Brackets aren't required, however the option is available for those that want it.
newOption(someEventVar, "scoping around") = {
if isInFactionWith("SOV") { // This is to show that the syntax doesn't change between a non-scoped `if` and a scoped `if`
addStability("ROOT", 50) // The player would gain 50% stability if it's in a Soviet faction.
}
}
}
How the generated HOI4 code would look
option = {
name = namespace.id.whatever
if = {
limit = {
is_in_faction_with = SOV
}
ROOT = { add_stability = 0.50 }
}
}
A for
loop would be harder to include and less handy to use, as Paradox hasn't implemented any real generic way of using for
loops in the text files, however HCL will just duplicate the generated HOI4 code to achieve the same effect. I am most interested seeing how this would even get implemented in Lua while looking good.
Why is a new language being create for this rather than an already existing language?