#Is this how you end a function?

9 messages · Page 1 of 1 (latest)

lyric crest
#
if(info2 != ''){
  text.add(3, [
    Text.of(' '+info2).aqua()
  ])
} else {return}

basically there are some tooltips that only has 2 texts and i want it to end there so that it will not put undefined in the game

rich kilnBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

lyric crest
#
let tip = (item, desc, info1, info2, info3) =>{
  event.addAdvanced([item],(item, advanced, text) => {
    text.add(1, [
      Text.of(desc).gray()
    ])
    text.add(2, [
      Text.of(' '+info1).aqua()
    ])
    if(info2 != ''){
       text.add(3, [
         Text.of(' '+info2).aqua()
       ])
    } else {return}
       text.add(4, [
          Text.of(' '+info3).aqua()
        ])
    })
}
tip(CR+'water_wheel', 'Minimum RPM:', '8')
tip(CR+'large_water_wheel', 'Minimum RPM:', '4')
tip(CRN+'stirling_engine', 'RPM at ˚T/s:',  '8 at 50.0 ˚T/s', '16 at 100.0 ˚T/s')
tip(CRN+'heater', 'Heat at ˚T/s:', 'Passive at 50.0 ˚T/s', 'Heated at 100.0 ˚T/s', 'Super-heated at 400.0 ˚T/s')
#

this is the full code

stray frigate
#

there is a better way to do it

#

pass the info as array and loop add that

lyric crest
#

i may need an example script because i didnt do loop yet in java tho i understand how it works. Tried looking at example scripts and support but nada

lyric crest
#
let tip = (item, desc, info1, info2, info3) =>{
        event.addAdvanced([item], (item, advanced, text) => {
            text.add(1, [
                Text.of(desc).gray()
            ])
            text.add(2, [
                Text.of(' '+info1).aqua()
            ])
            if(info2 != undefined){
                text.add(3, [
                    Text.of(' '+info2).aqua()
                ])
            } else {return}
            if(info3 != undefined) {
                text.add(4, [
                    Text.of(' '+info3).aqua()
                ])
            } else {return}
        })
    }
    tip(CR+'water_wheel', 'Minimum RPM:', '8')
    tip(CR+'large_water_wheel', 'Minimum RPM:', '4')
    tip(CRN+'stirling_engine', 'RPM at ˚T/s:',  '8 at 50.0 ˚T/s', '16 at 100.0 ˚T/s')
    tip(CRN+'heater', 'Heat at ˚T/s:', 'Passive at 50.0 ˚T/s', 'Heated at 100.0 ˚T/s', 'Super-heated at 400.0 ˚T/s')
#

i went with this instead