Signup Now
Results 1 to 9 of 9
  1. #1
    Free User Sajean's Avatar
    Join Date
    Feb 2014
    Posts
    386
    Reputation
    26
    Rep Power
    21

    Custom Data Base

    Hello guys i came here to show to yours how you can create your custom data base,changing and getting the values.

    I'm starting here knowing that everyone knows what is a data base.

    Ok Let's go.

    In this example we will put the name of your character in the data base.

    1º First Step: Creating the Data Base.

    init start
    MyData = opendatabase('Sajean')
    init end

    MyData: Variable, you can put what you want here.
    opendatabase('Sajean'): Here you are creating your database, you can put any name that you want.

    Now we data base is created.

    2º Second Step: Setting values for Data base.

    init start
    MyData = opendatabase('Sajean')
    MyData:setvalue('Sajean','Name',$name)
    init end

    setvalue: Here we are setting the value to we data base.
    'Sajean': Is the name of the SectionName.
    'Name': You can set what you want here, DataName.
    $name: Your character name.

    This code will add into the data base SectionName 'Sajean' in the 'Name' DataName your chracter '$name'.

    Now we data base have your name stored in 'Name' DataName.

    3º Third Step: Getting values stored in Data base.

    init start
    MyData = opendatabase('Sajean')
    MyData:setvalue('Sajean','Name',$name)
    init end
    auto(1000)
    local yourName = MyData:getvalue('Sajean','Name')
    print(yourName)


    local yourName: This creating an local variable, you can put what you want.
    getvalue: Here we are getting the value stored in your Data base.

    This code will get into the data base SectionName 'Sajean' in the 'Name' DataName, will print(yourName) in the console.

    Your CustomDataBase is stored in windbot folder.
    windbot/data/custom.

    NOTE: For you see what i'm saying you need to download an SQLite and you will can acess your data an seeing the value.

    Here is an example of how your data is.



    Now we data was created and your name is stored in the data.


    Here i will give simple example of functions to you get and add values to your data, if you are working with numbers or count.

    init start
    function getValue()
    return MyData:getvalue('Sajean','Count') --This function will get the value of the count.
    end
    function addValue(...)
    return MyData:setvalue('Sajean','Count',getValue()+...) --This function will add value to your count.
    end
    function decreaseValue(...)
    return MyData:setvalue('Sajean','Count',getValue()-...) --This function will decrease value to your count.
    end
    init end


    Thank you.
    Last edited by Sajean; 11-07-2014 at 04:14 PM.

  2. #2
    Moderator Leonardo's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    758
    Reputation
    77
    Rep Power
    22
    @KrusT

    Everything you need is here. Basically it crashes the bot because one section of db:setvalue is missing.

  3. #3
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17
    How can i check values and letters in basic databases? I mean $botdb, $chardb and $worlddb for values like "loggedin", "lasttrained" and many others using in some scripts here
    Last edited by pedegie; 12-23-2015 at 04:08 AM.

  4. #4
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,440
    Reputation
    283
    Rep Power
    27
    Quote Originally Posted by pedegie View Post
    How can i check values and letters in basic databases? I mean $botdb, $chardb and $worlddb for values like "loggedin", "lasttrained" and many others using in some scripts here
    https://www.tibiawindbot.com/docs.ht...ns-DB:getvalue
    RaphSeller
    PayPal Instantaneous Reseller


    raphseller.com

  5. #5
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17
    this link not works

  6. #6
    Moderator mistgun's Avatar
    Join Date
    Dec 2013
    Location
    Lodz, Poland
    Posts
    1,821
    Reputation
    220
    Rep Power
    26
    example use:
    $chardb:setvalue('lastTrained', 1, 'my diks')
    print($chardb:getvalue('lastTrained', 1))
    Last edited by mistgun; 12-23-2015 at 03:55 PM.

  7. #7
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17
    I know examples. Need a list with all values to get from this database : P

  8. #8
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,440
    Reputation
    283
    Rep Power
    27
    The link won't work, but go on the docs and look for Iterators > Iterators > DB:sectionvalue
    RaphSeller
    PayPal Instantaneous Reseller


    raphseller.com

  9. #9
    Free User pedegie's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    264
    Reputation
    28
    Rep Power
    17
    There isnt any important informations too. Repair this link

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •