-
Posts
187 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Russell
-
-
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")
endfunction Script:Use()
if ShowedImagen=="Yes" then
ShowedImagen="No"
else
ShowedImagen="Yes"
end
endfunction 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!! ?
-
Hi there...
I'm new using LUA creating my own scripts from scratch.
And this is a question that is driving me crazy.
I want SHOW/HIDE a image centered on screen after USE an object ingame. With this code I have managed to show the image without problems:
-----------
Script.HudTextura=""local ScriptActivo="Yes"
local ShowImage="No"function Script:Use()
if self.enabled then
ShowImage="Yes"
else
ShowImage="No"
end
endfunction Script:PostRender(context)
if ShowImage=="Yes" then
context:SetBlendMode(Blend.Alpha)
texture = Texture:Load("Materials/MisTexturas/"..self.HudTextura..".tex")
context:DrawImage(texture,context:GetWidth()/2-texture:GetWidth()/2,context:GetHeight()/2-texture:GetHeight()/2,texture:GetWidth(),texture:GetHeight())
end
end-----------
But I don't know how hide or erase it after that.
I have searched forum and Google, but the answers i've found have not helped me. I'm not able to find any command to hide or delete the image after displaying it.
Can anybody help me?
I'm not using FlowGUI or FlipHook because i want learn LUA from beginning creating my own simple scripts.
Thank you very much!!
Hide or Delete Image (context) command in LUA??
in Programming
Posted
Ok, now with this code the problem is...
If i put 2 or more images on the level with this code, when i active one of them and activate another one with the same code, 2 images stay together on screen.
Is there any way to clear the activated image before show a second one???
If i use context.clear() my screen becomes white.