Check for campaigns being loaded using [lua]

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

Moderators: Forum Moderators, Developers

Check for campaigns being loaded using [lua]

Postby The_Gnat » November 12th, 2016, 1:03 am

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.
User avatar
The_Gnat
 
Posts: 1288
Joined: October 10th, 2016, 3:06 am

Re: Check for campaigns being loaded using [lua]

Postby gfgtdf » November 12th, 2016, 1:46 am

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.
gfgtdf
Developer
 
Posts: 910
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Postby The_Gnat » November 12th, 2016, 5:14 am

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!
User avatar
The_Gnat
 
Posts: 1288
Joined: October 10th, 2016, 3:06 am

Re: Check for campaigns being loaded using [lua]

Postby gfgtdf » November 12th, 2016, 12:22 pm

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.
gfgtdf
Developer
 
Posts: 910
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Postby Ravana » November 12th, 2016, 1:35 pm

I dont think database looks any of your Lua.
User avatar
Ravana
Moderator
 
Posts: 1458
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Check for campaigns being loaded using [lua]

Postby The_Gnat » November 12th, 2016, 9:22 pm

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!
User avatar
The_Gnat
 
Posts: 1288
Joined: October 10th, 2016, 3:06 am

Re: Check for campaigns being loaded using [lua]

Postby gfgtdf » November 12th, 2016, 11:48 pm

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.
gfgtdf
Developer
 
Posts: 910
Joined: February 10th, 2013, 2:25 pm

Re: Check for campaigns being loaded using [lua]

Postby The_Gnat » November 13th, 2016, 1:36 am

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?
User avatar
The_Gnat
 
Posts: 1288
Joined: October 10th, 2016, 3:06 am

Re: Check for campaigns being loaded using [lua]

Postby Tad_Carlucci » November 13th, 2016, 5:49 pm

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.
Tad_Carlucci
Developer
 
Posts: 202
Joined: April 24th, 2016, 4:18 pm

Re: Check for campaigns being loaded using [lua]

Postby The_Gnat » November 13th, 2016, 8:00 pm

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
User avatar
The_Gnat
 
Posts: 1288
Joined: October 10th, 2016, 3:06 am


Return to Lua Labs

Who is online

Users browsing this forum: No registered users and 1 guest