Introduction to YueScript
YueScript is a dynamic language that compiles to Lua. And it’s a MoonScript dialect. The codes written in YueScript are expressive and extremely concise. And it is suitable for writing some changing application logic with more maintainable codes and runs in a Lua embeded environment such as games or website servers.
Yue (月) is the name of moon in Chinese and it’s pronounced as [jyɛ].
A Taste of YueScript
Section titled “A Taste of YueScript”-- import syntaximport p, to_lua from "yue"
-- object literalsinventory = equipment: - "sword" - "shield" items: - name: "potion" count: 10 - name: "bread" count: 3
-- list comprehensionmap = (arr, action) -> [action item for item in *arr]
filter = (arr, cond) -> [item for item in *arr when cond item]
reduce = (arr, init, action): init -> init = action init, item for item in *arr
-- pipe operator[1, 2, 3] |> map (x) -> x * 2 |> filter (x) -> x > 4 |> reduce 0, (a, b) -> a + b |> print
-- metatable manipulationapple = size: 15 <index>: color: 0x00ffff
with apple p .size, .color, .<index> if .<>?
-- js-like export syntaxexport 🌛 = "Script of Moon"-- import syntaximport p, to_lua from "yue"
-- object literalsinventory = equipment: - "sword" - "shield" items: - name: "potion" count: 10 - name: "bread" count: 3
-- list comprehensionmap = (arr, action) -> [action item for item in *arr]
filter = (arr, cond) -> [item for item in *arr when cond item]
reduce = (arr, init, action): init -> init = action init, item for item in *arr
-- pipe operator[1, 2, 3] |> map (x) -> x * 2 |> filter (x) -> x > 4 |> reduce 0, (a, b) -> a + b |> print
-- metatable manipulationapple = size: 15 <index>: color: 0x00ffff
with apple p .size, .color, .<index> if .<>?
-- js-like export syntaxexport 🌛 = "Script of Moon"About Dora SSR
Section titled “About Dora SSR”YueScript is being developed and maintained alongside the open-source game engine Dora SSR. It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience.