Adding Scripts and Flashlight issue

  • #1, z fozzyWednesday, 08. March 2017, 01:49 hodinky 8 years ago
    Hello Visionaire community, im a coder my self but i have never worked with LUA., ive been expirementing with visionaire for about a week now, ive made some progress, learning the engine etc. 

    but i have some questions.

    1. may sound stupid, but how do i add the scripts? How do i call them? how to i add a specific script for a specific gameobject?

    2. is it possible to add something like a flashlight to my character, so that only a certain part of the scene is visible and as the character walks it illuminates the path. something like the example picture i pinned to this thread. 

    Any answers would be great.

    Bažant

    3 Posts


  • #2, z sebastianWednesday, 08. March 2017, 09:27 hodinky 8 years ago
    Hello and welcome to the community! 

    You can add Lua scripts in two ways:
    1: as general scripts in the sceipts section on the left (last point). Just create a script "object" there and put in your lua functions. 
    These functions can then be called inside functions itself or with an "execute a a script" action part. 

    2: for small scriptsyou need locally inside your actions you can do them directly  in an "execute a script" action part. 

    Im not sure what you do mean by adding a script fir a game object. Could you give an example what you need here? 

    I also suggest to read the wiki regarding scripting:

    There you can also find some example scripts and how to use them. 



    A flashlight is possible via the shaders script (also lua) which adds glsl shaders to the game. 

    there exists this script:

    But im not sure if it still works with the current engine version. May the lua script has to be updated to the recent release of the shader toolkit

    Kapitán

    2346 Posts

  • #3, z MachtnixWednesday, 08. March 2017, 18:01 hodinky 8 years ago
    Light (my solution):

    OK, I will try it in English: I did a picture in PS with alpha channel only with a transparent beam (100% white). The other parts are black (in my case I had a transparency of 20%, because the scene should't be 100% dark). This picture must be bigger (>twice) than the scene could be. For example: scene 800 x 600, picture 1610 x 1210 (ten pixels as a safety buffer). This picture should be at the top of the scene objects.

    I set the point of this beam to the point of the torch lamp (or whatever) with Lua. When my charakter walks on the scene the alpha picture follows it's position. In my case it needs an eternal request loop, but maybe it works without; I don't know. The picture has to be so big because at the left and right border I don't want a white uncovered part.

    Problem: I need two directions (left and right) so I build some querys (conditions) to switch the direction. I think the solution doesn't works easily with 8 directions wink wink

    Machtnix

    Kapitán

    1097 Posts

  • #4, z fozzyThursday, 09. March 2017, 17:23 hodinky 8 years ago
    Light (my solution):

    OK, I will try it in English: I did a picture in PS with alpha channel only with a transparent beam (100% white). The other parts are black (in my case I had a transparency of 20%, because the scene should't be 100% dark). This picture must be bigger (>twice) than the scene could be. For example: scene 800 x 600, picture 1610 x 1210 (ten pixels as a safety buffer). This picture should be at the top of the scene objects.

    I set the point of this beam to the point of the torch lamp (or whatever) with Lua."""""" When my charakter walks on the scene the alpha picture follows it's position""""""". In my case it needs an eternal request loop, but maybe it works without; I don't know. The picture has to be so big because at the left and right border I don't want a white uncovered part.


    can you copy me the Quoted scripy? that is a really nice idea thank you!

    Bažant

    3 Posts

  • #5, z fozzyThursday, 09. March 2017, 17:23 hodinky 8 years ago
    Hello and welcome to the community! 

    You can add Lua scripts in two ways:
    1: as general scripts in the sceipts section on the left (last point). Just create a script "object" there and put in your lua functions. 
    These functions can then be called inside functions itself or with an "execute a a script" action part. 

    2: for small scriptsyou need locally inside your actions you can do them directly  in an "execute a script" action part. 

    Im not sure what you do mean by adding a script fir a game object. Could you give an example what you need here? 

    I also suggest to read the wiki regarding scripting:

    There you can also find some example scripts and how to use them. 



    A flashlight is possible via the shaders script (also lua) which adds glsl shaders to the game. 

    there exists this script:

    But im not sure if it still works with the current engine version. May the lua script has to be updated to the recent release of the shader toolkit

    Thank you very much sir

    Bažant

    3 Posts

  • #6, z MachtnixThursday, 09. March 2017, 18:25 hodinky 8 years ago
    can you copy me the Quoted scripy? that is a really nice idea thank you!

    I have to clean it first. There is a lot of Lua in my scripts, many repeats and unneccessary lines... . I'm not good in economical programming and I put all Lua stuff into one script... I have no idea how to handle more than two... wink

    Kapitán

    1097 Posts