[01/08/2013 18:29:38] [Error - Action Interface]
[01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:onUse
[01/08/2013 18:29:38] Description:
[01/08/2013 18:29:38] attempt to index a number value
[01/08/2013 18:29:38] stack traceback:
[01/08/2013 18:29:38] [C]: in function 'doCreatureChangeOutfit'
[01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:14: in function <data/actions/scripts/outfit lever.lua:7>
Im still getting this
Code:[01/08/2013 18:29:38] [Error - Action Interface] [01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:onUse [01/08/2013 18:29:38] Description: [01/08/2013 18:29:38] attempt to index a number value [01/08/2013 18:29:38] stack traceback: [01/08/2013 18:29:38] [C]: in function 'doCreatureChangeOutfit' [01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:14: in function <data/actions/scripts/outfit lever.lua:7>
I've got 2 levers here, and i did /attr actionid 1200 and on the other /attr actionid 1201, so am i doing something wrong?
local t = {
[1200] = {123}, -- [LEVER_ACTION_ID] = {lookType}
[1201] = {456},
}
local token = 2159
function onUse(cid, item, fromPosition, itemEx, toPosition)
local k = t[item.actionid]
if k then
if(not doPlayerRemoveItem(cid, token, 1)) then
return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
end
doSetCreatureOutfit(cid, {lookType = k[1]}, -1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1)
end
return true
end
local config = {
token = 2159,
useRandomOutfits = true -- false will use the first outfit in the sequence {123, 237}
}
local t = {
[1200] = {123, 237}, -- [LEVER_ACTION_ID] = lookType(s)
[1201] = {123, 237},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local k = t[item.actionid]
if k then
if(not doPlayerRemoveItem(cid, config.token, 1)) then
return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
end
if(config.useRandomOutfits == true) then
for _, v in pairs(t) do
doSetCreatureOutfit(cid, {lookType = v[math.random(#v)]}, -1)
end
else
if(config.useRandomOutfits == false) then
doSetCreatureOutfit(cid, {lookType = k[1]}, -1)
end
end
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1)
end
return true
end
Try this one:
LUA:local t = { [1200] = {123}, -- [LEVER_ACTION_ID] = {lookType} [1201] = {456}, } local token = 2159 function onUse(cid, item, fromPosition, itemEx, toPosition) local k = t[item.actionid] if k then if(not doPlayerRemoveItem(cid, token, 1)) then return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end doSetCreatureOutfit(cid, {lookType = k[1]}, -1) doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1) end return true end
This one is untested, but I thought maybe you want random outfits:
LUA:local config = { token = 2159, useRandomOutfits = true -- false will use the first outfit in the sequence {123, 237} } local t = { [1200] = {123, 237}, -- [LEVER_ACTION_ID] = lookType(s) [1201] = {123, 237}, } function onUse(cid, item, fromPosition, itemEx, toPosition) local k = t[item.actionid] if k then if(not doPlayerRemoveItem(cid, config.token, 1)) then return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end if(config.useRandomOutfits) then for _, v in pairs(t) do doSetCreatureOutfit(cid, {lookType = v[math.random(#v)]}, -1) end else doSetCreatureOutfit(cid, {lookType = k[1]}, -1) end doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1) end return true end
[01/08/2013 18:34:30] [Error - LuaScriptInterface::loadFile] data/actions/scripts/outfit lever.lua:1: '=' expected near 'config'
[01/08/2013 18:34:31] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/outfit lever.lua)
[01/08/2013 18:34:31] data/actions/scripts/outfit lever.lua:1: '=' expected near 'config'
Did you try the first script? The second one is untested.![]()
local t = {
[1200] = {6}, -- [LEVER_ACTION_ID] = lookType(s)
[1201] = {92},
That worked the second one, but now it only gives the same outfit..
i changed it to that, but it only give me the 92..Code:local t = { [1200] = {6}, -- [LEVER_ACTION_ID] = lookType(s) [1201] = {92},
You need to put more than one outfit in the second script. See the second script here: http://otland.net/f132/monster-lever-must-have-tokens-196029/index3.html#post1891858
The first script should only give 1 outfit per lever.
OMG ITS WORKING, Bro im so happy.. you dont even know!!!!.. oh man! Thanks for taking YOUR time to help a noob xD bro, is it possible to give rep?
Good. Yes, click the little star beneath my username to the left.
Ninja was right... The way I used doCreatureChangeOutfit had an extra variable for time, which is for doSetCreatureOutfit. Good catch, Ninja. I mixed them up.![]()
Thanks for adding reputation to this user. May you be lucky enough to receive the same Reputation back in turn