How to use [floating_text]
Moderator: Forum Moderators
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.
How to use [floating_text]
I'm trying to make a floating text but it seems that it isn't working for me. My idea is to make a floating text similar to the healing one (camera is moved to location, text is spawned, healing sound is played, text is unspawned), but it isn't working, the [scroll_to_unit] and [floating_text] aren't working.
It doesn't do nothing.
Code: Select all
[event]
name=side turn
(....)
[scroll_to_unit]
x,y=$units[$index].x,$units[$index].y
immediate=yes
for_side=$side_number
[/scroll_to_unit]
[sound]
name=gold.wav
[/sound]
[floating_text]
x,y=$units[$index].x,$units[$index].y
text="<span color='#cccc33'>" + $(round($units[$index].abilities.dummyminer.value*{MULT})) + "</span>"
[/floating_text]
[gold]
amount=$(round($units[$index].abilities.dummyminer.value*{MULT}))
side=$side_number
[/gold]
[/event]
Re: How to use [floating_text]
Does this work?
Code: Select all
text="<span color='#cccc33'>" + _ "$(round($units[$index].abilities.dummyminer.value*{MULT}))|" + "</span>"
Re: How to use [floating_text]
Sadly no . What does "|"?SFault wrote:Does this work?Code: Select all
text="<span color='#cccc33'>" + _ "$(round($units[$index].abilities.dummyminer.value*{MULT}))|" + "</span>"
Re: How to use [floating_text]
| separates the variable from the following string e.g. "you found 10 $weapon_type|s"
Is the [gold] working alright? It looks like you are doing multiplying with *. I'm no pro but I think you need to store your dummyminer.value into variable and the use multiply={MULT} on it (assuming it's some macro for a number) and then use that variable in the string.
Is the [gold] working alright? It looks like you are doing multiplying with *. I'm no pro but I think you need to store your dummyminer.value into variable and the use multiply={MULT} on it (assuming it's some macro for a number) and then use that variable in the string.
Code: Select all
[set_variable]
name=dummyminer_value
multiply={MULT}
[/set_variable]
Re: How to use [floating_text]
The multiplying is working because [gold] works (I get the gold each turn). But the floating text doesn't.
Last edited by Enderlook on January 25th, 2018, 1:50 pm, edited 1 time in total.
Re: How to use [floating_text]
What is "round()"? Is it a variable you also want to multiply with...? Or you just want the value to be rounded? It doesn't work this way, if you want to round it, you first need to calculate this value in a WML variable, then use the ceil/floor attributes of the [set_variables] tag.
Or just leave it, why do you expect non-integers? I think this should work without problems:
Also, make sure the variable is inside "" with the text attribute, you don't need to concut it with + signs. (this could also be the problem).
Or just leave it, why do you expect non-integers? I think this should work without problems:
Also, make sure the variable is inside "" with the text attribute, you don't need to concut it with + signs. (this could also be the problem).
Code: Select all
[floating_text]
x,y=$units[$index].x,$units[$index].y
text="<span color='#cccc33'> $($units[$index].abilities.dummyminer.value*{MULT}) </span>"
[/floating_text]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: How to use [floating_text]
Oh, silly me then
I still think it should be between ""-s though, maybe that solves it?
I still think it should be between ""-s though, maybe that solves it?
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: How to use [floating_text]
Sadly, It keeps not working . The text doesn't appear.WhiteWolf wrote:Oh, silly me then
I still think it should be between ""-s though, maybe that solves it?
Re: How to use [floating_text]
You haven't said whether [floating_text] doesn't work, or whether only one very particular complicated way to use [floating_text] doesn't work. There's kind of a huge difference between those two.
Does that work? If it does, then the tag works all right, and you're just using it wrong, somehow. My guess: with very high likelyhood the mistake is in the code you excluded.
Code: Select all
[event]
name=side turn
first_time_only=no
[floating_text]
x,y=5,5
text="testing123"
[/floating_text]
[/event]
Re: How to use [floating_text]
You have right, if I put your code it works, but if I use [floating_text] in my code, it doesn't .
But I don't understand why it wouldn't work. The [gold] tag is below the [floating_text] and works, and the [message] tag (just for testing) is above the [floating_text] and also works. The only two tags that aren't working are [floating_text] and [scroll_to_unit].
Where $units is:
But I don't understand why it wouldn't work. The [gold] tag is below the [floating_text] and works, and the [message] tag (just for testing) is above the [floating_text] and also works. The only two tags that aren't working are [floating_text] and [scroll_to_unit].
Code: Select all
#define GET_GOLD MULT
[if]
[variable]
name=units[$index].attacks_left
greater_than=0
[/variable]
[then]
[message]
message=$(max(floor($units[$index].abilities.NE_miner.value*{MULT}),1))
[/message]
[scroll_to_unit]
x,y=$units[$index].x,$units[$index].y
immediate=yes
for_side=$side_number
[/scroll_to_unit]
[sound]
name=gold.ogg
[/sound]
[floating_text]
x,y=$units[$index].x,$units[$index].y
text="<span color='#cccc33'>$(max(floor($units[$index].abilities.NE_miner.value*{MULT}),1))</span>"
[/floating_text]
[gold]
amount=$(max(floor($units[$index].abilities.NE_miner.value*{MULT}),1))
side=$side_number
[/gold]
[/then]
[/if]
#enddef
Code: Select all
[store_unit]
[filter]
side=$side_number
ability=NE_miner
[filter_location]
terrain=Mm,Md,Ms,Hh,Hhd,Hd,Ha,*^Vu,*^Vud,Uh,*^Dr,*^Es
[/filter_location]
[/filter]
variable=units
[/store_unit]
{FOREACH units index}
Re: How to use [floating_text]
I discover I can use [unstore_unit] to make a text appear... and it's works. Shall I use this instead??
Re: How to use [floating_text]
Note: I update Wesnoth to 1.13.10 and now [floating_text] works .