(response to the proposal from Kess) |
(i think that is what Kess meant) |
||
Line 58: | Line 58: | ||
| tmw.chr_get_exp() || get_experience() | | tmw.chr_get_exp() || get_experience() | ||
|- | |- | ||
| tmw.chr_give_exp() || | | tmw.chr_give_exp() || add_experience() | ||
|- | |- | ||
| tmw.exp_for_level() || get_experience_needed() | | tmw.exp_for_level() || get_experience_needed() |
Revision as of 19:29, 23 February 2009
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/oron_
- 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.
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() | message() |
do_choice() | choice() or 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() |
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() | |
schedule_every() | |
on_death() | |
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:
- 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).
- 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)
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)