Hello Guest

Programmer Mode Tutorials

  • 4 Replies
  • 3885 Views
*

Seuntjie

  • *****
  • 305
  • +4/-2
    • View Profile
Programmer Mode Tutorials
« on: March 14, 2018, 02:07:13 pm »
Please have a look at some of the tutorials that's available for DiceBots programmer mode if you're having trouble with it:

The steemit tutorials are typically for beginner programmers and explain things like variables, functions and if statements. Tutorial 1.1 (variables), 1.2 (functions) and 2 (process) can be handy for experienced programmers that are new to dicebot though, as they contain a list of bot specific variables and functions that is available in the programmer mode and outlines the process of the programmer mode and how it fits into DiceBots overall system.

The youtube tutorials assume prior programming knowledge and focuses on utilizing the programmer mode, not on teaching how to program

Steemit:
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-01-overview
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-1-1-variables
https://steemit.com/seuntjie/@seuntjie/dicebot-programmer-mode-tutorial-01-2-functions
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-02-process
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-03-martingale
https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-04-martingale-and-mini-if-tutorial

Youtube
https://www.youtube.com/watch?v=m79E9QKm9PI&index=1&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=1s
https://www.youtube.com/watch?v=k1GlmmXjtYc&index=2&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=0s
https://www.youtube.com/watch?v=MmqZbpaJmH4&index=3&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=2s
https://www.youtube.com/watch?v=RlxPCWG3zD8&index=4&list=PLZH88mwZAXLxVtHpc3PIFamkiT1o2V3LX&t=597s


I also have a quick overview of the programmer mode on https://bot.seuntjie.com/programmermode.aspx with a UML of the bet class.
« Last Edit: June 19, 2019, 07:44:16 am by Seuntjie »

*

koyin

  • *
  • 4
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #1 on: March 27, 2018, 08:17:26 pm »
thanks for tutorials!!!

will there any further entries for more complex issues?

*

Seuntjie

  • *****
  • 305
  • +4/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #2 on: March 28, 2018, 01:24:08 pm »
What issues would you like to be adressed?

*

koyin

  • *
  • 4
  • +0/-0
    • View Profile
Re: Programmer Mode Tutorials
« Reply #3 on: March 28, 2018, 08:51:22 pm »
i think a tutorial on creating new functions would be perfect.


*

Seuntjie

  • *****
  • 305
  • +4/-2
    • View Profile
Re: Programmer Mode Tutorials
« Reply #4 on: March 10, 2019, 05:13:21 pm »
Tutorial on creating functions:

A function is a piece of code you can call using a name and some parameters to do a task. For example, you can write a function to add two numbers together. You would call the function using it's name and give the two numbers you want added together as parameters, and the function will return the result. A function does not need to return a value. An example function that doesn't return a value can for example print out the parameters in a certain format.

The syntax of a function:
Code: [Select]
--<tell lua you're creating a function>     <the function name>          <the parameters, separated by columns)
function                                                  AddNums                           (number1, number2)

--<perform function logic inside the function body>
sum = number1+number2

--<return a value for the function>
return sum

--<specify the end of your function>
end


Example function without comments:
Code: [Select]
function AddNums(number1, number2)
   sum = number1+number2
   return sum
end

--use this function in another function or another part of the code
result = AddNums(987654321,123456789)
print(result)

Example of a more complex function that doesn't return a value
Code: [Select]
function prettyprint(bal, profit, bets, wins)
  if bets%1000==0 then --every 1000 bets
    print('Your Balance:'.bal)
    print('You\'ve made '.profit.' Profit so far')
    print('You\'ve made a total of '.bets.' bets')
    print('Of which you have won '.wins)
    print('And have lost '.(bets-wins))
  end
end


Your function name can be anything, as long as it is one word and there is no other function or variable with the same name. You can have as few or as many parameters as you need (I think there's a limit on parameters you can have, but it should be higher than you will ever practically need. If you need to use that many parameters, you need to restructure your code to have more and smaller functions). Functions do not need to return a value, if one does, you can get the result by assigning it to a value as I showed in the AddNums example.

Why use functions?
Functions are re-usable, so any time you have a piece of code that might be repeated, with the same or different values, it's worth putting them into functions. This allows you to have a single place to make changes if something in your code has to change in regards of what the function is doing, instead of having to search through your code for everywhere that you did the same thing and fixing it in 20 different places. It also typically makes your code easier to understand when others read and easier to maintain yourself.