From The Mana World

How about changing some function names?

The following is a suggestion/proposal of name changes, tried to be seen from the eyes of an NPC/quest scripter; no abbreviations, natural word order, colloquial words. I especially do not like the tmw prefix, as from this perspective the script is supposed to be used in the tmw namespace. (I would either remove it altogether or making the namespace automatic for scripts. That is, without the scripter having to “localize” the namespace.)

A standard set of prefixes should be used consistently, perhaps:

create_
creates something (new x)
remove_
removes something (delete x)
get_
gets something (x)
set_
sets something to something (x = y)
add_
adds something to something (x = x + y)
subtract_
subtracts something from something (x = x - y)
at_ and/or on_
sets up a conditional check

Maybe every set_ function could have corresponding add_ and subtract_ functions. Would not add to the functionality, but might ease scripting and make it more transparent.

Unchanged functions are on a yellowish background.

Current name Proposed name
create_npc() create_npc()
tmw.monster_create() create_monster()
tmw.trigger_create() create_trigger()
tmw.effect_create() create_effect()
do_message() npc_message() or wait_message()
do_choice() npc_choice() or npc_menu() or wait_choice() or wait_menu()
tmw.being_say() say()
tmw.chatmessage() log_to_chat() or chatlog()
tmw.npc_trade() trade()
tmw.chr_invcount() get_inventory()
tmw.chr_invchange() set_inventory()
tmw.chr_money() get_money()
tmw.chr_money_change() set_money()
tmw.being_get_name() get_name()
tmw.being_type() get_being_type()
tmw.chr_warp() warp_character()
tmw.posx() get_x()
tmw.posy() get_y()
tmw.being_get_attribute() get_attribute()
tmw.chr_get_exp() get_experience()
tmw.chr_give_exp() add_experience()
tmw.exp_for_level() get_experience_needed()
tmw.char_get_hair_color() get_hair_color()
tmw.char_set_hair_color() set_hair_color()
tmw.char_get_hair_style() get_hair_style()
tmw.char_set_hair_style() set_hair_style()
tmw.chr_get_rights() get_rights()
get_quest_var() get_quest_variable()
tmw.chr_set_quest() set_quest_variable()
tmw.being_walk() walk() or walk_being()
tmw.being_damage() damage() or damage_being()
tmw.get_beings_in_circle() get_beings_inside_circle() or get_beings_in_circle()
atinit() at_initialization() or at_init()
schedule_in() scehedule_in()
schedule_every() schedule_every()
on_death() on_death()
on_remove() on_remove()
tmw.get_map_id() get_map()

✎ Kess☽ 15:09, 22 February 2009 (UTC)

Good idea, but there is something you have to consider:
  1. The "being_" or "chr_" prefixes are important because not every function is available for every kind of object. Trying to call warp with a monster, for example, could cause a cryptic error message in the best case and a server crash in the worst. I would suggest to use this restriction as a suffix of the function name (warp_chr, damage_being etc).
  2. Some functions may not be called from scripts which are not NPC scripts because otherwise they freeze the game server until a response from a client or the accountserver comes. Most (but not all) of these functions currently have the "do_" prefix. I would suggest to replace this with "wait_".
--Crush2 18:38, 23 February 2009 (UTC)
Fair considerations. I’ve updated the table above. Though I am open for further suggestions on the wait_ prefix, as it is not natural sounding, at least not to me. But if they only are used in NPC scripts, why not simply use an npc_ prefix? I am uncertain of a few cases (would being functions really need _being?, would rather obvious character functions need _chr/_char/_character?) but I will think of them during the night. ✎ Kess☽ 19:59, 23 February 2009 (UTC)

Usage questions and ideas

Perhaps tmw.chatmessage() · chatlog() · log_to_chat() could take chat channel as an optional argument? ✎ Kess☽ 15:09, 22 February 2009 (UTC)