• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Food System (Only explain to me)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
This is my script of food, can someone explain to me?
1. Where I change seconds of each food?
2. In tibiarl how many SECONDS OF FOOD player can eat to be FULL? Where I change it in this script?

LUA:
local FOODS =
{
	[2362] = {8, "Crunch."},
	[2666] = {15, "Munch."},
	[2667] = {12, "Munch."},
	[2668] = {10, "Mmmm."},
	[2669] = {17, "Munch."},
	[2670] = {4, "Gulp."},
	[2671] = {30, "Chomp."},
	[2672] = {60, "Chomp."},
	[2673] = {5, "Yum."},
	[2674] = {6, "Yum."},
	[2675] = {13, "Yum."},
	[2676] = {8, "Yum."},
	[2677] = {1, "Yum."},
	[2678] = {18, "Slurp."},
	[2679] = {1, "Yum."},
	[2680] = {2, "Yum."},
	[2681] = {9, "Yum."},
	[2682] = {20, "Yum."},
	[2683] = {17, "Munch."},
	[2684] = {8, "Crunch."},
	[2685] = {6, "Munch."},
	[2686] = {9, "Crunch."},
	[2687] = {2, "Crunch."},
	[2688] = {9, "Munch."},
	[2689] = {10, "Crunch."},
	[2690] = {3, "Crunch."},
	[2691] = {8, "Crunch."},
	[2792] = {6, "Munch."},
	[2793] = {9, "Munch."},
	[2695] = {6, "Gulp."},
	[2696] = {9, "Smack."},
	[2787] = {9, "Munch."},
	[2788] = {4, "Munch."},
	[2789] = {22, "Munch."},
	[2790] = {30, "Munch."},
	[2791] = {30, "Munch."},
	[2792] = {6, "Munch."},
	[2794] = {3, "Munch."},
	[2795] = {36, "Munch."},
	[2796] = {5, "Munch."},
	[2793] = {9, "Munch."},
	[5097] = {4, "Yum."},
	[6125] = {8, "Gulp."},
	[6278] = {10, "Mmmm."},
	[6279] = {15, "Mmmm."},
	[6393] = {12, "Mmmm."},
	[6394] = {15, "Mmmm."},
	[6501] = {20, "Mmmm."},
	[6541] = {6, "Gulp."},
	[6542] = {6, "Gulp."},
	[6543] = {6, "Gulp."},
	[6544] = {6, "Gulp."},
	[6545] = {6, "Gulp."},
	[6569] = {1, "Mmmm."},
	[6574] = {4, "Mmmm."},
	[7158] = {15, "Munch."},
	[7159] = {13, "Munch."},
	[7372] = {7, "Yum."},
	[7373] = {7, "Yum."},
	[7374] = {7, "Yum."},
	[7375] = {7, "Yum."},
	[7376] = {7, "Yum."},
	[7377] = {7, "Yum."},
	[7909] = {4, "Crunch."},
	[8838] = {7, "Gulp."},
	[8839] = {5, "Yum."},
	[8840] = {2, "Yum."},
	[8841] = {3, "Urgh."},
	[8842] = {3, "Munch."},
	[8843] = {3, "Crunch."},
	[8844] = {3, "Gulp."},
	[8845] = {2, "Munch."},
	[8847] = {11, "Yum."}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local food = FOODS[item.itemid]
	if(not food) then
		return false
	end
 
	if((getPlayerFood(cid) + food[1]) >= 400) then
		doPlayerSendCancel(cid, "You are full.")
		return true
	end
 
	doPlayerFeed(cid, food[1] * 4)
	doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	return true
end
 
What is better?

Seconds
LUA:
local FOODS, MAX_FOOD = {
        [2666] = {180, "Munch."},
        [2667] = {144, "Munch."},
	[2668] = {120, "Mmmm."},
        [2669] = {204, "Munch."},
        [2670] = {48, "Gulp."},
        [2671] = {360, "Chomp."},
	[2672] = {720, "Chomp."},
        [2673] = {60, "Yum."},
        [2674] = {72, "Yum."},
        [2675] = {156, "Yum."},
	[2676] = {96, "Yum."},
        [2677] = {12, "Yum."},
        [2678] = {216, "Slurp."},
        [2679] = {12, "Yum."},
	[2680] = {24, "Yum."},
        [2681] = {108, "Yum."},
        [2682] = {240, "Yum."},
        [2683] = {204, "Munch."},
	[2684] = {60, "Crunch."},
        [2685] = {72, "Munch."},
        [2686] = {108, "Crunch."},
        [2687] = {24, "Crunch."},
	[2688] = {24, "Mmmm."},
        [2689] = {120, "Crunch."},
        [2690] = {36, "Crunch."},
        [2691] = {96, "Crunch."},
	[2695] = {72, "Gulp."},
        [2696] = {108, "Smack."},
        [8112] = {108, "Urgh."},
        [2787] = {270, "Crunch."},
	[2788] = {48, "Munch."},
        [2789] = {264, "Munch."},
        [2790] = {360, "Crunch."},
        [2791] = {108, "Crunch."},
	[2792] = {72, "Crunch."},
        [2793] = {144, "Crunch."},
        [2794] = {36, "Crunch."},
        [2795] = {432, "Crunch."},
	[2796] = {60, "Crunch."},
        [5097] = {48, "Yum."},
        [5678] = {96, "Gulp."},
        [6125] = {96, "Gulp."},
	[6278] = {120, "Mmmm."},
        [6279] = {180, "Mmmm."},
        [6393] = {144, "Mmmm."},
        [6394] = {180, "Mmmm."},
	[6501] = {240, "Mmmm."},
        [6541] = {72, "Gulp."},
        [6542] = {72, "Gulp."},
        [6543] = {72, "Gulp."},
        [6544] = {72, "Gulp."},
        [6545] = {72, "Gulp."}
}, 1200

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 6280) then
		if(fromPosition.x == CONTAINER_POSITION) then
			fromPosition = getThingPosition(cid)
		end

		doCreatureSay(cid, getPlayerName(cid) .. " blew out the candle.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, item.itemid - 1)

		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		return true
	end

	local food = FOODS[item.itemid]
	if(food == nil) then
		return false
	end

	local size = food[1]
	if(getPlayerFood(cid) + size > MAX_FOOD) then
		doPlayerSendCancel(cid, "You are full.")
		return true
	end

	doPlayerFeed(cid, size)
	doRemoveItem(item.uid, 1)

	doCreatureSay(cid, food[2], TALKTYPE_MONSTER)
	return true
end

or %?
LUA:
local FOODS =
{
	[2362] = {8, "Crunch."},
	[2666] = {15, "Munch."},
	[2667] = {12, "Munch."},
	[2668] = {10, "Mmmm."},
	[2669] = {17, "Munch."},
	[2670] = {4, "Gulp."},
	[2671] = {30, "Chomp."},
	[2672] = {60, "Chomp."},
	[2673] = {5, "Yum."},
	[2674] = {6, "Yum."},
	[2675] = {13, "Yum."},
	[2676] = {8, "Yum."},
	[2677] = {1, "Yum."},
	[2678] = {18, "Slurp."},
	[2679] = {1, "Yum."},
	[2680] = {2, "Yum."},
	[2681] = {9, "Yum."},
	[2682] = {20, "Yum."},
	[2683] = {17, "Munch."},
	[2684] = {8, "Crunch."},
	[2685] = {6, "Munch."},
	[2686] = {9, "Crunch."},
	[2687] = {2, "Crunch."},
	[2688] = {9, "Munch."},
	[2689] = {10, "Crunch."},
	[2690] = {3, "Crunch."},
	[2691] = {8, "Crunch."},
	[2792] = {6, "Munch."},
	[2793] = {9, "Munch."},
	[2695] = {6, "Gulp."},
	[2696] = {9, "Smack."},
	[2787] = {9, "Munch."},
	[2788] = {4, "Munch."},
	[2789] = {22, "Munch."},
	[2790] = {30, "Munch."},
	[2791] = {30, "Munch."},
	[2792] = {6, "Munch."},
	[2794] = {3, "Munch."},
	[2795] = {36, "Munch."},
	[2796] = {5, "Munch."},
	[2793] = {9, "Munch."},
	[5097] = {4, "Yum."},
	[6125] = {8, "Gulp."},
	[6278] = {10, "Mmmm."},
	[6279] = {15, "Mmmm."},
	[6393] = {12, "Mmmm."},
	[6394] = {15, "Mmmm."},
	[6501] = {20, "Mmmm."},
	[6541] = {6, "Gulp."},
	[6542] = {6, "Gulp."},
	[6543] = {6, "Gulp."},
	[6544] = {6, "Gulp."},
	[6545] = {6, "Gulp."},
	[6569] = {1, "Mmmm."},
	[6574] = {4, "Mmmm."},
	[7158] = {15, "Munch."},
	[7159] = {13, "Munch."},
	[7372] = {7, "Yum."},
	[7373] = {7, "Yum."},
	[7374] = {7, "Yum."},
	[7375] = {7, "Yum."},
	[7376] = {7, "Yum."},
	[7377] = {7, "Yum."},
	[7909] = {4, "Crunch."},
	[8838] = {7, "Gulp."},
	[8839] = {5, "Yum."},
	[8840] = {2, "Yum."},
	[8841] = {3, "Urgh."},
	[8842] = {3, "Munch."},
	[8843] = {3, "Crunch."},
	[8844] = {3, "Gulp."},
	[8845] = {2, "Munch."},
	[8847] = {11, "Yum."}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local food = FOODS[item.itemid]
	if(not food) then
		return false
	end
 
	if((getPlayerFood(cid) + food[1]) >= 400) then
		doPlayerSendCancel(cid, "You are full.")
		return true
	end
 
	doPlayerFeed(cid, food[1] * 4)
	doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	return true
end
 
I tried to make a food.lua like tibia rl. It's not easy for me because I'm not good with lua..
I think that if I use "seconds" it will be much perfect, don't?
 
There is discrepancies between those two scripts...

Here's the merged code. The one script multiplied it's table values by 4 before applying them so I moved the multiplier inside the table so you can sort out the discrepancies.

Code:
see post below
 
Last edited:
There are no food which only lasts for 8 seconds? Blueberries has the lowest duration as far as I know and that is 12 seconds. Which equals 1%.

And every food value increment by 12. (12, 24, 36, 48 etc...) So you can just divide seconds by 12 and the result will be in % which will always be an int value which you can use.
 
hint hint Lucas.

Edit:

vbseo_like_bg.png
is not what I meant.

Try the
reputation-40b.png
instead, eh?
 
Last edited:
Here... ;seems most of the entries matched when multiplied by 12 instead of 4, I added identifier comments to the right of the table during which I noticed peanut was next to walnut in the item.xml, so I added it to the table. Remaining discrepancies are removed from the table with a commenting tag. Several are the eating 'sound' being Crunch versus Munch:


Code:
---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------
--[[ useAction for eating food items ]]--Lessaire--
---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------
local MAX_FOOD = 1200
local FOODS = {
    [2362] = {  32, "Crunch." }, --carrot of doom
    [2666] = { 180, "Munch."  }, --meat
    [2667] = { 144, "Munch." },  --fish
    [2668] = { 120, "Mmmm."  },  --salmon  
    [2669] = { 204, "Munch." },  --northern pike  
    [2670] = {  48, "Gulp."  },  --shrimp  
    [2671] = { 360, "Chomp." },  --ham   
    [2672] = { 720, "Chomp." },  --dragon ham  
    [2673] = {  60, "Yum."   },  --pear   
    [2674] = {  72, "Yum."  },   --red apple
    [2675] = { 156, "Yum."  },   --orange
    [2676] = {  96, "Yum."  },   --banana
    [2677] = {  12, "Yum."   },  --blueberry
    [2678] = { 216, "Slurp." },  --coconut
    [2679] = {  12, "Yum."   },  --cherry
    [2680] = {  24, "Yum."  },   --strawberry
    [2681] = { 108, "Yum."  },   --grapes
    [2682] = { 240, "Yum."   },  --melon
    [2683] = { 204, "Munch."  }, --pumpkin
--  [2684] = {  96, "Crunch." }, --carrot
--  [2684] = {  60, "Crunch." }, --carrot
    [2685] = {  72, "Munch."  }, --tomato
    [2686] = { 108, "Crunch." }, --corncob
    [2687] = {  24, "Crunch." }, --cookie
--  [2688] = { 108, "Munch."  }, --candy cane
--  [2688] = {  24, "Mmmm."   }, --candy cane
    [2689] = { 120, "Crunch." }, --bread
    [2690] = {  36, "Crunch." }, --rolls
    [2691] = {  96, "Crunch." }, --brown bread
    [2695] = {  72, "Gulp."   }, --egg
    [2696] = { 108, "Smack."  }, --cheese
--  [2787] = { 108, "Munch."  }, --white mushroom
--  [2787] = { 270, "Crunch." }, --white mushroom
    [2788] = {  48, "Munch."  }, --red mushroom
--  [2789] = { 242, "Munch."  }, --brown mushroom
--  [2789] = { 264, "Munch."  }, --brown mushroom
--  [2790] = { 360, "Munch."  }, --orange mushroom
--  [2790] = { 360, "Crunch." }, --orange mushroom
--  [2791] = { 360, "Munch."  }, --wood mushroom
--  [2791] = { 108, "Crunch." }, --wood mushroom
--  [2792] = {  72, "Munch."  }, --dark mushroom
--  [2792] = {  72, "Crunch." }, --dark mushroom
--  [2793] = { 108, "Munch."  }, --mushrooms
--  [2793] = { 144, "Crunch." }, --mushrooms
--  [2794] = {  36, "Munch."  }, --mushrooms
--  [2794] = {  36, "Crunch." }, --mushrooms
--  [2795] = { 366, "Munch."  }, --fire mushroom
--  [2795] = { 432, "Crunch." }, --fire mushroom
--  [2796] = {  60, "Munch."  }, --green mushroom
--  [2796] = {  60, "Crunch." }, --green mushroom
    [5097] = {  48, "Yum."    }, --mango
    [5678] = {  96, "Gulp."  },  --tortoise egg #1
    [6125] = {  96, "Gulp." },   --tortoise egg #2
    [6278] = { 120, "Mmmm." },   --cake
    [6279] = { 180, "Mmmm." },   --decorated cake
    [6393] = { 144, "Mmmm." },   --valentine's cake
    [6394] = { 180, "Mmmm." },   --cream cake
    [6501] = { 240, "Mmmm." },   --gingerbread man
    [6541] = {  72, "Gulp." },   --coloured egg
    [6542] = {  72, "Gulp." },   --coloured egg
    [6543] = {  72, "Gulp." },   --coloured egg
    [6544] = {  72, "Gulp." },   --coloured egg
    [6545] = {  72, "Gulp." },   --coloured egg
    [6569] = {  12, "Mmmm." },   --candy
    [6574] = {  48, "Mmmm."  },  --bar of chocolate
    [7158] = { 180, "Munch." },  --rainbow trout
    [7159] = { 156, "Munch." },  --green perch
    [7372] = {  84, "Yum."   },  --ice cream cone
    [7373] = {  84, "Yum."  },   --ice cream cone
    [7374] = {  84, "Yum."  },   --ice cream cone
    [7375] = {  84, "Yum."  },   --ice cream cone
    [7376] = {  84, "Yum."   },  --ice cream cone
    [7377] = {  84, "Yum."    }, --ice cream cone
    [7909] = {  48, "Crunch." }, --walnut
    [7910] = {  48, "Crunch." }, --peanut
    [8112] = { 108, "Urgh."   }, --scarab cheese
    [8838] = {  84, "Gulp."  },  --potato
    [8839] = {  60, "Yum."  },   --plum
    [8840] = {  24, "Yum."   },  --raspberry
    [8841] = {  36, "Urgh."  },  --lemon
    [8842] = {  36, "Munch."  }, --cucumber
    [8843] = {  36, "Crunch." }, --onion
    [8844] = {  36, "Gulp."   }, --jalapeno pepper
    [8845] = {  24, "Munch." },  --beetroot
    [8847] = { 132, "Yum."   }   --chocolate cake
    }
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 6280) then
        if(fromPosition.x == CONTAINER_POSITION) then
            fromPosition = getThingPosition(cid)
        end
         doCreatureSay(cid, getPlayerName(cid) .. " blew out the candle.", TALKTYPE_MONSTER)
        doTransformItem(item.uid, item.itemid - 1)
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        return true
    end

    local food = FOODS[item.itemid]
 
    if((getPlayerFood(cid) + food[1]) >= MAX_FOOD) then
        doPlayerSendCancel(cid, "You are full.")
        return true
    end
 
    if(not food) then
        return false
    end
 
    doRemoveItem(item.uid, 1)
    doPlayerFeed(cid, food[1])
    doCreatureSay(cid, food[2], TALKTYPE_MONSTER)
    return true
end
 
¬¬ food system works like this : u eat food, u gain health and u stop geting health after x time bcuz the food efect is gone now u need eat more food >D
 
Back
Top