Author Topic: LUA Enchangements  (Read 1461 times)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
LUA Enchangements
« on: 1 November 2011, 22:42:47 »
Hello,
I will build some new LUA functions in near future.

Here all new functions, that are done so far:

SVN rev 2767:
displayFormattedLangText ()

SVN rev 2813:
addConsoleLangText()

SVN rev 2823:
new events:
    unitAttacked (by softcoder)
   unitAttacking (by softcoder)
 
   methods:
   lastAttackedUnitName() (by softcoder)
   lastAttackedUnit() (by softcoder)
   lastAttackingUnitName() (by softcoder)
   lastAttackingUnit() (by softcoder)
   giveKills(unit,amount)

SVN rev 2824:
new lua method (by softcoder)
lastDeadUnitCauseOfDeath(),
possible int values are:
   None = 0
   Attacked = 1
   AttackBoost = 2
   StarvedResource = 3
   StarvedRegeneration = 4
 
« Last Edit: 17 November 2011, 06:22:13 by MuwuM »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: LUA-Functions New Functions by me for testing
« Reply #1 on: 2 November 2011, 06:18:48 »
Before it's too late, I'd like to point out that for consistency, the function name should be displayFormattedLangText() (with the first letter being lowercase). I think that since all modders would have access to these functions, it's very important that the naming format of functions is the same, even if that doesn't match the individual codder's preferences.

For example, if we had most functions in the format camelCaseIsCool, but then someone makes a new function slightly different like FirstLetterCapitalized, and then maybe someone else would even get to the point of which we have i_prefer_underscores... It just gets a horrible mess for modders, who often would memorize function names based on the content only, not the casing.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: LUA-Functions New Functions by me for testing
« Reply #2 on: 2 November 2011, 19:10:59 »
I'm sorry, but I used the same capitalizion as in DisplayFormattedText(). So for me no obvious syntax exist.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: LUA-Functions New Functions by me for testing
« Reply #3 on: 3 November 2011, 01:41:19 »
I'm sorry, but I used the same capitalizion as in DisplayFormattedText(). So for me no obvious syntax exist.
Hmm... Strange. Looking at MG/Scripted Scenarios on the Wiki, every function EXCEPT DisplayFormattedText is in the format camelCaseRocks(). I think that DisplayFormattedText should work as either (and remove reference to the uppercase version on the wiki) for these same consistency issues I mentioned.

The wiki lists 52 different MegaGlest Lua functions, of which 51 are in the same consistent format, and 1 is not. Seems a bit redundant?

The majority of times (that I've seen), camel case is written with the first word all lowercase, that way a single variable (eg, "foo") will be a far more standardized lowercase instead of "Foo". Some instances it does appear with the first word capitalized as well, though.
« Last Edit: 18 June 2016, 14:49:25 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: LUA-Functions New Functions by me for testing
« Reply #4 on: 3 November 2011, 07:02:24 »
Well, I really don't have a Problem with lowercase at first letter, but maybe it would be better to make displayFormattedtext() lowercase, too.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Re: LUA-Functions New Functions by me for testing
« Reply #5 on: 3 November 2011, 17:05:15 »
Done, that stray method is now in camelcase.

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: LUA-Functions New Functions by me for testing
« Reply #6 on: 3 November 2011, 20:17:39 »
My Lua function is now camelcase, too. It's now in SVN head. 

Next function will be: addConsoleLangText() wich will be the same as addConsoleText() besides the fact, that it allows variables like displayFormattedText ().

Function is Done. Now testing. Will obvious be in next dev-version (after recent beta).

Third function will be a fuction which resolves unit-names e.g. resolveUnitName("test_unit") will return "Test Unit".

Function-list updated (new beta site added) https://docs.megaglest.org/MG/Scripted_Scenarios_Beta
« Last Edit: 18 June 2016, 12:59:52 by filux »