Post #1 · Publicado en 2015-01-10 04:29:16pm Hace 9.4 años
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 Mensajes | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
Hello again... sorry for multiples topics but... I was taking a break about theming these days but now Im working again in a next Upodate of my Theme Metro Quad...
I was reading on http://kki.ajworld.net/lua/sm5/Lua.xml about codes and commands, etc... and I found that one AddInputCallback(). About what I read, I can call a function depending of differents values or determinates actions... for example pressing a determinate key or with multiples settings...
Anyway I tried to experiment with this one but I cannt get something works, I would like to know if someone has used this command and let me know whats things I can do with it...
My idea is execute some scripts using some combo-keys... I have so many ideas on my mind but I need a little help to start with this command.
Anyway Thanks for the help... It's very helpful
I was reading on http://kki.ajworld.net/lua/sm5/Lua.xml about codes and commands, etc... and I found that one AddInputCallback(). About what I read, I can call a function depending of differents values or determinates actions... for example pressing a determinate key or with multiples settings...
Anyway I tried to experiment with this one but I cannt get something works, I would like to know if someone has used this command and let me know whats things I can do with it...
My idea is execute some scripts using some combo-keys... I have so many ideas on my mind but I need a little help to start with this command.
Anyway Thanks for the help... It's very helpful
Post #2 · Publicado en 2015-01-10 06:23:12pm Hace 9.4 años
Kyzentun | |
---|---|
Member | |
3,209 Mensajes | |
Reg. 2008-02-20 | |
"I'm honestly pissed off." |
Last updated: 2015-01-10 06:23pm
http://codepad.org/GFrM9BN4
(SetStateProperties is a function I added last night, but that's not really relevant. I just didn't feel like taking an extra minute to make a demo that just changes a bitmaptext when I already had a similar enough demo.)
Basically, you write a function, call AddInputCallback and pass in that function. Then whenever input occurs, your function is called with the event structure filled out.
(SetStateProperties is a function I added last night, but that's not really relevant. I just didn't feel like taking an extra minute to make a demo that just changes a bitmaptext when I already had a similar enough demo.)
Basically, you write a function, call AddInputCallback and pass in that function. Then whenever input occurs, your function is called with the event structure filled out.
Post #3 · Publicado en 2015-01-10 07:10:20pm Hace 9.4 años
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 Mensajes | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
Quote: Kyzentun
http://codepad.org/GFrM9BN4
(SetStateProperties is a function I added last night, but that's not really relevant. I just didn't feel like taking an extra minute to make a demo that just changes a bitmaptext when I already had a similar enough demo.)
Basically, you write a function, call AddInputCallback and pass in that function. Then whenever input occurs, your function is called with the event structure filled out.
(SetStateProperties is a function I added last night, but that's not really relevant. I just didn't feel like taking an extra minute to make a demo that just changes a bitmaptext when I already had a similar enough demo.)
Basically, you write a function, call AddInputCallback and pass in that function. Then whenever input occurs, your function is called with the event structure filled out.
Well it is a little hard to understand at least for me... for example, I wanna try something very simple... on ScreenEvaluation i put this:
Quote
local Text
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button == "DeviceButton_w" then
Text = "Pressed W"
end
end
local Example = {
OnCommand= function(self)
SCREENMAN:GetTopScreen():AddInputCallback(input)
end,
LoadFont("Common Normal")..{
Text="Not Pressed";
InitCommand=cmd(Center;zoom,1);
},
}
return Def.ActorFrame(Example)
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button == "DeviceButton_w" then
Text = "Pressed W"
end
end
local Example = {
OnCommand= function(self)
SCREENMAN:GetTopScreen():AddInputCallback(input)
end,
LoadFont("Common Normal")..{
Text="Not Pressed";
InitCommand=cmd(Center;zoom,1);
},
}
return Def.ActorFrame(Example)
My idea is simple, try to change the text from "Not Pressed" to for example at the moment to press W, it shows "Pressed W"... I still dont understand this...
Post #4 · Publicado en 2015-01-10 07:20:53pm Hace 9.4 años
Kyzentun | |
---|---|
Member | |
3,209 Mensajes | |
Reg. 2008-02-20 | |
"I'm honestly pissed off." |
So, the problem in your example is that you're not changing something visible. You're just setting the variable named "Text" to the string "Pressed W". Your input callback is actually working perfectly.
To actually see a result, you have to do something to an actor on the screen.
Something like this:
local text= false
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button= "DeviceButton_w" then
text:settext("Pressed W"
end
end
return Def.ActorFrame{
Def.BitmapText{
Font="Common Normal", Text= "Not Pressed", InitCommand= function(self) text= self self:Center() end,
OnCommand= function(self) SCREENMAN:GetTopScreen():AddInputCallback(input) end,
}
Notice that the BitmapText actor sets the variable "text" to itself in its InitCommand. Code that executes after that occurs can then use the text variable to do things to the BitmapText, like change the text being displayed.
To actually see a result, you have to do something to an actor on the screen.
Something like this:
local text= false
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button= "DeviceButton_w" then
text:settext("Pressed W"
end
end
return Def.ActorFrame{
Def.BitmapText{
Font="Common Normal", Text= "Not Pressed", InitCommand= function(self) text= self self:Center() end,
OnCommand= function(self) SCREENMAN:GetTopScreen():AddInputCallback(input) end,
}
Notice that the BitmapText actor sets the variable "text" to itself in its InitCommand. Code that executes after that occurs can then use the text variable to do things to the BitmapText, like change the text being displayed.
Post #5 · Publicado en 2015-01-10 07:29:40pm Hace 9.4 años
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 Mensajes | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
Quote: Kyzentun
So, the problem in your example is that you're not changing something visible. You're just setting the variable named "Text" to the string "Pressed W". Your input callback is actually working perfectly.
To actually see a result, you have to do something to an actor on the screen.
Something like this:
local text= false
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button= "DeviceButton_w" then
text:settext("Pressed W"
end
end
return Def.ActorFrame{
Def.BitmapText{
Font="Common Normal", Text= "Not Pressed", InitCommand= function(self) text= self self:Center() end,
OnCommand= function(self) SCREENMAN:GetTopScreen():AddInputCallback(input) end,
}
Notice that the BitmapText actor sets the variable "text" to itself in its InitCommand. Code that executes after that occurs can then use the text variable to do things to the BitmapText, like change the text being displayed.
To actually see a result, you have to do something to an actor on the screen.
Something like this:
local text= false
local function input(event)
if event.type == "InputEventType_Release" then return false end
if event.DeviceInput.button= "DeviceButton_w" then
text:settext("Pressed W"
end
end
return Def.ActorFrame{
Def.BitmapText{
Font="Common Normal", Text= "Not Pressed", InitCommand= function(self) text= self self:Center() end,
OnCommand= function(self) SCREENMAN:GetTopScreen():AddInputCallback(input) end,
}
Notice that the BitmapText actor sets the variable "text" to itself in its InitCommand. Code that executes after that occurs can then use the text variable to do things to the BitmapText, like change the text being displayed.
Ok Im understanding this a little... well yeah the code works, If I press W it will change the Text and then show it on screen... well thanks, ill try to experimenting what more I can do with this...
Thanks you Kyzentun