From The Mana World
Revision as of 15:09, 22 February 2009 by Kess (talk | contribs) (Suggestions to improve functions for scripters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 formated like this.
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() set_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)

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)