Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard of Case Sensitivity #685

Closed
Emistry opened this issue Aug 31, 2015 · 2 comments
Closed

Standard of Case Sensitivity #685

Emistry opened this issue Aug 31, 2015 · 2 comments
Labels
component:scripts Affecting the scripts and NPCs status:wontfix The issue can't/won't be fixed type:question

Comments

@Emistry
Copy link
Member

Emistry commented Aug 31, 2015

What is the exact standard of case-sensitivity of letters in Hercules ?
case-sensitive

In my case :

Detected Type Correct case ?
.size = 1; npc variable .Size = 1;
.map$ = "prontera"; npc variable .MAP$ = "prontera";
npc_talk( param ); external function NPC_TALK( param );

However, these only happened to some of it only.
I actually got alot of npc variable that doesn't follow the capital-front-letter format, same goes for lower-case naming for external function.
But all of these are not detected during startup? or its set to be ignored ? or its actually correctly named, but then why those above are detected as wrong case ?

@MishimaHaruna
Copy link
Member

First off, the general case preference is:

  • Variables: all lowercase, words separated by _ (example: .@my_variable, .another_variable)
  • Functions: PascalCase, prefixed with F_ if the function is global (example: F_Navi, F_InsertComma)
  • Labels (events such as doevent): PascalCase, prefixed with On (example: OnDisable, OnMyEvent)
  • Labels (subroutines, i.e. callsub): PascalCase, prefixed with S_ (example: S_CheckQuestStatus)
  • Builtin functions (defined in source): all lowercase, words optionally separated by _ (example: instance_check_guild, completequest)
  • Constants (item names): Capitalized words, separated by _ (example: Red_Potion)
  • Constants (mob names): All caps, words separated by _ (example: POISON_SPORE)
  • Constants (misc constants, const.txt): Depends on the origin and purpose, some capitalized, some all caps, some lowercase.

But this isn't followed by all scripts.

The messages "Maybe you meant" aren't necessarily correct. It uses heuristics to guess that you might have typed a variable with the wrong case, based solely on what it found before. If a script has both Foo and foo, it accepts the first one, regardless of which it is, and whenever it finds the other spelling, it warns that you might have typed it wrong.

The .Size variable is in npc/custom/woe_controller.txt, and it should eventually be changed to .size, when we'll apply those above rules to the scripts in our repo (or remove the script altogether, since the custom scripts aren't meant to be in the main repository, but we'll likely use a separate one for custom scripts and plugins)

The NPC_TALK function isn't part of the repository (I'm guessing custom code). What it's trying to tell you there is that you have both variants, NPC_TALK and npc_talk (and I'd advise to avoid using NPC_TALK, it's ugly)

@AnnieRuru
Copy link
Contributor

This issue is pinned temporary, until someone corporate this into coding style
https://github.com/HerculesWS/Hercules/wiki/Coding-Style#chapter-4-naming
my english too sux to write a guide

@Jedzkie Jedzkie unpinned this issue Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:scripts Affecting the scripts and NPCs status:wontfix The issue can't/won't be fixed type:question
Projects
None yet
Development

No branches or pull requests

3 participants