From ef4175cdfae6a6981738e15cb0009d8e47ed7c80 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 15 Apr 2013 21:24:55 +0200 Subject: Moved functions to entity members where appropriate Some functions were skipped for now because they may need a new name or change of behavior. Changes: chr_warp entity:warp chr_get_inventory entity:inventory chr_inv_change entity:inv_change chr_inv_count entity:inv_count chr_get_equipment entity:equipment chr_equip_slot entity:equip_slot chr_equip_item entity:equip_item chr_unequip_slot entity:unequip_slot chr_unequip_item entity:unequip_item chr_get_level entity:level chr_get_exp entity:xp chr_give_exp entity:give_xp chr_get_rights entity:rights chr_set_hair_style entity:set_hair_style chr_get_hair_style entity:hair_style chr_set_hair_color entity:set_hair_color chr_get_hair_color entity:hair_color chr_get_kill_count entity:kill_count chr_give_special entity:give_special chr_has_special entity:has_special chr_take_special entity:take_special chr_set_special_recharge_speed entity:set_special_recharge_speed chr_get_special_recharge_speed entity:special_recharge_speed chr_set_special_mana entity:set_special_mana chr_get_special_mana entity:special_mana chr_kick entity:kick exp_for_level xp_for_level monster_get_id entity:monster_id monster_change_anger entity:change_anger monster_drop_anger entity:drop_anger monster_get_angerlist entity:angerlist being_apply_status entity:apply_status being_remove_status entity:remove_status being_has_status entity:has_status being_set_status_time entity:set_status_time being_get_status_time entity:status_time being_get_gender entity:gender being_set_gender entity:set_gender being_type entity:type being_walk entity:walk being_say entity:say being_damage entity:damage being_heal entity:heal being_get_name entity:name being_get_action entity:action being_set_action entity:set_action being_get_direction entity:direction being_set_direction entity:set_direction being_apply_attribute_modifier entity:apply_attribute_modifier being_remove_attribute_modifier entity:remove_attribute_modifier being_set_base_attribute entity:set_base_attribute being_get_modified_attribute entity:modified_attribute being_get_base_attribute entity:base_attribute being_set_walkmask entity:set_walkmask being_get_walkmask entity:walkmask being_get_mapid entity:mapid chat_message entity:message being_register entity:register chr_shake_screen entity:shake_screen chr_create_text_particle entity:show_text_particle - entity:position posX entity:x posY entity:y monster_get_name monsterclass:name item_get_name itemclass:name --- example/scripts/crafting.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'example/scripts/crafting.lua') diff --git a/example/scripts/crafting.lua b/example/scripts/crafting.lua index 1a7d0e54..dac8bf72 100644 --- a/example/scripts/crafting.lua +++ b/example/scripts/crafting.lua @@ -9,14 +9,13 @@ local function craft_strict(ch, recipe) if (recipe[1].id == 8 and recipe[1].amount == 2 and -- has two iron recipe[2].id == 9 and recipe[2].amount == 1) -- and one wood then - chr_inv_change(ch, - 8, -2, --take away the iron - 9, -1, --take away the wood - 5, 1 ) -- give a sword - chat_message(ch, "You've crafted a sword") + ch:inv_change(8, -2, --take away the iron + 9, -1, --take away the wood + 5, 1 ) -- give a sword + ch:message("You've crafted a sword") return end - chat_message(ch, "This wouldn't create anything useful") + ch:message("This wouldn't create anything useful") end -- this turns multiple occurences of the same item into one by adding up @@ -56,14 +55,13 @@ local function craft_lax(ch, recipe) if (recipe[1].id == 8 and recipe[1].amount >= 2 and -- has at least two iron recipe[2].id == 9 and recipe[2].amount >= 1) -- and at least one wood then - chr_inv_change(ch, - 8, -2, -- take away the iron - 9, -1, -- take away the wood - 5, 1 ) -- give a sword - chat_message(ch, "You've crafted a sword") + ch:inv_change(8, -2, -- take away the iron + 9, -1, -- take away the wood + 5, 1 ) -- give a sword + ch:message("You've crafted a sword") return end - chat_message(ch, "This wouldn't create anything useful") + ch:message("This wouldn't create anything useful") end -- This function is registered with the game engine to use when a character @@ -80,7 +78,7 @@ local function craft(ch, recipe) -- uncomment one (but not both!) of the following three lines to enable the -- example crafting systems - chat_message(ch, "There is no crafting in this game world.") + ch:message("There is no crafting in this game world.") --craft_strict(ch, recipe) --craft_lax(ch, recipe) end -- cgit v1.2.3-70-g09d2