NDCommunityToolsTestTool

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search

[Main][Community Tools]

Testing Tool

This script is easy to attach to any item. Use the /info command on any item. Attach this module to it in the Info UI window. This script upon being attached will add 3 contenxt (right click) options to the item you targeted.

General Information

  • this script package was uploaded during Point Release 8, December 2019.
  • thank you for trying my equipment editor tool.

How to Use

  • Open Window - this is used to open the ShowTestWindow() function
  • Reload Modules - this will reload the test_scripting.lua file
  • Test Function - this will run any code put in the TestCode Function
  • Save the following as test_scripting.lua in any editor you use.

CODE

--- Attach this file by typing /info and targeting any item
--- Then in the texfield type in test_scripting and add the module
--- Then use this file to test out UI parts, or function info.
--- There are 3 contet menu options to speed up testing.
--- this is the testwindow 
function ShowTestWindow(user,controlobject)
	local dynamicWindow = DynamicWindow("DynamicWindowHandler","",300,300,-150,-150,"TransparentDraggable","Center")
	dynamicWindow:AddImage(1,1,"HueSwatch",300,300,"Simple","252525")
	DrawCloseButton(271,5,dynamicWindow)

	--test dynamic window code here

	user:OpenDynamicWindow(dynamicWindow,controlobject)
end	

--- this is the dynamic window you wish to place the close button on
function DrawCloseButton(x,y,dynamicwindow)
	dynamicwindow:AddImage(x,y,"HueSwatch",24,24,"Sliced","AA0000")
	dynamicwindow:AddImage(x+2,y+2,"HueSwatch",20,20,"Sliced","770000")
	dynamicwindow:AddButton(x,y,"CloseButton","",24,24,"[FF7700]Close\n[FFFF00]closes this dynamic window.","",true,"Invisible")
end

--- this will handle the response to your dynamic window
RegisterEventHandler(EventType.DynamicWindowResponse,"DynamicWindowHandler",
function (user,buttonId,fieldData)
	
	if(buttonId == "CloseButton") then
		user:SystemMessage("I clicked the close button","info")
	end
	-- handle dynamic window responses here

end)

--- this will handle the context menu and double click of the attached object
RegisterEventHandler(EventType.Message, "UseObject", function(user, usedType) 
    if(usedType=="Open Window") then
    	ShowTestWindow(user,this)
    end
    if(usedType=="Refresh Modules") then
		ReloadModule(GetCurrentModule())
    end
    if(usedType=="Test Code") then
		TestCodeFunction()
    end
end)

function TestCodeFunction()
	-- test code here
end

-- this will handle when the module gets attached to the object
RegisterEventHandler(EventType.ModuleAttached, GetCurrentModule(), function() 
	AddUseCase(this,"Open Window",true,"IsGod")
	AddUseCase(this,"Refresh Modules",false,"IsGod")
	AddUseCase(this,"Test Code",false,"IsGod")
end)

[Main][Community Tools]