Thank you very much for the answer... I've putted "LOAD Texture" commands in the Start Function.
Anyway, after hours of battle with LUA, finally i've solved my problem loading an empty-small texture of 32x32 on Start Function too...
Now my code works fine for me like this:
---------------------
Script.HudTexture=""
local ScriptActivo="Yes"
local ShowedImagen="No"
function Script:Start()
self.enabled=true
texture = Texture:Load("Materials/MyTextures/"..self.HudTexture..".tex")
textureEmpty = Texture:Load("Materials/MyTextures/Empty.tex")
end
function Script:Use()
if ShowedImagen=="Yes" then
ShowedImagen="No"
else
ShowedImagen="Yes"
end
end
function Script:PostRender(context)
if ShowedImagen=="Yes" then
context:SetBlendMode(Blend.Alpha)
context:DrawImage(texture,context:GetWidth()/2-texture:GetWidth()/2,context:GetHeight()/2-texture:GetHeight()/2,texture:GetWidth(),texture:GetHeight())
end
if ShowedImagen=="No" then
context:SetBlendMode(Blend.Alpha)
context:DrawImage(textureEmpty,context:GetWidth()/2-textureEmpty:GetWidth()/2,context:GetHeight()/2-textureEmpty:GetHeight()/2,textureEmpty:GetWidth(),textureEmpty:GetHeight())
end
end
---------------------
I don't know if this solution is the best, but It works fine for me.
With my little knowledge in LUA, I am quite satisfied with the result.
Thank you very much!! ?