• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help: More than 0-6 Skills

Drakkhan

Illuria Project Lead
Joined
Oct 3, 2013
Messages
141
Reaction score
22
I'm interested in adding more skills to my server (TFS 0.2.14 (Mystic Spirit)).

I realize it may be extremely difficult to add the skills, and then over the top to get them to display in the client. I would LIKE to do both, but I would be happy with adding the skills and having them function, while being forced to view the skill level via some .lua code...

Any ideas?

Regards,

Drakkhan
 
Just use a storage value, create a formula for the skill level and add a talkaction to check it.
What do you want to use it for?
 
The plan is to develop a carpentry, smithing, and farming system that are based off of additional skills.. if the addition of new "skills" is a fairly painless process.. I plan to branch out and add woodcutting, glass blowing, mining, and alchemy as well as subskills for the magic system.



--- Updated ---


Also, where exactly do I add this storage value? Let's reduce my last post to simply "I want to create a carpentry skill" How do I create a storage value for each character that stores the player's current carpentry skill?

EDIT: and what would be a example of modifying that player's value in a .lua script?
 
Last edited by a moderator:
Let's say you get 5 skill tries for a successful use of a hammer and 1 skill try for others.

Code:
local function getCarpetTriesForLevel(lv)
    local lv = lv - 1
    return math.floor(20 * lv + 0.8 * lv ^ 3)     -- use your formula here
end

local function getCarpetSkill(tries)
    local tmp = 0
    repeat
        tmp = tmp + 1
    until tries >= getCarpetTriesForLevel(tmp) and not(tries >= getCarpetTriesForLevel(tmp + 1))
    return tmp
end

local carpentryStorage = 39393

-- in function onUse()
local rand = math.random(100)
local currentSkillTries = math.max(getPlayerStorageValue(cid, carpentryStorage), 0)
local newSkillTries = currentSkillTries
local currentSkillLevel = getCarpetSkill(currentSkillTries)
if rand >= 60 then -- successful 
    -- doPlayerSendCancel(cid, "Success")    
    newSkillTries = newSkillTries + 5
else                    -- other
    -- doPlayerSendCancel(cid, "You failed")    
    newSkillTries = newSkillTries + 1
end
setPlayerStorageValue(cid, carpentryStorage, newSkillTries)

local newLevel = getCarpetSkill(newSkillTries)
if newLevel > currentSkillLevel then
    doPlayerSendCancel(cid, string.format("You advanced in carpeting. Your skill level is %d.", newLevel))
    -- other stuff on skill advance.
end

Might not be the best way but it works, I would build general functions like getCustomSkillTries, addCustomSkillTries, getCustomSkillLevel etc. but this should work too.
 
@Summ this is excellent! I'm new to OT Programming, somewhat, but, luckily, I'm not new to programming in general.. I'm soaking up your coding formats and style like a sponge, here! :).

So I'm very capable of recording extra stored skill values, now, my next question is:

How do I go about creating a .lua file for a general getCustomSkillTries() function, and then calling that function in other .lua scripts? Is this possible?

Thanks again!
 
Last edited:
In 0.2.14 you should find a global.lua in your data directory, you can place functions in there which will be accessible by all scripts.
 
Back
Top