Question: Lua Script Effects Module

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
Temeria
Posts: 3
Joined: Fri Mar 29, 2019 10:19 pm

Question: Lua Script Effects Module

Post by Temeria »

Hi, I'm trying to make various effects run via lua script for the purpose of roleplay. However, I keep running into the same problems with regards to changing effects via lua script.

If I try effects.world_bonus(effect_type_name), where effect is example Reveal_Map, it produces error: bad argument #2 to 'world_bonus' (got 'nil', 'string' expected). Why is there an argument #2? If I try to put a 2nd argument and put a random string in, it then says bad argument #2 to 'world_bonus' (got 'string', '(null)' expected).

When I try effects.player_bonus(player, effect_type_name), I get the same problem except it's now because of bad argument #3 instead of 2. I'm assuming the same problem exists for effects.city_bonus? How do I change effects via lua script then?

A side question: Is it possible to have a dialogue box appear for the player with "yes" and "no" choice for events which happen in-game?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Question: Lua Script Effects Module

Post by Ignatus »

Temeria wrote: If I try effects.world_bonus(effect_type_name), where effect is example Reveal_Map, it produces error: bad argument #2 to 'world_bonus' (got 'nil', 'string' expected). Why is there an argument #2?
The function arguments are enumerated from 2, AFAIK. Have you assigned

Code: Select all

effect_type_name = "Reveal_Map";
or something?
A side question: Is it possible to have a dialogue box appear for the player with "yes" and "no" choice for events which happen in-game?
Not yet, both no such functionality for client- and server side.
Temeria
Posts: 3
Joined: Fri Mar 29, 2019 10:19 pm

Re: Question: Lua Script Effects Module

Post by Temeria »

The function arguments are enumerated from 2, AFAIK.
This would be odd, since the error message changes when I change effects.world_bonus(Reveal_Map, 'string') to effects.world_bonus(Reveal_Map, 5). Now the error is "argument #2 is 'number'; '(null)' expected."

Using your suggestion and making the argument a string:

Code: Select all

local effect_type_name = "Reveal_Map";
effects.player_bonus(find.player(0), effect_type_name)
I stop getting error messages, but instead the effect does not trigger.

At the moment, I'm trying to write an event which changes Gain_AI_Love by x amount, but I don't know how to change effects amount by lua. However, presently the problem is, can't even get a binary effect like Reveal_Map to trigger.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Question: Lua Script Effects Module

Post by Ignatus »

Ah, you want to trigger effects? Sorry, they are mostly not triggerable with Lua, the effects module contains only checking functions that return the effect's current value and can't modify it. It is not done intentionally to keep the rules simple enough, especially for the AI. In theory, AI love may be made modifiable but actually it is not. Only the history-type culture can be changed from Lua (in the newer versions where it exists), you can try to tie effects to culture diapasones if you don't use other culture effects.
Temeria
Posts: 3
Joined: Fri Mar 29, 2019 10:19 pm

Re: Question: Lua Script Effects Module

Post by Temeria »

That's a pity as it would help with modding and creating scenarios with story, which I think Civ 2 was quite good at. With regards to AI, I fail to see the relevance as event effects can be made to apply only to human for roleplay, and at any rate, if one is unhappy with its effects on AI, one can simply highlight it in the lua and delete the whole thing, versus making changes in the rulesets which might go on and affect multiple files. Thanks for replying.
zeko
Posts: 12
Joined: Wed Oct 03, 2018 6:36 pm

Re: Question: Lua Script Effects Module

Post by zeko »

Wow, GPT-2 powered spam in the wild.
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Re: Question: Lua Script Effects Module

Post by Corbeau »

Dafuq was that?!
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
Post Reply