Jump to content




kind of function but not a function


  • You cannot reply to this topic
4 replies to this topic

#1 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 07 August 2012 - 02:41 PM

look, i dont really get this logic stuff:
printCentred( math.floor(h/2) + 0, ((nDifficulty == 1) and "[  EASY  ]") or "EASY" )

ok i have 2 questions :P/>
1. how does this work
2. how to write this stuff

thx in advance
wilcomega

#2 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 07 August 2012 - 04:39 PM

Well for starters, where is the actual printCentered function?
It makes more sense if you could tell us or something...

#3 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 07 August 2012 - 04:52 PM

If you are talking about how the math works, then look here: Math Library
If you are trying to learn how to make interactive menus, I suggest you look here: A Quick Guide Through Menu Making

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 07 August 2012 - 07:14 PM

printCentred( math.floor(h/2) + 0, ((nDifficulty == 1) and "[  EASY  ]") or "EASY" )
printCentred(): function call.
math.floor(h / 2) + 0: divide h by 2, floor the result and add 0.
Now the "hard" part:
((nDifficulty == 1) and "[ EASY ]") or "EASY"
This is like using an if statement. If nDifficulty equals 1, then return "[ EASY "], else return "EASY".

#5 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 08 August 2012 - 03:29 AM

Printcentred isn't a built in function. I take it you copied this code from someone else's project and want to use it to your own devices but know next to nothing about programming?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users