• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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!

[TFS 1.3] [Revscriptsys] Free Lua scripting service - Post your requests! Let's learn it together!

Evil Puncker

I'd rather kiss a rattlesnake
Joined
May 30, 2009
Messages
6,128
Best answers
44
Reaction score
1,989
Location
160,54,7
Lua:
monster.events = {
    "nameofevent1",
    "nameofevent2"
}
this will register the event to the monster or use MonsterType("name"):registerEvent("eventName")
I'd rather not try to include the event itself into the monster file as the loading order of script systems might be a problem, you can however try to confirm that aswell if you want to.
thanks, I just used a onKill event attached to the player so I didn't need to change monster file and it worked, thanks again
 

Eiffel

EternumOT Mapper/Designer
Joined
Nov 17, 2008
Messages
246
Best answers
0
Reaction score
110
Location
Bakersfield, CA
Not much of a request for a specific script but is there a quick and easy way to learn how to create dynamic spells with revscripts?

Example: A spell that deals damage around the player that casts it for 20 seconds in .5 second intervals.

Example 2: A spell that places a buff on you that heals you for 50% of your damage.

Example 3: A spell that converts all your basic attack damage into another random element each second for 10 seconds.
 

Evil Puncker

I'd rather kiss a rattlesnake
Joined
May 30, 2009
Messages
6,128
Best answers
44
Reaction score
1,989
Location
160,54,7
I'd like to request this script to be converted into revscriptsys and made a PR so we can close one more issue one tfs :p (is there a way to make toggle-able in config.lua? I'm open to ideas 😁
 

Dreww

Veteran OT User
Joined
Oct 7, 2011
Messages
251
Best answers
0
Reaction score
373
Location
México
hello id like to request SCRIPT! i don't have idea if its work on 1.3 tho but it would cool to have it on revscriptsys :p
 

ralke

Felipe
Joined
Dec 17, 2011
Messages
340
Best answers
3
Reaction score
51
Location
Chile
[TFS 1.2] Teleport Scroll by @Stigma

Converted to Revscriptsys, 3 XML file changes and 3 file additions into 1 file:

Teleports player to default town position, creates a teleport near the player (that only the player can see).
The player has 30 seconds to enter the teleport to get back to their previous position.
Also added a 30 seconds cooldown, and tons of comments to explain the code.

Lua:
-- TP Scroll by Stigma: https://otland.net/threads/tfs-1-2-teleport-scroll.245184/
-- Converted to TFS 1.3 Revscriptsys by Znote.

-- Part 1 = Action (scroll item)
-- Part 2 = Movement (step in teleport positions)
-- Part 3 = Creaturescript (disable/cleanup if the player decides to log out while system is active)


------------------------------------
-- Begin code of Part 1 = Action: --
tpScroll = Action() -- Create a new action that we call "tpScroll"
tpScroll:id(1953) -- Item id of the scroll we want to attach this action to.

-- Create an internal storage object to keep track of positions
local savePos = {}

-- Supplementary function to this particular action.
-- (apply and re-apply effect as a pulse while the effect position is stored in internal object)
local function sendEffects(position, effect, pid)
    if savePos[pid] then
        if savePos[pid].Enabled then
            local player = Player(pid)
            if isPlayer(player) then
                position:sendMagicEffect(effect, player)
                addEvent(sendEffects, 400, position, effect, pid, CS)
            end
        end
    end
end

-- Attach an "onUse" functionality to this tpScroll action.
-- When you use the id associated to the action, this function will trigger.
function tpScroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Store player id, we will use this as a logical reference in our internal storage
    -- and to re-create the player object in our SendEffects function
    local pid = player:getId()

    -- Don't allow players to use this scroll if they have engaged aggressively in PvP
    if not player:isPzLocked() then

        -- If player (pid) is not added to internal storage yet
        -- Add it to internal storage and execute this action
        if not savePos[pid] then
            -- Save the players position in his own internal storage (pid)
            savePos[pid] = {
                ScrollActivatedPosition = player:getPosition(),
                RandomTemplePosition = nil, -- We will save this a bit further down
                Enabled = true,
                Cooldown = os.time() + 31
            }

            -- Teleport player to his temple
            player:teleportTo(player:getTown():getTemplePosition())
        
            -- Get and store the position of the temple
            local pos = player:getPosition()

            -- Calculate a close nearby random position to this temple and save it
            savePos[pid].RandomTemplePosition = Position(pos.x+math.random(3), pos.y+math.random(2), pos.z)

            -- Execute the function that creates a pulse effect while this action is running
            -- On both positions, but with different effect type. (12 and 35)
            sendEffects(savePos[pid].RandomTemplePosition, 12, pid)
            sendEffects(savePos[pid].ScrollActivatedPosition, 35, pid)

            -- Find the ground item at the random temple position, and give it an action Id
            -- (For the movement script/PART 2)
            local item = Item(Tile(savePos[pid].RandomTemplePosition):getGround().uid)
            item:setActionId(3006)

            -- Also, execute a function in 30 seconds that will remove this added action id.
            addEvent(
                function()
                    if item:getActionId(3006) then
                        item:removeAttribute('aid')
                        savePos[pid] = nil
                    end
                end
            ,30 * 1000) -- 30 * 1000 ms = 30 seconds until this internal function executes.

        else -- This action is already executed, the teleport is already spawned.
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            -- If the system is still enabled, they havent entered the teleport yet
            if savePos[pid].Enabled then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You must enter your teleport first before you use this again. The teleport will exist for ' .. savePos[pid].Cooldown - os.time() .. ' more seconds.')
            else -- They have entered the teleport, but there is a lingering addevent we have to wait for to complete before they can use it again
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Remaining cooldown: ' .. savePos[pid].Cooldown - os.time() .. ' seconds.')
            end
        end
    else -- If the player IS pz locked. (has attacked another player)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You may not use this while you are in battle.')
    end
    return true
end

-- Register/enable this action!
tpScroll:register()


--------------------------------------
-- Begin code of Part 2 = Movement: --
randomTemplePosition = MoveEvent()

-- In step 1 we added action id 3006 on this tile. Now lets register the "functionality" of it.
randomTemplePosition:aid(3006)

-- When you step on this actionid, the MoveEvent executes.
function randomTemplePosition.onStepIn(creature, item, position, fromPosition)
    -- Load the player id that moved on this randomTemplePosition, using that, find the relevant internal storage for him
    local pid = creature:getId()
    local pos = savePos[pid]

    -- If we found this players positions in the internal storage, proceed
    if pos and pos.RandomTemplePosition then

        -- Teleport him back to the position where he activated the tp scroll
        creature:teleportTo(pos.ScrollActivatedPosition)

        -- Send the stun effect on both positions (random temple + scroll)
        pos.ScrollActivatedPosition:sendMagicEffect(CONST_ME_STUN)
        pos.RandomTemplePosition:sendMagicEffect(CONST_ME_STUN)

        -- Remove the added action id. (Which will stop this event from happening until next time)
        item:removeAttribute('aid')

        -- Remove the player from the internal storage, so the pulse effects in step 1 stop pulsing.
        savePos[pid].Enabled = false
    end
    return true
end

-- Register/activate this onstepin effect.
randomTemplePosition:register()

----------------------------------------------------------------------------------------------
---------------------------- Begin code of Part 3 = Movement: --------------------------------
-- Creaturescript (disable/cleanup if the player decides to log out while system is active) --
local tpscroll_player = CreatureEvent("tpscroll_player")

-- onLogin and onLogout CreatureEvent function declarations should automatically be registered to every player
function tpscroll_player.onLogout(player)
    local pid = player:getId()
    -- If we have any internal storage on this player, remove it. Also remove the actionid on the floor
    if savePos[pid] then
        Item(Tile(savePos[pid].RandomTemplePosition):getGround().uid):removeAttribute('aid')
        savePos[pid].Enabled = false
    end
    return true
end

-- Enable/activate this Creature Event
tpscroll_player:register()
hi @Znote, what im doing wrong with this?
error tp scroll.png

