[Freeciv-Dev] Adding scripting language
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Let's talk a bit about it.
As it is note on web site guile seems to be best choice. I personally
would prefer java, but it's footprint is way too large for just
scripting language (and it needs compiling - more mess than with fully
interpreted language).
Adding guile to C programs seems straigforward. Hooks into C data can be
added incrementally - when somebody will need somthing he will just add
needed accessor/side effect function.
Some points where scripts can be added are obvious - for example
can_build predicate for building with (player,city) arguments. For
default rule (just prerequisite tech) no script will be given so normal
code will be executed. If script is given, it will be run instead of C
code (possibly repeating some steps from C - but sometimes it might be
necessary to override them - for example if given building is enabled
earlier by wonder).
Real question is how to arrange it all so guile code will execute only
on server (as it is better to keep client simple and additionally client
sometime will have not enough data to correctly evaluate script). For
script with attack routine it is easy - just run on server and send
results about units. But what with can_build predicate ?
My proposition is to add can_build array to city and send it with city
data - filling on server with results of all can_build routines. It
shouldn't be problem for network traffic (bitfield will maybe 20-30
bytes and city packet is few times larger), but I'm not sure how it will
affect cpu usage - after all a lot of scripts will have to be run every
turn for every thing that changes state.
Second big question is how to implement wonders etc - things with global
affects. Wonder which establishes embassies with all civs is easy - just
run script and forget. But wonder which cuts down shield cost of air
units in half is more complicated. You can add build_cost script to air
units and add same check for given wonder in each of them, but it's a
bit overkill. I do not see easy way to solve this. Maybe some kind of
event registry, so for example each time some kind of script is called
first global overrules are checked. But with 5 global event listeners
for build_cost, every change in city would require evaluation not of 100
build_cost scripts, but 600 of them. Any ideas ?
Artur
- [Freeciv-Dev] Adding scripting language,
Artur Biesiadowski <=
|
|