Page 1 of 1

Question: Lua Script Effects Module

Posted: Fri Mar 29, 2019 10:57 pm
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?

Re: Question: Lua Script Effects Module

Posted: Sat Mar 30, 2019 11:46 am
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.

Re: Question: Lua Script Effects Module

Posted: Sat Mar 30, 2019 3:33 pm
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.

Re: Question: Lua Script Effects Module

Posted: Sat Mar 30, 2019 7:19 pm
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.

Re: Question: Lua Script Effects Module

Posted: Sat Mar 30, 2019 11:03 pm
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.

Re: Question: Lua Script Effects Module

Posted: Wed Aug 14, 2019 3:40 am
by zeko
Wow, GPT-2 powered spam in the wild.

Re: Question: Lua Script Effects Module

Posted: Sat Aug 17, 2019 12:40 am
by Corbeau
Dafuq was that?!