Check for campaigns being loaded using [lua]

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Check for campaigns being loaded using [lua]

Post by The_Gnat »

Hi, i am not familiar with [lua] tags but i have encountered a problem that i think using lua would be solvable:

Basically i want to create [lua] code that is part of my umc era that checks if any campaigns are being loaded and if a campaign is being loaded does an action, if multiplayer is being loaded does a different action and if neither are being loaded (for example if the unit database is being loaded) does a third action.

Thanks a lot!!! :D
Last edited by The_Gnat on November 12th, 2016, 5:16 am, edited 1 time in total.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Post by gfgtdf »

You can easily chacke which units are being 'loaded' by checking wesnoth.unit_types[unit_id] ~= nil. wesnoth.game_config.mp_settings can also give you information about the currently playing mp game and active mods.

Note that in mp making code depdnent on whether a specific unit type is loaded might casue OOS since its posible that a type is onyl loaded one one clients (becaue others don't have the corresponding addons installed)
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Check for campaigns being loaded using [lua]

Post by The_Gnat »

Thanks gfgtdf, :D i was more wondering though if there was a way to check if a campaign was being loaded. This would be great because i want a modification to be loaded ONLY in the unit database! I can #ifndef MULTIPLAYER to make it not load into multiplayer, but i want to do IF NOT CAMPAIGN using [lua] code to make sure it doesn't load into any campaigns! (i know it sounds silly but this would be real helpful ;) )

Thanks again, hopefully this can be done!
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Post by gfgtdf »

in mp you can use wesnoth.game_config.mp_settings.mp_campaign ~= "" t check whether this is a campaign or just a regular [multiplayer]
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Check for campaigns being loaded using [lua]

Post by Ravana »

I dont think database looks any of your Lua.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Check for campaigns being loaded using [lua]

Post by The_Gnat »

gfgtdf wrote:in mp you can use wesnoth.game_config.mp_settings.mp_campaign ~= "" t check whether this is a campaign or just a regular [multiplayer]
Thanks yeah this is what i would want to do :D , i'll give it a try!
Ravana wrote:I dont think database looks any of your Lua.
That actually isn't a problem. :D

EDIT: Hmm... can you put a [lua] check for campaign type code into a [unit]? :P I don't think you can, but i ask because i want to change the advancements for this unit if any campaign is being loaded, Thanks!
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Post by gfgtdf »

EDIT: Hmm... can you put a [lua] check for campaign type code into a [unit]? :P I don't think you can, but i ask because i want to change the advancements for this unit if any campaign is being loaded, Thanks!
you can put a [lua] in a [event] in a [unit]
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Check for campaigns being loaded using [lua]

Post by The_Gnat »

gfgtdf wrote:you can put a [lua] in a [event] in a [unit]
Great idea, :D what I'll do is set my units to [advance_from] the people i want, but then if a campaign is being loaded then i will modify there advancements using a [event]!

Should i run my [lua] code as a name=turn refresh or a name=new turn [event], to make sure all the units have their advancements properly modified?
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Check for campaigns being loaded using [lua]

Post by Tad_Carlucci »

Not been reading, not sure what you're wanting to do or why, but it seems to me there's almost certainly a better place to handle a unit advancement issue than checking every turn.
I forked real life and now I'm getting merge conflicts.
User avatar
The_Gnat
Posts: 2215
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Check for campaigns being loaded using [lua]

Post by The_Gnat »

Tad_Carlucci wrote:Not been reading, not sure what you're wanting to do or why, but it seems to me there's almost certainly a better place to handle a unit advancement issue than checking every turn.
:lol: Yeah after looking into [lua] a little bit i have much more respect for the developers of wesnoth! and have decided to postpone this thing i am working on until i have more time to devote to learning [lua]. Thanks a lot to everyone on this thread who tried to help! :D
Post Reply