armory3d / armory

3D Engine with Blender Integration
https://armory3d.org/engine
zlib License
3.07k stars 315 forks source link

Global variables #312

Closed yanngdev closed 6 years ago

yanngdev commented 6 years ago

Is there any way to have global variables available in armory Traits ? If not, how about having an editable list somewhere in the render panel ?

yanngdev commented 6 years ago

One global variable (not editable) I would also like to find is the path of the current project (to use relative paths in code).

Simonrazer commented 6 years ago

They start to become realy needed for the ACXT3R-project, mainly for hit recognition and the enemys reaction to that, which are in 2 different traits.

luboslenco commented 6 years ago

Added two logic node examples which could aid in this. Ideally we would keep logic trees mostly self contained so it's easy to share them around in different blend files.

@yulbryn I suspect you are not talking about logic nodes? Would you be able to move code accessing current project path into the build system / khafile.js? That one should have __dirname value defined.

There is also a possibility to read files at compile time in Haxe. And perhaps also resolve path to a file using a macro.

Simonrazer commented 6 years ago

It seems like the "Send global event" node is not working, I get this error: C:\Users\SK\Desktop\ACXT3R\Sources/arm/node/Laser.hx:8: characters 29-65 : Type not found : armory.logicnode.SendGlobalEventNode But thanks for adding it!

luboslenco commented 6 years ago

Are you on the latest armory(should have mention that)? If so can you check for armory/Sources/armory/logicnode/SendGlobalEventNode.hx file?

Simonrazer commented 6 years ago

yes i am running the latest version, at least that what the console says(already up to date five times in a row). here is the file and the .blend: globalevent.zip (example doesnt work, too, I checked this time)

yanngdev commented 6 years ago

@luboslenco I was indeed not talking about nodes but having global variables available in Sources hx files. In fact, I am looking for a clean way to read an dynamic file (here containing a json) that is continuously read at runtime and written by an other app/process.

yanngdev commented 6 years ago

I too have an "Undefined" node in the logic_setproperty example, even with SDK updated on 2.79.

luboslenco commented 6 years ago

capture

It looks like updater is sometimes not working properly, will check it out. Perhaps Restore SDK and then Update SDK again would do as a workaround.

yanngdev commented 6 years ago

Restore then Update worked. Seems the updater needs some improvements :).

yanngdev commented 6 years ago

I did not know you could add Armory Traits to the scene! This is an elegant solution, close to the one I had.

Simonrazer commented 6 years ago

@luboslenco yes restoring SDK and then updating with restarts inbetween made it work and also the "Ghost" button in the physics-tab show up!

luboslenco commented 6 years ago

Awesome! I will dig up why the updater is not pulling, at least the workaround worked.

Yeah, scene traits still quite recent, but seem to work ok.:) They will get instantiated before object traits as one would expect.