Jump to content

Collision trigger a picture?


lxFirebal69xl
 Share

Recommended Posts

So, I want the player to enter a collision trigger and that trigger makes it shows a picture, kind of like this script for text but instead of text, it shows a picture. How can I do this? tongue.png

 

Script.ObjectDescription = "" --String "Object Description"

Script.DisplayTimeMax = 5000 --Int "Display time"

Script.Used = "0"

Script.DisplayTime = 0

Script.DisplayEnabled = false

local font1 = Font:Load("Fonts/True Lies.ttf", 20)

 

function Script:Use(context)

self.Used = "1"

self.CurrentTime = Time:GetCurrent()

self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax

end

 

 

function Script:PostRender(context)

if self.Used == "1" then

App.context:SetBlendMode(Blend.Alpha)

App.context:SetFont(font1)

self.DisplayEnabled = true

if self.DisplayEnabled == true then

if self.DisplayTime > Time:GetCurrent() then

App.context:SetColor(255,255,255)

context:DrawText(self.ObjectDescription, 100, 600)

else

self.DisplayEnabled = false

self.Used = "0"

end

end

App.context:SetBlendMode(Blend.Solid)

end

end

Link to comment
Share on other sites

This does a picture instead:

 

Script.ObjectDescription = "test" --String "Object Description"
Script.DisplayTimeMax = 5000 --Int "Display time"
Script.Used = "0"
Script.DisplayTime = 0
Script.DisplayEnabled = false
Script.image=Texture:Load("Materials/Effects/bloodspatter.tex")
function Script:Use(context)
self.Used = "1"
self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax
self.DisplayEnabled=true
end

function Script:PostRender(context)
if self.Used == "1" then
 context:SetBlendMode(Blend.Alpha)
 self.DisplayEnabled = true
 if self.DisplayEnabled == true then
  if self.DisplayTime > Time:GetCurrent() then
   context:DrawImage(self.image, 100, 100,100,100)
  else
   self.DisplayEnabled = false
   self.Used = "0"
  end
 end
 App.context:SetBlendMode(Blend.Solid)
  end
end

 

Collision trigger: Are you talking about if the player enters a certain zone this script gets played? Or is it if the player selects an object like with this script?

Link to comment
Share on other sites

This does a picture instead:

 

Script.ObjectDescription = "test" --String "Object Description"
Script.DisplayTimeMax = 5000 --Int "Display time"
Script.Used = "0"
Script.DisplayTime = 0
Script.DisplayEnabled = false
Script.image=Texture:Load("Materials/Effects/bloodspatter.tex")
function Script:Use(context)
self.Used = "1"
self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax
self.DisplayEnabled=true
end

function Script:PostRender(context)
if self.Used == "1" then
context:SetBlendMode(Blend.Alpha)
self.DisplayEnabled = true
if self.DisplayEnabled == true then
if self.DisplayTime > Time:GetCurrent() then
context:DrawImage(self.image, 100, 100,100,100)
else
self.DisplayEnabled = false
self.Used = "0"
end
end
App.context:SetBlendMode(Blend.Solid)
end
end

 

Collision trigger: Are you talking about if the player enters a certain zone this script gets played? Or is it if the player selects an object like with this script?

 

I was talking about the player entering the zone and the picture would show up. Looks like this one only works for when a player uses an objectand it only shows up with a black box on the corner, no actual picture shows up :(

Link to comment
Share on other sites

I'm not really sure why you are getting a black box, but it may have something to do with other code that you may have (like if you edited App.lua code or something) or maybe the image doesn't exist or something like that. Try a different image instead.

 

These tutorials explain how to make a collision trigger ("zone") effect:

 

The second link shows code on how to do this, but the first one gives a little bit of background.

Link to comment
Share on other sites

I'm not really sure why you are getting a black box, but it may have something to do with other code that you may have (like if you edited App.lua code or something) or maybe the image doesn't exist or something like that. Try a different image instead.

 

These tutorials explain how to make a collision trigger ("zone") effect:

 

The second link shows code on how to do this, but the first one gives a little bit of background.

 

Only the default texture you use works, I've tried others and it only works if they're in the "Effects" folder, which is quite strange...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...