PlaceholderAPI / Javascript-Expansion

Adds javascript placeholders
GNU General Public License v3.0
22 stars 24 forks source link

Contributes with converter between cm to ,km, m, cm (cred too BlitzZzZzZzZ) #31

Closed broken1arrow closed 3 years ago

broken1arrow commented 3 years ago

You follow the normal steps too add it and scrips is under plugins/placeholderAPI/javascripts (and name the file .js)

Is for %statistic_walk_one_cm% get it in nice human reading format (need improvements, can´t choose placeholders to display only one of the km,m and cm. but you can remove/change if you do not want to see cm and / or m ).

var cm = parseInt("%statistic_walk_one_cm%")
var type = args[0]

function format() {
  var m = parseInt(cm/100)
  var km = parseInt(m/1000)
  m = parseInt(m%1000)
  cm = parseInt(cm%100)
  return km + " km " + m + " m " + cm + " cm"
}

format()

And if you use cmi or similar plugin for ranks and want all travel static in one placeholder (like in the deluxe menu) has i modify it (sadly no placeholder for walk in or on water so get 100% exactly).

This is my modified version of the script and I removed cm (is not 100% done is work on progress).

var num1 = '%statistic_walk_one_cm%',
    num2 = '%statistic_sprint_one_cm%',
    num3 = '%statistic_swim_one_cm%',
    num4 = '%statistic_fly_one_cm%',
    num5 = '%statistic_aviate_one_cm%',
    num6 = '%statistic_boat_one_cm%',
    num7 = '%statistic_horse_one_cm%',
    num8 = '%statistic_pig_one_cm%',
    num9 = '%statistic_fall_one_cm%',
    num10 = '%statistic_climb_one_cm%',
    num11 = '%statistic_minecart_one_cm%',
    num12 = '%statistic_crouch_one_cm%';

var sum = (+num1) + (+num2) + (+num3) + (+num4) + (+num5) + (+num6) + (+num7) + (+num8) + (+num9) + (+num10) + (+num11) + (+num12);
var cm = parseInt(sum)
var type = args[0]

function format() {
  var m = parseInt(cm/100)
  var km = parseInt(m/1000)
  m = parseInt(m%1000)
  cm = parseInt(cm%100)
  return km + " km " + m + " m "
}

format()
BlitzOffline commented 3 years ago

closing this. Can't really see the use for it. Most people can do this in a few minutes.