I need help for scripting a game - Script Writing - CHDK Forum

I need help for scripting a game

  • 1 Replies
  • 2796 Views
I need help for scripting a game
« on: 11 / January / 2016, 09:25:51 »
Advertisements
If anyone has seen the CHDK Wikia page, there is a script for testing input.

However, this script was written in uBasic...

I plan to make a clicker game(for now) using Lua/uBasic

I need to know if there is any way to make procedures/methods of sorts to change a variable's value after a click. In the script I mentioned above, 'gosub' is used to call a procedure, which prints the key you just clicked. I am using Lua, as there is IO and more support generally, and so I want to know how to replicate this. The only way I know how to, is by creating separate files and opening them, however, this might be intensive for cameras to handle...

Please tell me your thoughts, and if you can, help me script...

Re: I need help for scripting a game
« Reply #1 on: 11 / January / 2016, 10:01:11 »
I need to know if there is any way to make procedures/methods of sorts to change a variable's value after a click. In the script I mentioned above, 'gosub' is used to call a procedure, which prints the key you just clicked. I am using Lua, as there is IO and more support generally, and so I want to know how to replicate this. The only way I know how to, is by creating separate files and opening them, however, this might be intensive for cameras to handle...
Lua allows you do define proper functions rather than use the primitive uBASIC "gosub"mechanism. Amongst the advantages of doing that is the ability to pass parameters to the function and receive return values. 

There is a pretty good CHDK wiki page about scripting :  CHDK Scripting Cross Reference Page

You might want to read through some of the materials linked at the top of that page - especially the Lua part.

Update : Lua version of the script you mentioned attached.
« Last Edit: 11 / January / 2016, 21:10:33 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics