enclave's WML Macros questions Thread

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » June 14th, 2018, 8:05 pm

Hi everyone..
I could google or browse wiki and forums for some hours to find what I need, so I'm asking here rather, as I'm not in a rush with this..
My question may be too obvious and simple, or too complicated idk.. I just never happen to do it before.

Can I add a new side to the game, after game started, during the game?
like... [event] name=turn 5 {ADD_NEW_SIDE 6 teal bla bla bla bla} [/event]

My problem is that I want to add survival elements to a random generated map created with generator.. And in generator there is set amount of sides..
I mean so that it would work on any amount of players map randomly generated.. or on any existing default map without dedicating 1 of the sides to ai when hosting game.. bzzzzz.. hard to explain, better just ignore my reasons with the explanation.. Just imagine that I want to use the [scenario] without specifying any separate side for ai,
Spoiler:
or that I would want some AI units spawn and attack on some default 1v1 map

Just please give me all ideas you have on how it could be done? Thanks!
PS. (creating [unit] side=3 would work to the best of my memory but that unit would be passive... or somebody could confirm that after creating unit of non existing side 3 I could just [modify_side] controller=ai and everything will start to happen?)

User avatar
zookeeper
WML Wizard
Posts: 9739
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: enclave's WML Macros questions Thread

Post by zookeeper » June 14th, 2018, 11:25 pm

enclave wrote:
June 14th, 2018, 8:05 pm
Can I add a new side to the game, after game started, during the game?
No, there's no way to do that. However, you can of course make some sides invisible and empty initially.

enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » June 15th, 2018, 12:23 am

zookeeper wrote:
June 14th, 2018, 11:25 pm
enclave wrote:
June 14th, 2018, 8:05 pm
Can I add a new side to the game, after game started, during the game?
No, there's no way to do that. However, you can of course make some sides invisible and empty initially.
Yeah, but unfortunately that's not the way I would like it to work.. ideally it would be an addon that would work separately like a modification and could be used to add extra side to any default map.. (it's just to explain the complexity.. it's not really what I want from it..)

Anyone else could confirm that it's impossible? No alternative ideas/thoughts?

PS. Another question... is there a way to change time of day during the game?
like [event] name=turn 5 {CHANGE_TIME_OF_DAY_TO dusk} [/event] ?

User avatar
vultraz
Community Manager
Posts: 938
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: enclave's WML Macros questions Thread

Post by vultraz » June 16th, 2018, 4:13 am

I'm afraid adding new sides after they game has begun is indeed impossible.
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: enclave's WML Macros questions Thread

Post by Choicerer » June 25th, 2018, 10:07 pm

enclave wrote:
June 15th, 2018, 12:23 am
PS. Another question... is there a way to change time of day during the game?
like [event] name=turn 5 {CHANGE_TIME_OF_DAY_TO dusk} [/event] ?
I guess you probably found out about it, since this question is a bit old, but in case you didn't:
https://wiki.wesnoth.org/DirectActionsW ... me_area.5D

User avatar
Ravana
Moderator
Posts: 1874
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana » June 25th, 2018, 10:17 pm

You might want [replace_schedule] for that instead.

enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » June 26th, 2018, 11:33 am

Choicerer wrote:
June 25th, 2018, 10:07 pm
I guess you probably found out about it, since this question is a bit old, but in case you didn't:
https://wiki.wesnoth.org/DirectActionsW ... me_area.5D
Ravana wrote:
June 25th, 2018, 10:17 pm
You might want [replace_schedule] for that instead.
I will try both versions, thanks you both!

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: enclave's WML Macros questions Thread

Post by Choicerer » June 26th, 2018, 1:17 pm

enclave wrote:
June 26th, 2018, 11:33 am
Choicerer wrote:
June 25th, 2018, 10:07 pm
I guess you probably found out about it, since this question is a bit old, but in case you didn't:
https://wiki.wesnoth.org/DirectActionsW ... me_area.5D
Ravana wrote:
June 25th, 2018, 10:17 pm
You might want [replace_schedule] for that instead.
I will try both versions, thanks you both!
No problem, but Ravana's right. I didn't know about that one, I guess in your case it would work better.

enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » June 28th, 2018, 1:13 pm

Hi, this one will be quite advanced question, yet nothing complicated...

