|
Post by parduz on May 7, 2018 21:18:14 GMT
I have this field: a_text_paper: left: 0 top: {card.bottombar_Top + 1} right: {card_real_width} bottom: {card_real_height} z index: -9 render style: image image: /mygame.mse-include/TextPaperBackground.png
This is'nt working if i keep that + 1 (the image does not appear), instead it works if i remove + 1. Now: card.bottombar_Top contains " 200", and trying in the console to evaluate the expression, i get " 2001" as result  . Guessing that this to what Top is set, I'd like to understand why it takes + 1 as a string; I would write {card.bottombar_Top + "1"} if I wanted 1 as a string. What should I write to get " 201" as the Top of that field? Or is the console "wrong" and the problem is of a different kind?
|
|
|
Post by cajun on May 7, 2018 21:36:55 GMT
Try one of the following:
card.bottombar_Top+1 ## no spaces /should/ force it to work as a number instead of string to_number(card.bottombar_Top) +1 ## converts to number if it is a string card.bottombar_Top - (-1) ## minus always works as a number
|
|
|
Post by parduz on May 7, 2018 22:22:54 GMT
card.bottombar_Top+1 ## no spaces /should/ force it to work as a number instead of string Nope to_number(card.bottombar_Top) +1 ## converts to number if it is a string Yep, this works. Now: is this behaviour expected? If yes, what's the rule i have to follow? or it is a bug? 'cause i have a lot of fields like this: im_W: left: {card_real_width + large_field_margin + fields_stardard_width + 10 + fields_stardard_width + 20} top : {full_row_h*2} width: {fields_stardard_width/2} height: {fields_row_h} alignment: bottom center font: name: {styling.entry_font} size: {fields_font_h} z index: 1
and now i think that the only reason that works is 'cause the variables are declared as numbers (like fields_stardard_width:= 50 ), not because +10 is different than +"10". Oh, thanks for your fast answer!
|
|
|
Post by cajun on May 7, 2018 22:36:18 GMT
Yea my guess would be your variables are all already numbers but the card field is acting as a string. I've seen fields act as numbers but now that I think about it might be a combination of the minus-conversion trick and using == instead of ===.
|
|