FeLiPe-Eduardo
New Member
- Joined
- Jun 3, 2015
- Messages
- 38
- Solutions
- 1
- Reaction score
- 3
Hello.
this script is from @Xikini and i cant convert this to revscript to use on tfs1.3, and i dont understand this yet. i can change some scripts and adapt for my use, but this conversion still confusion to me, if someone can convert and comment the diferences for this script as exemple.
Something simple now, how restricting the use of this item only to equipment/weapons/wands,etc ... on this way it is can be used on the floor or in containers, etc ...
thanks.
FLP
this script is from @Xikini and i cant convert this to revscript to use on tfs1.3, and i dont understand this yet. i can change some scripts and adapt for my use, but this conversion still confusion to me, if someone can convert and comment the diferences for this script as exemple.
Lua:
--[[
.------..------..------..------..------..------.
|X.--. ||I.--. ||K.--. ||I.--. ||N.--. ||I.--. |
| :/\: || (\/) || :/\: || (\/) || :(): || (\/) |
| (__) || :\/: || :\/: || :\/: || ()() || :\/: |
| '--'X|| '--'I|| '--'K|| '--'I|| '--'N|| '--'I|
`------'`------'`------'`------'`------'`------'
]]--
local config = {
[45000] = {
object = {
position = Position(250, 242, 7),
itemId = 1514,
removeTimer = 4 -- seconds
},
tilePositions = {
Position(248, 245, 7),
Position(250, 245, 7),
Position(252, 245, 7)
}
},
[45001] = {
object = {
position = Position(1000, 1000, 7),
itemId = 1111,
removeTimer = 4
},
tilePositions = {
Position(1000, 1000, 7),
Position(1000, 1000, 7),
Position(1000, 1000, 7)
}
}
}
local function removeAndReAddObject(position, objectId, timer)
position:sendMagicEffect(CONST_ME_POFF)
if timer > 0 then
Tile(position):getItemById(objectId):remove()
addEvent(removeAndReAddObject, timer, position, objectId, 0)
else
Game.createItem(objectId, 1, position)
end
end
local stepTilesRemoveObject = MoveEvent()
stepTilesRemoveObject:type("stepin")
function stepTilesRemoveObject.onStepIn(player, item, position, fromPosition)
-- confirm is player
if not player:isPlayer() then
return true
end
-- confirm index
local actionId = item:getActionId()
local index = config[actionId]
if not index then
print("LUA error: ActionId not in table." .. actionId)
return true
end
-- confirm that object exists
if Tile(index.object.position):getItemCountById(index.object.itemId) == 0 then
position:sendMagicEffect(CONST_ME_POFF)
return true
end
-- confirm if all tiles are occupied
local positionAmount = #index.tilePositions
local playerCount = 0
for i = 1, positionAmount do
local creature = Tile(index.tilePositions[i]):getTopCreature()
if not creature or not creature:isPlayer() then
index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_RED)
else
index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_GREEN)
playerCount = playerCount + 1
end
end
-- remove and reAdd stone
if playerCount == positionAmount then
removeAndReAddObject(index.object.position, index.object.itemId, index.object.removeTimer * 1000)
end
return true
end
for actionid, _ in pairs(config) do
stepTilesRemoveObject:aid(actionid) -- adds all actionid's from config
end
stepTilesRemoveObject:register()
Something simple now, how restricting the use of this item only to equipment/weapons/wands,etc ... on this way it is can be used on the floor or in containers, etc ...
Code:
local epicgem = Action()
local itemId = 40810
function epicgem.onUse(cid, item, frompos, item2)
rollRarity(item2, 'epic')
item:remove(1)
return true
end
epicgem:id(itemId)
epicgem:register()
thanks.
FLP