Could somebody explain in at least a little bit details what is the difference between loading a game and loading replay, is preload event behaving the same way for both? How exactly is it different? What differences are in storing and reloading variables and how they get reloaded, in which events, when?
Also anyone knows what happens to [options][entry] values on loading replay, is same as with loading game?

Anyone knows if there is a way to modify some kind of global variable for saving replays? For example on turn 3 I would modify some global variable and when loading replay on turn 1 it would show replay according to that global variable (not from turn 3, when the change took place)?

Also for example wesnoth.game_events.on_save reacts to saving game, but does Not react to saving replay, is there any function (even undocumented) that would react to saving replay action?

Thanks everyone in advance for any ideas, clues, hints, comments, and information..

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: enclave's WML Macros questions Thread

Post by Choicerer » June 28th, 2018, 6:34 pm

Hi, I've been quite busy programming some other thing the 2 past days, but I'm going to look into this soon, as promised.
I just wanted to say
enclave wrote: Also anyone knows what happens to [options][entry] values on loading replay, is same as with loading game?
This part must surely be referring to my hack. Actually, yesterday, while browsing through the wiki, I found out the hack's redundant, because there's a much easier way to do this, namely:

Code: Select all

if wesnoth.game_config.mp_settings.savegame then
https://wiki.wesnoth.org/LuaWML/Misc#we ... ame_config

EDIT: Read your private messages, this solution could very well fix our problem.
EDIT2:[censored]. Disregard this post. The key actually only refers to whether a Multiplayer game that was hosted was a reloaded game or a new game.
EDIT3:Nice auto-censoring feature, I think that's new!


EDIT4:Check your mail. I've actually found some time and managed to get it to work.

enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » October 16th, 2018, 8:22 pm

Hello,

I have a question... about nested events inside events.. something like that..

I have [event] name=start

which has [if] variable=1 then
[event] name=die

inside die event it has 2 other events:
[event] name=moveto id=dead_king_moveto_side$unit.side
[event] name=side $unit.side turn

My question is how to make event name=side $unit.side turn be shown in debug list of events as name=side 1 turn (which is the side of dead unit)

I tried different ways with delay variable substitution and with $| signs... i can't get it to work the way I want.. its either nothing or $unit.side (while inside die event everything else is working perfectly fine.. but the events appear corrupted..

please help!

User avatar
Ravana
Moderator
Posts: 1874
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana » October 16th, 2018, 8:40 pm

I doubt you can change how it appears in debug list. Does the event work as expected?

enclave
Posts: 885
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » October 16th, 2018, 8:48 pm

hmm you think it will work as it is... thats interesting idea.. i was sure if its looking messed up in debug list then it wont work...
I will check to make sure it doesnt work or works... but it didn't work the first time.. i will just try some more things... maybe i try to change that die event into something like die $unit.side ... and if it appear fine in list then i will know where to look deeper...

hmm indeed it appears also corrupted with $ things... then it must be me doing other mistake in code somewhere possibly...
thanks for advice

Ok i have tested.. and it seems like (for now.. I will have to investigate more... and make tutorial for others.. because wiki is like always bloody short and has super basic example that nobody would ever use in real world)

Code: Select all

if you have [event] start  
   then inside  [event] die 
      then inside [event] moveto
if you would want to use $unit.side from die event inside moveto event, then you would have to use $unit.side
if you would want to use $unit.side from moveto event inside moveto event, then you would have to use $|unit.side

But it will only work if you make sure that your moveto event has delayed_variable_substitution=no (default is yes, when it's absent)
If you want to put [event] name=side $unit.side turn refresh (which would use $unit.side from die event, then you would also need to make sure that your turn refresh has delayed_variable_substitution=no (while die event and start event has it set to "yes" or simply don't have it)

Hopefully I will later make a small tutorial with examples to make it clear for others, and including myself too... because I don't really 100% get it yet.. especially if there was more events inside events.. for now I haven't completed the code that I needed... once I done it maybe I could say that I understand it well..
Ravana wrote:
October 16th, 2018, 8:40 pm
I doubt you can change how it appears in debug list.
I have tested it and can say for sure that if you put:

Code: Select all

[event]
			name=side $unit.side turn
			first_time_only=yes
			delayed_variable_substitution=no
Then it will appear as "side_2_turn" in the debug inspection list of events. So it will not have dollar signs "$" in it. It does not work with dollar signs as intended, they are treated like literals or similar. So if anyone see dollar signs in event list it most probably means u need to change your code as it wasnt translated properly.

Post Reply