Topic: EnableCameraLayer Issue(Resolved)

In one scene I have my level.
In another scene I have some text that updates every frame and a camera.

I used the enableCameraLayer() function on the first scene to project the 2nd scene over the 1st one.

When I run the 2nd scene, the text works.
However, when I run the first scene (the level scene), the 2nd scene's text appears but it only shows the default text, and it doesn't update at all.

Scene 1 code:
GuiScene = getScene("Pnt_scene")
Camera = getObject("camera0")
enableCameraLayer(Camera, GuiScene)

Scene 2 code:
txt_points = getObject("Text0")
   t = 0
   function onSceneUpdate()
       t = t + 1
       new_text = "Time = " .. t -- change the last "t" to display another info
       setText(txt_points, new_text)
   end

Any help?

Last edited by Tutorial Doctor (2013-09-18 20:52:24)

Re: EnableCameraLayer Issue(Resolved)

Is there no way you can come to IRC to chat about this..that would be great, and give the rest of us some needed company in the channel that atm is usualy dead during most of the day.

irc.freenode.net , #maratis

Anyway to answer your question, I have no idea what your code is doing, not for sure anyway..I easily get the general idea, Im just a tad confused on what the text code is doing...if I had a better idea of that I could prob . assist you in your efforts. Either come to irc (its much easier and its in real time!) or wait for someone else to chime in, which eventually WILL happen, and they likely will know what is wrong given my programming ability, atm anyway, is very lacking. I've just not had time , as my skills are primarily in graphics. Learning the code part as I go...:)

All of your code is easy to understand,short of this:

t = t + 1
       new_text = "Time = " .. t -- change the last "t" to display another info

"Time = " .. t < is the part Im totally confused by, if you explain that I might''' be able to help you. Frankly that part looks wrong to me, as if something is missing or incomplete..but that's a major guess as I'm just not used to seeing that type of programming given my current lacking expertise.

If you are using this code from somewhere else, could you point out to me where it is so I can compare and possibly help you spot the coding error ?

cheers
hs
aka: neighborlee

Re: EnableCameraLayer Issue(Resolved)

heartseed wrote:

Is there no way you can come to IRC to chat about this..that would be great, and give the rest of us some needed company in the channel that atm is usualy dead during most of the day.

irc.freenode.net , #maratis

Anyway to answer your question, I have no idea what your code is doing, not for sure anyway..I easily get the general idea, Im just a tad confused on what the text code is doing...if I had a better idea of that I could prob . assist you in your efforts. Either come to irc (its much easier and its in real time!) or wait for someone else to chime in, which eventually WILL happen, and they likely will know what is wrong given my programming ability, atm anyway, is very lacking. I've just not had time , as my skills are primarily in graphics. Learning the code part as I go...:)

All of your code is easy to understand,short of this:

t = t + 1
       new_text = "Time = " .. t -- change the last "t" to display another info

"Time = " .. t < is the part Im totally confused by, if you explain that I might''' be able to help you. Frankly that part looks wrong to me, as if something is missing or incomplete..but that's a major guess as I'm just not used to seeing that type of programming given my current lacking expertise.

If you are using this code from somewhere else, could you point out to me where it is so I can compare and possibly help you spot the coding error ?

cheers
hs
aka: neighborlee

I just copied and pasted it from the wiki and changed the names a bit. But I think it is the way that you do concatenation in lua. Some languages do it like this:

new_text = "Time " + t

This new_text variable is simply a WORD + a NUMBER (You can't add words to numbers really, but it's how you display them)

Instead of using + in lua they must use ..

So what actually occurs is that I have the word TIME followed by a number that keeps getting bigger (it updates every frame).

It works in the 2nd scene, but when I try to overlay that scene on the first, it doesn't. It just displays the words TEXT. That's it.

p.s(It actually displays ''Time ='' and a number)

Last edited by Tutorial Doctor (2013-09-18 17:39:23)

Re: EnableCameraLayer Issue(Resolved)

