[allow_undo] in moveto events

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.

Re: Transfer selection from editor to wml

Postby Paulomat4 » April 3rd, 2016, 5:17 pm

No, I don't think so. Probably the easiest thing to do is to break your area up into three or four ranges that cover everything with nothing extra. Then use [filter_location] with an [or] statement for each range.

Okay, thank you. That what I'll do then. :)
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Transfer selection from editor to wml

Postby fabi » April 14th, 2016, 11:31 am

Why don't you use the editor's "area" feature and filter for the id of the area?
"Wesnoth has many strong points but team and users management are certainly not in them." -- pyrophorus
fabi
Developer
 
Posts: 1222
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Unexpected characters at line start error

Postby Paulomat4 » March 11th, 2017, 3:36 pm

Hello guys,

I haven't run into any unsolvable wml errors for quite some time until recently. I was trying to include the fire elemental from rise of the elementalist, adding the missing unit macros step by step. Unfortunately I'm getting the following error and I'm clueless on what it is supposed to mean.

Unexpected characters at line start
at ~add-ons\\dawn_of_thunder\\units\\elementals\\Fire_Elemental.cfg:19
included from ~add-ons\\dawn_of_thunder\\_main.cfg:53

here's the elementals.cfg file:
Spoiler:


I've checked the file but can't find any unexpected character. :doh: Any idea someone?
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Unexpected characters at line start error

Postby Sapient » March 11th, 2017, 4:38 pm

The error message says to check Fire_Elemental.cfg at line number 19.
Are you sure you posted the right file here?
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Sapient
Developer
 
Posts: 4354
Joined: November 26th, 2005, 7:41 am

Re: Unexpected characters at line start error

Postby zookeeper » March 11th, 2017, 4:54 pm

Whether it's the right or wrong file, that #textdomain line sure shouldn't be like that...
User avatar
zookeeper
WML Wizard
 
Posts: 9598
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Unexpected characters at line start error

Postby Paulomat4 » March 11th, 2017, 5:19 pm

The error message says to check Fire_Elemental.cfg at line number 19.

right, sry. here it is:
Spoiler:


that #textdomain line sure shouldn't be like that

You're absolutely right. I currently haven't made my campaign translatable so I figured it didn't matter. :)
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Unexpected characters at line start error

Postby zookeeper » March 11th, 2017, 7:01 pm

...and you checked those macros to make sure that calling them there that way won't result in unexpected characters at line start? Because it seems pretty clear that's the problem.
User avatar
zookeeper
WML Wizard
 
Posts: 9598
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Unexpected characters at line start error

Postby Paulomat4 » March 12th, 2017, 10:30 am

...and you checked those macros to make sure that calling them there that way won't result in unexpected characters at line start?

yup. I don't see anything wrong with them, maybe you could explain :)
here are the two custom macros that are called.
Code: Select all
#define SPECIAL_NOTES_FIRE_HEALING HP
_" This unit regenerates {HP} HP per turn when on lava terrain."
#enddef

#define SPECIAL_NOTES_WOOD_HEALING
    _" This unit regenerates 8 HP per turn by absorbing energy from burning forests. Any time this unit starts a turn on a dry forrest (non-snow), it burns the trees, leaving none left."
#enddef
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Unexpected characters at line start error

Postby Ravana » March 12th, 2017, 12:30 pm

Here you can see that it adds unquoted \n to description, so what follows is indeed unexpected.
User avatar
Ravana
Moderator
 
Posts: 1438
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Unexpected characters at line start error

Postby Pentarctagon » March 12th, 2017, 3:36 pm

You can also check <wesnoth install>/data/core/macros/special-notes.cfg for comparison.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Pentarctagon
Forum Administrator
 
Posts: 2887
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Unexpected characters at line start error

Postby Paulomat4 » March 12th, 2017, 6:33 pm

Thanks, i figured it out :) I didn't eben think about this possibility before. You can always learn something new with wesnoth.
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

[allow_undo] in moveto events

Postby Paulomat4 » March 18th, 2017, 6:03 pm

Could someone maybe clarify for me hoe [allow_undo] works?
I've been working on this event which randomly spawns a crab on a moveto event.
Code: Select all
   [event]
      name=moveto
      first_time_only=no
      [filter]
         side=1,2,3,4,5
         [filter_location]
            terrain=D*^*, Hd, D*
         [/filter_location]
      [/filter]
      [set_variable]
         name=spawnlevel
         rand=0,1,2,3
      [/set_variable]
      [if]
         {VARIABLE_CONDITIONAL spawnlevel equals 1}
         [then]
            [unit]
               type="Crab"
               x,y=$x1,$y1
               side=6
               find_vacant=yes
            [/unit]
         [/then]
      [/if]
      [if]
         {VARIABLE_CONDITIONAL spawnlevel equals 2}
         [then]
            [unit]
               type="Overgrown Crab"
               x,y=$x1,$y1
               side=6
               find_vacant=yes
            [/unit]
         [/then]
      [/if]
      [if]
         {VARIABLE_CONDITIONAL spawnlevel equals 3}
         [then]
            [unit]
               type="Giant Crab"
               x,y=$x1,$y1
               side=6
               find_vacant=yes
            [/unit]
         [/then]
      [/if]
      [allow_undo]
      [/allow_undo]
   [/event]

The Problem is that it is now impossible to undo a move on sandy terrain, even though I added [allow_undo]. How can I do this, at least if no unit is spawned?
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator
 
Posts: 674
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: [allow_undo] in moveto events

Postby gfgtdf » March 18th, 2017, 7:42 pm

The Problem is that it is now impossible to undo a move on sandy terrain, even though I added [allow_undo]. How can I do this, at least if no unit is spawned?


You can't. Requiring a random variable ([set_varialbe] rand=) is in internal change of the gamestate that cannot be undone without causing OOS. The game engine detects this and ignores your [allow_undo]


EDIT: this means you can make it undoable if you don't use rand= to determine whether a unit is spawned, you coudl for example make the unit spawned only depend on the turn and the coodinate, like:
Code: Select all
      [set_variable]
         name=spawnlevel
         value="$(($x1 + $1y + $turn_number + $turn_number +side_number) % 4)"
      [/set_variable]


of this isnt perfect, a proper hash function woudl toa better job
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: 898
Joined: February 10th, 2013, 2:25 pm

Re: [allow_undo] in moveto events

Postby Sapient » March 18th, 2017, 9:40 pm

Probably better to pick the ambush points in advance. I think there's an HttT scenario that does that, which you could look at for an example.

At one point there was a nice PseudoRandom algorithm on the wiki. But since someone deleted the page in 2008 it appears that I can no longer view it in the history.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Sapient
Developer
 
Posts: 4354
Joined: November 26th, 2005, 7:41 am

Re: [allow_undo] in moveto events

Postby gfgtdf » March 18th, 2017, 10:12 pm

Sapient wrote:At one point there was a nice PseudoRandom algorithm on the wiki. But since someone deleted the page in 2008 it appears that I can no longer view it in the history.


I dont se how this could help here, if he used that instead of of rand= in his code he'd get OOS if the actions was undone since the wml-implemented pseudo random counter would have changed. If he generated them in advance (in prestart event) he could also use rand= .
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: 898
Joined: February 10th, 2013, 2:25 pm

PreviousNext

Return to WML Workshop

Who is online

Users browsing this forum: No registered users and 5 guests