ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator Lifting of the fog...
person icon
veganpete
Registered User
Quote
2023-08-24 09:33:23

Gald it works! Of course - if you want to make it happen with code, instead of using the built-in "on-proximity" events, Sven will possibly modify his script for you. I think the coding will be a more efficient solution.

*"Rat Creature"? How dare you! emoji icon_grin - Anna Maria will be sadly disappointed...
https://www.youtube.com/watch?v=...

Yeah, sorry about that: "Lupain" was a spelling error (I'm dyslexic); it was meant to say "Lupin" emoji icon_devil.
...I've now changed it to "Luposian" and re-uploaded it for you, so it's slightly less offensive.emoji icon_holy

person icon
sven
Registered User
Quote
2023-08-24 10:25:56

Here is modified version.
This script wont put fog back anymore just sets it zero if you reach to the peak.

https://drive.google.com/file/d/...

I make kinda similar game.. but instead of fadeing fog when moving up i make fog value more higer.. so on top of mountain i cant see ground.

person icon
luposian
Registered User
Quote
2023-08-24 18:05:07

wrote:
Gald it works! Of course - if you want to make it happen with code, instead of using the built-in "on-proximity" events, Sven will possibly modify his script for you. I think the coding will be a more efficient solution.

*"Rat Creature"? How dare you! emoji icon_grin - Anna Maria will be sadly disappointed...
https://www.youtube.com/watch?v=...

Yeah, sorry about that: "Lupain" was a spelling error (I'm dyslexic); it was meant to say "Lupin" emoji icon_devil.
...I've now changed it to "Luposian" and re-uploaded it for you, so it's slightly less offensive.emoji icon_holy

Ok, glad to know it wasn't you or a family member that drew that atrocity. But, honestly, couldn't you have just used a stick figure or some other place holder and called it "player"?

Did a word search for "Lupin" (I only knew the word from the Japanese Anime series that was used as part of a laserdisc arcade game called "Cliff Hanger"; Google it, if you're unfamiliar) and discovered that the flower (plant) is named after a wolf, because it was believed to ravenously (like a wolf) deplete the soil! Interesting information!

person icon
luposian
Registered User
Quote
2023-08-24 18:34:32

@Sven - Absolutely awesome! Now I just need to figure out how to trigger the next part, which then ends Stage 1! Yes, we're THAT close!

BTW, I normally like to quote in my replies, but some messages just give constant error messages, so I'm forced to create a new message, instead. Anyone know WHY that keeps happening? I'm thinking it's something to do with file links or long messages or code snippets or something. emoji icon_hmpf

person icon
Dieter
Guest
Quote
2023-08-24 19:13:49

I still don't know what was wrong with the suggestion to use altitude directly, as it was the initial question. Something along the lines of


var root = ccbGetRootSceneNode();
var playerpos=ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position");
var altitude= playerpos.y;
var density=10- (altittude/10);
if(density > 10){density=10;}
if(density < 0){density= 0;}
ccbSetSceneNodeProperty(root,"FogDensity", density);

But it was kind of ignored.

person icon
luposian
Registered User
Quote
2023-08-24 22:16:52

Dieter wrote:
I still don't know what was wrong with the suggestion to use altitude directly, as it was the initial question. Something along the lines of


var root = ccbGetRootSceneNode();
var playerpos=ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position");
var altitude= playerpos.y;
var density=10- (altittude/10);
if(density > 10){density=10;}
if(density < 0){density= 0;}
ccbSetSceneNodeProperty(root,"FogDensity", density);

But it was kind of ignored.

"Something along the lines of" does not necessarily mean the code is fully functional. As well, since I'm not a programmer, I wouldn't know how or where to exactly incorporate that code. If someone (like Sven) has a working piece of code that I can easily implement, I naturally go with the easiest option.

Would I like to understand how to program? Sure. Will I? To some degree (as I have), but not enough to ever not require a lot of help from others who know code like the back of their hand.

The lack of implementation of other's code is not a sign of disrespect. But Sven stepped up and offered a quick solution. I've spent hours, banging my head against a wall, trying to figure out stuff on my own, with some parts of this Stage. It leaves me exhausted. Sure, its immensely satisfying to finally get something working, after twisting my brain in knots trying to figure it out... but if someone is willing to spare me that effort... why wouldn't I take the easier route? The end result is the same, except instead of Stage 1 getting finished sooner... it would take a LOT longer... if it ever got completed (in some cases, to this point of development).

If someone hands me code and points me in the right direction, sometimes I can figure out the rest (as I've done in a few instances). Othertimes, the solution remains utterly elusive to my thinking. Having the next piece of the puzzle, but having no idea where (or how) to place it.

So, don't take it personally. I really am trying my best to do as much as I can on my own... but I'm not a programmer. And I'm forever grateful to those willing to assist on my behalf and give credit to all who do. emoji icon_grin

person icon
Dieter
Guest
Quote
2023-08-25 11:58:02

Luposian,
while I agree about Coppercube, being sometimes confusing where and how to use scripts - even for an experienced programmer - because it allows to insert them at various places, you are very lucky to have some people here who write code for you. Generally, on the long run, you should learn to code, or hire programmers.

That said, Javascript is a bad language for starters. Many coding styles are possible, some are barely human-readable anymore, like how am I supposed to intuitively know that
a % b means a MOD b ? It's a lot about googling the exact syntax, not so much about creative thinking (the thing I love about coding, like a mixture of lego, chess and play-doh).

I started with BASIC about 25 years ago. Some say it's a bad choice and leads to bad habits, I disagree. Once you know what the commands do, you begin to understand how programs work. When you then learn a new language like JS, you already know what it should do, you only have to "translate" the idea that's in your head to that new language.

Some languages like LUA or C seem to be easier than JS. Javascript also has terrible debugging options. Browsers usually have a Javascript error console that you can open to see what went wrong. However, this is the language of the browser applications, so we are forced to use it. It is however pretty powerful, once you overcome the beginner obstacles.

In the case of my code given above, you would add a behavior to the root scene node: do something every few seconds, you would choose maybe every 1000 ms.
There simply choose as action: special, execute javasctipt. There paste it in the little script editor window.

You said you want to turn off the fog, once player has reached the top. Simply put the whole code into an IF condition and execute only if a certain variable is still zero.
If the player reaches the top, set that variable to 1.

Like many structures in JS, the IF condition uses the wavey brackets to define what's to be executed IF a certain condition holds true. Example:


reached_top=ccbGetCopperCubeVariable("WasOnTop");
if(reached_top == 0)
{
// insert script seen above
// and add this:
if (altitude > 100) { ccbSetCopperCubeVariable("WasOnTop", 1); }
}

Also noteworthy, Any variables you plan to use, you should declare in a script in "Do something before first drawing", of the root scene node. In this case it'd be:

ccbSetCopperCubeVariable("WasOnTop", 0);

This also prepares the game for scene-reload / restart. So I hope this was useful, and that you'll have a good start into the addictive world of creative coding.

person icon
Dieter
Guest
Quote
2023-08-25 13:07:22

Oh and BTW, that "altittude" in my script above, should of course be "altitude" ^^

person icon
okeoke
Registered User
Quote
2023-08-25 14:15:57

Javascript also has terrible debugging options.


Hi Dieter,

I can't disagree more. All modern IDEs support debugging for JS - you have the same tools as usual: breakpoints, step into, step out, next step, etc:https://javascript.info/debuggin...
If you're developing for browser you can also set breakpoints for any events like page load, dom changes, animation, you name it.

If you develop with node js, there are even more options. You can use chrome:https://medium.com/@paul_irish/d...
You can use your IDE built-in tools:https://code.visualstudio.com/do...
You can use node js debugger:https://nodejs.org/api/debugger....

The only issue you can't use it these with Coppercube:) (you can, but only with webgl target).
But this is not the issue with language. If coppercube was using any basic engine the same way it uses js engine now, there would also be no way to debug code either.

person icon
Dieter
Guest
Quote
2023-08-25 14:29:48

okeoke,
you may be right in many aspects, yet, this is still terribly user-unfriendly, compared to the old times, when a compiler told you exactly what's wrong, like "syntax error on line 123" and it really was line 123, whereas JS error messages can be cryptic, and are usually more of a trace to a path to follow, that may lead you to the bug - but sometimes not really.

And as you said, in CC there isn't much of a code editor. I actually try to avoid using the embed editor, but put as much as possible in behavior and action script extensions. Not having a "find" function in a text editor, and also the need to close and reopen it every time, definitely is annoying.

That just shows how precious CC's rendering power is, that I use it despite these hurdles.

person icon
okeoke
Registered User
Quote
2023-08-25 14:51:14

Yeah, I've changed my mind. You are right - it sucks.

person icon
Dieter
Guest
Quote
2023-08-25 15:18:31

Well, it starts with the fact that one has to go and find an IDE at all, where as I was working with languages that contain a perfect IDE, compiler and interpreter already. And syntax error detection is by no means related to whether it's interpreted or compiled - it's the same code, so why should it not check it in either case.

But I must admit, back in those old days, things were simpler. Hardware and Software became more complex. So it was easier back then, to keep the toolset simple and efficient.

But other than that, it seems to me a lot of coders never experienced truly userfriendly tech. For instance installing and configuring VC++ on a PC is a complete nightmare, compared to those systems of the past.
But like VHS tapes etc. the worse tech usually prevails. And most ppl never ever experienced the luxury of beta-max.

I find JS picky and hard to debug, you don't. Great, we have a diversity of opinions. But this is getting a bit off topic.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |