• 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.X+ Printing storage value in OnLook event

Obito

0x1337
Joined
Feb 17, 2011
Messages
350
Solutions
8
Reaction score
145
Location
Egypt
Hi, I have this script
Lua:
local config = {
    [2361] = {damageincrease = 5}, -- frozen starlight = 5% extra damage
    [2123] = {damageincrease = 10} -- ring of the sky = 10% extra damage
}

function onEquip(player, item, slot, isCall)
    if isCall == false then
        player:setStorageValue(33250, player:getStorageValue(33250) + config[item:getId()].damageincrease) -- add damage increase
    end
    return true
end

function onDeEquip(player, item, slot)
    player:setStorageValue(33250, player:getStorageValue(33250) - config[item:getId()].damageincrease) -- remove damage increase
    return true
end
but I was wondering how do I print the percentage of this particular storage "33250" for example when you look at yourself or in someone else it says Total Damage: "The number of percentages that I have from wearing this item"but I couldn't because when I try to create an onLook event with creatruescripts to check this storage it says
Code:
[Error - CreatureEvent::configureEvent] Invalid type for creature event: onlook_damage_increase
[Warning - BaseEvents::loadFromXml] Failed to configure event
Using tfs 1.4.1
edit: I found player.lua but I don't know how to make it in the events folder seems so complicated.
 
Last edited:
seems so complicated.

Event Callbacks are basically just as easy as the creaturescipt script you have above, just have a small alteration, follow these steps to create an event callback

1. Create a variable (name it your event) and declare it to be an EventCallback

Lua:
Local MyCoolEvent = EventCallback

2. Create the type of event you want added to the variable as a function, making sure to include the same parameters as the event you are trying to call.

Code:
MyCoolEvent.onLook = function(self, thing, position, distance, description) -- self is only added parameter onLook event

3. Be sure to include an end as with all functions, and to at some point do the proper return for the event. Look events returning description, onHealthChange returns damages, onEquip return true or false, ect, ect.

Code:
local MyCoolEvent = EventCallback

MyCoolEvent.onLook = function(self, thing, position, distance, description)
    ---------------
    --Do cool stuff
    ---------------
    return description
end

4. Finally, register the event.


Code:
local MyCoolEvent = EventCallback

MyCoolEvent.onLook = function(self, thing, position, distance, description)
    ---------------
    --Do cool stuff
    ---------------
    return description
end

MyCoolEvent:register() --- simple method to register the created event callback.

Saving this as a script in data/scripts folder is where you want to do all callbacks , added bonus is that entire revscript system works there, so you can just keep adding events of different types (each one must be its own variable) to same file to expand a system to include onEquip, onDeEquip, onLook and much more!
 
Event Callbacks are basically just as easy as the creaturescipt script you have above, just have a small alteration, follow these steps to create an event callback

1. Create a variable (name it your event) and declare it to be an EventCallback

Lua:
Local MyCoolEvent = EventCallback

2. Create the type of event you want added to the variable as a function, making sure to include the same parameters as the event you are trying to call.

Code:
MyCoolEvent.onLook = function(self, thing, position, distance, description) -- self is only added parameter onLook event

3. Be sure to include an end as with all functions, and to at some point do the proper return for the event. Look events returning description, onHealthChange returns damages, onEquip return true or false, ect, ect.

Code:
local MyCoolEvent = EventCallback

MyCoolEvent.onLook = function(self, thing, position, distance, description)
    ---------------
    --Do cool stuff
    ---------------
    return description
end

4. Finally, register the event.


Code:
local MyCoolEvent = EventCallback

MyCoolEvent.onLook = function(self, thing, position, distance, description)
    ---------------
    --Do cool stuff
    ---------------
    return description
end

MyCoolEvent:register() --- simple method to register the created event callback.

Saving this as a script in data/scripts folder is where you want to do all callbacks , added bonus is that entire revscript system works there, so you can just keep adding events of different types (each one must be its own variable) to same file to expand a system to include onEquip, onDeEquip, onLook and much more!
Thanks for helping I'm really grateful to you. :)
 
Back
Top