C++ Code

Ok, I only know a little bit of C++ code. I’m tring to pass a variable from c++ to GDevelop and it didnt work.
I have in the include section
my C++ code looks like this

[spoiler]scene.SetBackgroundColor(100,100,240);

time_t now = time(0);
tm *ltm = localtime(&now);

int varDay;
varDay = ltm->tm_mday;[/spoiler]

Condition:
Action: Do =Variable(varDay) to variable varDay2

The documentation is here : 4ian.github.io/GD-Documentation/ … index.html
If you don’t know how to use it, then, it will be very difficult to do anything with the C++ feature. :frowning:

I was looking to do a workaround for the time(mday) not working in the html5 version.
I seen GDevelop allowed to use C++ code and assumed I would just need to plug in the needed code.
I only seen the C++ code importation, but see in the documentation you can use JS also. The JS for HTML and C++ for native. But it looks like you need both C++ and JS for html5, am I reading this correct?

You just use JS for HTML5 games. You should be able to use the JS time functions and display it in-game in GD.

Hmm, I tried
Javascript code:
runtimeScene.setBackgroundColor(100,100,240);
var y = 6;
and event action Do = VariableString(y) to the text of NewObject
I also tried GlobalVariableString(y)
I got 0 as the result.

Ok I did a debugger and found I have to use:

var d = new Date();
var d = d.getDay()+1
runtimeScene.getVariables().get(“z”).setNumber(d);

Is their a cleaner method?

TY:)

Got it

runtimeScene.getVariables().get(“varDay”).setNumber(new Date().getDay()+1);

Workaround for anyone needing to address day issue in html5, just add to JS and use the variable varDay