Question: Lua Script Effects Module

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

Question: Lua Script Effects Module

Postby Temeria » Fri Mar 29, 2019 10:57 pm

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
Hardened
Posts: 200
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Question: Lua Script Effects Module

Postby Ignatus » Sat Mar 30, 2019 11:46 am

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

Postby Temeria » Sat Mar 30, 2019 3:33 pm

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
Hardened
Posts: 200
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Question: Lua Script Effects Module

Postby Ignatus » Sat Mar 30, 2019 7:19 pm

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

Postby Temeria » Sat Mar 30, 2019 11:03 pm

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.

KamClep
Posts: 16
Joined: Sat Jul 27, 2019 12:24 am
Location: Panama
Contact:

Question Lua Script Effects Module

Postby KamClep » Wed Aug 14, 2019 2:15 am

A friendly hello to all.

I would like to know how often the query per second of a LUA script is. The script is basically the same as the SDK Material Season Example.lua.

A friendly programmer said it was possible that the query might be 18 times a second TICK18. One more question: How common is the query of a code stored in the modeldef.xml, is the LUA Script more resource efficient than the Season Code from the modeldef.xml?


If you adored this article and you simply would like to get more info concerning What is a good salary in Singapore 2019 or How much does a trip to Japan cost for 2 weeks kindly visit our page

zeko
Posts: 12
Joined: Wed Oct 03, 2018 6:36 pm

Re: Question: Lua Script Effects Module

Postby zeko » Wed Aug 14, 2019 3:40 am

Wow, GPT-2 powered spam in the wild.

User avatar
Corbeau
Elite
Posts: 991
Joined: Mon Jan 13, 2014 11:13 pm

Re: Question: Lua Script Effects Module

Postby Corbeau » Sat Aug 17, 2019 12:40 am

Dafuq was that?!