• 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!

transform item on modal window

Hokku

Member
Joined
Jul 25, 2013
Messages
97
Reaction score
18
Location
Extremadura, Spain
Hello guys im trying to create a general furniture kit, a kit with different options on modal window to choose the furni you want, but i cant figure how to transform it.
Dont get any error in console.
Im using tfs 1.1

LUA:
function onModalWindow(cid, item, modalWindowId, buttonId, choiceId)
    local furniture = {1869, 1866, 1863, 1860, 1872, 1857}
    if modalWindowId == 1005 then
        if buttonId == 100 then
    item:transform(furniture[choiceId])
        end
    end
end
 
Last edited:
Can you elaborate just a little bit? Like first off, does the window pop up with the correct choices? If so, when you click on the choice does it give you buttons, and if so what happens when you use them if anything? It's been awhile since I used a modalwindow, but I don't think I recall an item being a part of the parameters, and I also think that cid was supposed to be player userdata by 1.1 as well.
 
Can you elaborate just a little bit? Like first off, does the window pop up with the correct choices? If so, when you click on the choice does it give you buttons, and if so what happens when you use them if anything? It's been awhile since I used a modalwindow, but I don't think I recall an item being a part of the parameters, and I also think that cid was supposed to be player userdata by 1.1 as well.
The modal window works perfectly, the only thing I can't get is for the script to transform the item into the choice option. The problem is that I want the object to be transformed on the ground, so it is not enough for me to add the item to the player otherwise I would use player:additem. Tried removing cid and i get
LUA:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/modalfurniture.lua:onModalWindow
data/creaturescripts/scripts/modalfurniture.lua:6: attempt to call method 'transform' (a nil value)
stack traceback:
        [C]: in function 'transform'
        data/creaturescripts/scripts/modalfurniture.lua:6: in function <data/creaturescripts/scripts/modalfurniture.lua:1>
 
Your error states that the method "transform" for the class item, does not exist, unless its not an item that is being passed as the second param.. whatever "item" actually is, it can't find the transform function for that class
Post automatically merged:

Confirmed. I just looked around, and there is no onModalWindow function which has an item as the second parameter.. it looks like you just wrote in the word "item" between player and modalwindowId, because that event doesn't even take that many parameters... and the more I think about it, how could it? There is no way to pass an item to a modal window that I can think of
Post automatically merged:

I'm almost certain that you cannot do what you are wanting to do with the modal windows unfortunately, it sounds like that is something that would need to be done with extended opcodes and OTC. You could generate a text list of options along with revscripts and combining actions and maybe another event all together, and have a whole system built that way, but it wouldn't really pass the items along, you would just have to generate the modal window dynamically based off the item you do the action on... something like that could work, but you for sure can't pass an item to the modal window unfortunately
 
Last edited:
Back
Top