Hi,
I read this documentation below:
I have the following Module named “FPSandMouseXY.lua” in folder “modules”:
-- Put functions in this file to use them in several other scripts.
-- To get access to the functions, you need to put:
-- require "my_directory.my_file"
-- in any script using the functions.
local M = {}
function M.UpdateFPSandMouseXY()
FPS_FrameCount = (FPS_FrameCount + 1)
local currentTime = socket.gettime()
if ( currentTime > (FPS_LastSecond + 1) ) then
FPS_TenSeconds[FPS_CurrentSecond] = FPS_FrameCount
if (FPS_CurrentSecond < 10) then
FPS_CurrentSecond = (FPS_CurrentSecond + 1)
else
FPS_CurrentSecond = 0
end
for index = 0, 10 do
FPS_Average = (FPS_Average + FPS_TenSeconds[index])
end
FPS_Average = (FPS_Average / 11)
FPS_Average = math.floor(FPS_Average)
FPS_LastSecond = socket.gettime()
FPS_FrameCount = 0
end
label.set_text( "#MouseXY", "FPS=" .. tostring(FPS_Average) .. " [" .. tostring( math.floor( mX * (360/WindowWidthTrue) ) ) .. "," .. tostring( math.floor( mY * (640/WindowHeightTrue) ) ) .. "]" )
end
return M
I then have this script code:
function init(self)
-- Add initialization code here
-- Remove this function if not needed
local m = require "modules.FPSandMouseXY"
CurrentScreen = 1
NextScreen = 2
msg.post(".", "acquire_input_focus")
go.set("#FAS-Statue", "scale.x", 0.65)
go.set("#FAS-Statue", "scale.y", 0.65)
end
function final(self)
-- Add finalization code here
-- Remove this function if not needed
msg.post(".", "release_input_focus")
end
function update(self, dt)
-- Add update code here
-- Remove this function if not needed
m.UpdateFPSandMouseXY()
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Remove this function if not needed
if message_id == hash("show_level_select") then
msg.post("#", "enable")
self.active = true
elseif message_id == hash("hide_level_select") then
msg.post("#", "disable")
self.active = false
end
end
function on_input(self, action_id, action)
-- Add input-handling code here
-- Remove this function if not needed
mX = action.screen_x
mY = action.screen_y
end
function on_reload(self)
-- Add reload-handling code here
-- Remove this function if not needed
end
Above does not compile, get the following error message:
The file ‘/modules/FPSandMouseXY.lua’ could not be found.
Any ideas what I am doing wrong?
(trying to create a module for lines of code that I use in every Collection)
Thanks!
J.