"Time " + t < this is the only  thing I can see that MIGHt indicate something wrong...since I have no idea where on wiki you pasted this from, is there supposed to be a 'space' between e and " in time ?

BUt anyway given it works in 2nd scene when not overlayed, then maybe you are  just missing some part of what you copied/pasted, that it can't update, I just don't know without seeing original code. Somebody else MORE familiar with this, would prob. know instantly wink

Re: EnableCameraLayer Issue(Resolved)

heartseed wrote:

"Time " + t < this is the only  thing I can see that MIGHt indicate something wrong...since I have no idea where on wiki you pasted this from, is there supposed to be a 'space' between e and " in time ?

The space is there so that "Time" is not displayed right next to the number.

Say I had a variable:

words = "I am" .. "a word"

This would display as:

I ama word

I could do it this way to fix it:

words = "I am " .. "a word"

or

words = "I am" .. " a word"

My code works in the 2nd scene perfectly. But it just doesn't work when projected over the 2nd scene using the enableCameraLayer() function

I got it from here:
http://wiki.maratis3d.org/index.php?tit … ameraLayer

And here:
http://wiki.maratis3d.org/index.php?title=SetText

Last edited by Tutorial Doctor (2013-09-18 17:49:33)

Re: EnableCameraLayer Issue(Resolved)

One t hing I noticed, and Im NOT sure it matters is this:

Text0 = getObject("Text0")


YOur example is this: txt_points = getObject("Text0")

I get that txt_points is a variable, but I wonder if not having them called the same as the wiki example does, matters ?

ATm its the only thing I can see that is different. It can't hurt to try it , in case it matters.

Re: EnableCameraLayer Issue(Resolved)

Hi,

there is only one script running at a time,
in your case the scene 1 because it is the active scene.

So write all code in the scene 1 script :

Scene 1 code:
GuiScene = getScene("Pnt_scene")
Camera = getObject("camera0")
enableCameraLayer(Camera, GuiScene)

txt_points = getObject(GuiScene, "Text0") -- get object from GuiScene
t = 0

function onSceneUpdate()
       t = t + 1
       new_text = "Time = " .. t -- change the last "t" to display another info
       setText(txt_points, new_text)
end

Re: EnableCameraLayer Issue(Resolved)

anael wrote:

Hi,

there is only one script running at a time,
in your case the scene 1 because it is the active scene.

So write all code in the scene 1 script :

Scene 1 code:
GuiScene = getScene("Pnt_scene")
Camera = getObject("camera0")
enableCameraLayer(Camera, GuiScene)

txt_points = getObject(GuiScene, "Text0") -- get object from GuiScene
t = 0

function onSceneUpdate()
       t = t + 1
       new_text = "Time = " .. t -- change the last "t" to display another info
       setText(txt_points, new_text)
end

Thank you heartseed and anael!! I have a collection script now that displays on scene! I want to upload the level, but I don't know if I am allowed to re-upload the jules level. I just modified the script a bit. If not I can upload a screenshot.

-- get objects
Jules = getObject("Jules")
Player = getObject("Player")
Set = getObject("Set")
Feet = getObject("Feet")
apple = getObject("apple")
snd_collect = getObject("collect")
apple_clone = getClone(apple)

GuiScene = getScene("Pnt_scene")
Camera = getObject("camera0")
enableCameraLayer(Camera, GuiScene)
text = getObject(GuiScene,"Text0")

apples_collected = 0

function Collect(object)
    if isCollisionBetween(Player,object) then
        deactivate(object)
        playSound(snd_collect)
        Scale()
        apples_collected = apples_collected + 1
    end
end

function onSceneUpdate()
    --Apples GUI
    show_apples_collected = "Apples = " .. apples_collected
    setText(text,show_apples_collected)
   
    --Apple Collection
    Collect(apple)
    Collect(apple_clone)
end

Last edited by Tutorial Doctor (2013-09-18 20:28:36)