Simpleparser

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
cazfi
Elite
Posts: 1344
Joined: Tue Jan 29, 2013 6:54 pm

Simpleparser

Postby cazfi » Wed May 17, 2017 10:34 pm

The problem that modpack authors seem to have with powerful lua scripting interface is that as a fullblown programming language it's not exactly simple syntax. In freeciv-3.1 development I'm trying to address that issue with something I call simpleparser. From the freeciv engine point of view scripting is always done with the lua (it provides only lua interface), but I'm working on such a lua script that it would parse events from simpler datafile. Modpack author then would not need to change that lua script (parser) but only the datafile. Yet lua scripting remains an option to do more complex things with - you can definitely mix direct lua scripting and simpleparser datafiles in the same ruleset.

As a proof of concept implementation, I can currently handle datafile like this:

Code: Select all

[turn_1]
action="log"
msg="First Turn"
restrictions = { "type", "value"
                 "turn", "1"
               }

[turn_2]
action="log"
msg="No restrictions here"

[turn_3]
action="log"
msg="Turn 4"
restrictions = { "type", "value"
                 "turn", "4"
               }


There's three event definitions. They are triggered by turn change. All of them are potentially triggered on every turn change - number part in [turn_1] is not turn number, but number of the event definition. Number 2 has no further restrictions - it really executes every turn change. First one has a restriction of type "turn" and value "1" meaning it executes only on first turn. Third one executes only on fourth turn. The action they execute is "log" for all of them. There's also field specific to "log" actions named "msg". That's the message they write to the log.

Everything is still subject to change. That's actually why I write this post already - would you consider something like this suitable datafile format, and how you would want to change it. Comments.

louis94
Hardened
Posts: 186
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Simpleparser

Postby louis94 » Thu May 18, 2017 12:16 pm

Hello,

Maybe you should take a look at Wesnoth's ActionWML. It mixes event-driven and declarative approaches, and I think it's quite close to what you're trying to do. Wesnoth modding is very active, so it must be successful.

Louis

Lachu
Hardened
Posts: 221
Joined: Sat May 04, 2013 2:19 pm

Re: Simpleparser

Postby Lachu » Sat Jul 01, 2017 11:26 am

I suggest to first create counters, because actions needs conditions, which fire events. I have described counters on this forum.