and also, where i should install this one?
Lua:
local foods = {
    [2362] = {5, "Crunch."}, -- carrot
    [2666] = {15, "Munch."}, -- meat
    [2667] = {12, "Munch."}, -- fish
    [2668] = {10, "Mmmm."}, -- salmon
    [2669] = {17, "Munch."}, -- northern pike
    [2670] = {4, "Gulp."}, -- shrimp
    [2671] = {30, "Chomp."}, -- ham
    [2672] = {60, "Chomp."}, -- dragon ham
    [2673] = {5, "Yum."}, -- pear
    [2674] = {6, "Yum."}, -- red apple
    [2675] = {13, "Yum."}, -- orange
    [2676] = {8, "Yum."}, -- banana
    [2677] = {1, "Yum."}, -- blueberry
    [2678] = {18, "Slurp."}, -- coconut
    [2679] = {1, "Yum."}, -- cherry
    [2680] = {2, "Yum."}, -- strawberry
    [2681] = {9, "Yum."}, -- grapes
    [2682] = {20, "Yum."}, -- melon
    [2683] = {17, "Munch."}, -- pumpkin
    [2684] = {5, "Crunch."}, -- carrot
    [2685] = {6, "Munch."}, -- tomato
    [2686] = {9, "Crunch."}, -- corncob
    [2687] = {2, "Crunch."}, -- cookie
    [2688] = {2, "Munch."}, -- candy cane
    [2689] = {10, "Crunch."}, -- bread
    [2690] = {3, "Crunch."}, -- roll
    [2691] = {8, "Crunch."}, -- brown bread
    [2695] = {6, "Gulp."}, -- egg
    [2696] = {9, "Smack."}, -- cheese
    [2787] = {9, "Munch."}, -- white mushroom
    [2788] = {4, "Munch."}, -- red mushroom
    [2789] = {22, "Munch."}, -- brown mushroom
    [2790] = {30, "Munch."}, -- orange mushroom
    [2791] = {9, "Munch."}, -- wood mushroom
    [2792] = {6, "Munch."}, -- dark mushroom
    [2793] = {12, "Munch."}, -- some mushrooms
    [2794] = {3, "Munch."}, -- some mushrooms
    [2795] = {36, "Munch."}, -- fire mushroom
    [2796] = {5, "Munch."}, -- green mushroom
    [5097] = {4, "Yum."}, -- mango
    [6125] = {8, "Gulp."}, -- tortoise egg
    [6278] = {10, "Mmmm."}, -- cake
    [6279] = {15, "Mmmm."}, -- decorated cake
    [6393] = {12, "Mmmm."}, -- valentine's cake
    [6394] = {15, "Mmmm."}, -- cream cake
    [6501] = {20, "Mmmm."}, -- gingerbread man
    [6541] = {6, "Gulp."}, -- coloured egg (yellow)
    [6542] = {6, "Gulp."}, -- coloured egg (red)
    [6543] = {6, "Gulp."}, -- coloured egg (blue)
    [6544] = {6, "Gulp."}, -- coloured egg (green)
    [6545] = {6, "Gulp."}, -- coloured egg (purple)
    [6569] = {1, "Mmmm."}, -- candy
    [6574] = {5, "Mmmm."}, -- bar of chocolate
    [7158] = {15, "Munch."}, -- rainbow trout
    [7159] = {13, "Munch."}, -- green perch
    [7372] = {2, "Yum."}, -- ice cream cone (crispy chocolate chips)
    [7373] = {2, "Yum."}, -- ice cream cone (velvet vanilla)
    [7374] = {2, "Yum."}, -- ice cream cone (sweet strawberry)
    [7375] = {2, "Yum."}, -- ice cream cone (chilly cherry)
    [7376] = {2, "Yum."}, -- ice cream cone (mellow melon)
    [7377] = {2, "Yum."}, -- ice cream cone (blue-barian)
    [7909] = {4, "Crunch."}, -- walnut
    [7910] = {4, "Crunch."}, -- peanut
    [7963] = {60, "Munch."}, -- marlin
    [8112] = {9, "Urgh."}, -- scarab cheese
    [8838] = {10, "Gulp."}, -- potato
    [8839] = {5, "Yum."}, -- plum
    [8840] = {1, "Yum."}, -- raspberry
    [8841] = {1, "Urgh."}, -- lemon
    [8842] = {7, "Munch."}, -- cucumber
    [8843] = {5, "Crunch."}, -- onion
    [8844] = {1, "Gulp."}, -- jalapeño pepper
    [8845] = {5, "Munch."}, -- beetroot
    [8847] = {11, "Yum."}, -- chocolate cake
    [9005] = {7, "Slurp."}, -- yummy gummy worm
    [9114] = {5, "Crunch."}, -- bulb of garlic
    [9996] = {0, "Slurp."}, -- banana chocolate shake
    [10454] = {0, "Your head begins to feel better."}, -- headache pill
    [11246] = {15, "Yum."}, -- rice ball
    [11370] = {3, "Urgh."}, -- terramite eggs
    [11429] = {10, "Mmmm."}, -- crocodile steak
    [12415] = {20, "Yum."}, -- pineapple
    [12416] = {10, "Munch."}, -- aubergine
    [12417] = {8, "Crunch."}, -- broccoli
    [12418] = {9, "Crunch."}, -- cauliflower
    [12637] = {55, "Gulp."}, -- ectoplasmic sushi
    [12638] = {18, "Yum."}, -- dragonfruit
    [12639] = {2, "Munch."}, -- peas
    [13297] = {20, "Crunch."}, -- haunch of boar
    [15405] = {55, "Munch."}, -- sandfish
    [15487] = {14, "Urgh."}, -- larvae
    [15488] = {15, "Munch."}, -- deepling filet
    [16014] = {60, "Mmmm."}, -- anniversary cake
    [18397] = {33, "Munch."}, -- mushroom pie
    [19737] = {10, "Urgh."}, -- insectoid eggs
    [20100] = {15, "Smack."}, -- soft cheese
    [20101] = {12, "Smack."} -- rat cheese
}

local autoFeed = CreatureEvent("AutoFeed")

function autoFeed.onThink(player, interval)
    local foundFood, removeFood
    for itemid, food in pairs(foods) do
        if player:getItemCount(itemid) > 0 then
            foundFood, removeFood = food, itemid
            break
        end
    end
    if not foundFood then
        return true
    end
    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + foundFood[1] * 12) < 1200 then
        player:feed(foundFood[1] * 12)
        player:say(foundFood[2], TALKTYPE_MONSTER_SAY)
        player:removeItem(removeFood, 1)
    end
    return true
end

autoFeed:register()

local login = CreatureEvent("RegisterAutoFeed")

function login.onLogin(player)
    player:registerEvent("AutoFeed")
    return true
end

login:register()
thanks in advance!
 
Top