gui2 and replays

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

Moderator: Forum Moderators

Post Reply
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

gui2 and replays

Post by gfgtdf »

hi i wrote a scenario that uses a lot of lua and also some gui2 codes.

the problem is that when i see the replay. the replay shows me the gui2 dialog.
and because the dialog influences the game, the replay will be detroyed if i dont make exactly the same coiches as in the original.

is threre any way to avoid this?
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.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: gui2 and replays

Post by Anonymissimus »

I think wesnoth.synchronize_choice should work around that. That is, it should store the choice that was made in the replay and retrieve it once the dialog would have opened in an actual game. But IIRC I never tested it with a replay. Its documentation mentions replays at least.
You need to wire input-querying lua dialogs into this function anyway in case that you have a MP scenario/campaign, in order to avoid OOS errors.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: gui2 and replays

Post by gfgtdf »

ty, i suppose, that is was i was looking for, i haven looked at synchronize_choice becaus i thought it was oonly for muliplayer stuff.
sicne right now the dialog is changing an existent object instead of returning a new object, it may need some greater changes but it is doable.

but i have another quiestion about synchronize_choice: if i call a function that uses synchronize_choice in a synchronize_choice context, (so that in a kind of double synchronize_choice context) would that cause problems?
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.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: gui2 and replays

Post by Anonymissimus »

gfgtdf wrote:sicne right now the dialog is changing an existent object instead of returning a new object, it may need some greater changes but it is doable.
You need to split the data-gathering part of the code into an own function which is passed to sync_choice, let it return the data, and *only then* modify the gamestate with that data after the sync_choice call has run out. Make sure the data passed through is in the form of a wml table or otherwise it fails without an error. It also works only in turn 1 and later events.
but i have another quiestion about synchronize_choice: if i call a function that uses synchronize_choice in a synchronize_choice context, (so that in a kind of double synchronize_choice context) would that cause problems?
No idea. Perhaps something about your design or understanding is wrong if you feel the need to do this.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Post Reply