- Joined
- Dec 26, 2013
- Messages
- 2,124
- Solutions
- 14
- Reaction score
- 1,518
- Location
- USA
- GitHub
- Codinablack
So I decided to start a discussion on different ways to implement a ModalWindow System that contains many modalwindows. What made me decide to start this discussion was abnormal activity from my ModalWindow System currently in development (Attribute Points System). Anyways, I am still kind of not used to the behavior of modalwindows, but I noticed mine were lagging for no apparent reason, and if I tried to click between many of them too fast it would just not send me my next modalwindow. I thought this was very odd so I investigated.
So what I do understand is that all of my modalwindows are in one file, since they are all to be used together and with nothing else. So I have one creatureevent to register. I also register the creatureevent in login.lua. One thing I found was I was using return way to much and fixed that. I use a predefined function to create every window too. Looks like this...
Anyways the point of this discussion.
What methods would you use? Would you put each individual window in it's own script? If so, would you then hardcode it all instead of using functions like those above? How would you register the creatureevent? Would you link them all if they were in seperate scripts by registering an event upon creation of the new window? Would you keep them all in one creaturescript? All of these options.... What combination of the options would you feel like would be best to keep everything optimized?
A couple shout-outs to get this started... @forgee @Flatlander @Breed @Summ @Printer @Limos @andu @Ninja
So what I do understand is that all of my modalwindows are in one file, since they are all to be used together and with nothing else. So I have one creatureevent to register. I also register the creatureevent in login.lua. One thing I found was I was using return way to much and fixed that. I use a predefined function to create every window too. Looks like this...
Code:
function createWindowWithButtons(cid, var, modalWindowId, headerText, bodyText, buttonTable, choiceTable, sendToPlayer, priority)
var = ModalWindow(modalWindowId, headerText, bodyText)
for i = 1, #buttonTable do
var:addButton(buttonTable[i].id, buttonTable[i].text)
if buttonTable[i].enter then
var:setDefaultEnterButton(buttonTable[i].id)
end
if buttonTable[i].escape then
var:setDefaultEscapeButton(buttonTable[i].id)
end
end
if choiceTable ~= nil then
for i = 0, #choiceTable do
if choiceTable[i] ~= nil then
var:addChoice(choiceTable[i].id, choiceTable[i].text)
end
end
end
if not priority then
var:setPriority(false)
end
if sendToPlayer then
var:sendToPlayer(cid)
end
end
function createWindowWithText(cid, var, modalWindowId, headerText, bodyText, buttonTable, sendToPlayer, priority)
var = ModalWindow(modalWindowId, headerText, bodyText)
for i = 1, #buttonTable do
var:addButton(buttonTable[i].id, buttonTable[i].text)
if buttonTable[i].enter then
var:setDefaultEnterButton(buttonTable[i].id)
end
if buttonTable[i].escape then
var:setDefaultEscapeButton(buttonTable[i].id)
end
end
if not priority then
var:setPriority(false)
end
if sendToPlayer then
var:sendToPlayer(cid)
end
end
Anyways the point of this discussion.
What methods would you use? Would you put each individual window in it's own script? If so, would you then hardcode it all instead of using functions like those above? How would you register the creatureevent? Would you link them all if they were in seperate scripts by registering an event upon creation of the new window? Would you keep them all in one creaturescript? All of these options.... What combination of the options would you feel like would be best to keep everything optimized?
A couple shout-outs to get this started... @forgee @Flatlander @Breed @Summ @Printer @Limos @andu @Ninja
Last edited: