1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

[Wiki] Scripting Documentation help

Discussion in 'Forum, wiki and other THD pages' started by Shadlington, Sep 7, 2012.

Mods: dnmr, Kazaco97
  1. Shadlington

    Shadlington THD Team THD Team Administrator Global Moderator

    Messages:
    1,562
    Okay so here's the thing... I'm meant to be documenting the script bindings for the scripting build but its taking bloody ages and I could use a bit of help to get me through it quickly.

    What I would like help with is creating a legion of page stubs for the various objects and their methods that need documenting. I will still document them all myself but you will essentially be taking out a significant amount of the grind involved in getting the basic page structures in place.

    If I get a few responses here then I'll post pastebins of the methods that actually bind stuff in kag to AS - they basically read like a list of methods/properties, but don't tell you anything about what they do that you can't pick up from the name. These are what you'll base the page stubs on.

    You guys would then help me by creating the stubs and then I'd go over them and fill them in with the detail.

    Anyone willing to help? Please? :)
    I'll make you a tester (and therefore give you access to the scripting build) if you make a significant contribution to this effort.

    So what do you actually have to do?

    Part one: Object Pages
    You need to create a page for the object type - with a formatted list of methods and a formatted list of properties. The list of object types (with links to where they should be created) is at https://wiki.kag2d.com/wiki/Object_Types.

    See https://wiki.kag2d.com/wiki/CMap for example of one of these.
    Basically I need the root pages for objects (e.g. CMap, CBlob, etc. as listed here: https://wiki.kag2d.com/wiki/Object_Types) to be populated with tables of the methods/properties for that object.


    The following spoiler contains something resembling the wiki code I'd expect you to paste in for each object type page you do.
    You would, however, replace MethodName1, etc. with the actual method name you're dealing with (e.g. getTile) and replace ObjectName with the object type you're dealing with (e.g. CInventory).
    You would also replace Property1Name, etc. and Property1Type, etc. with the names and types of the properties you're adding. The blank space is for the description that I will add in later.

    Code:
    <onlyinclude>
     
    </onlyinclude>
     
    Methods:
     
    {| class="wikitableShiny"
    |-
    ! '''Method'''
    ! '''Description'''
    |-
    | [[ObjectName::MethodName1|MethodName1]]
    | {{:ObjectName::MethodName1|MethodName1}}
    |-
    | [[ObjectName::MethodName2|MethodName2]]
    | {{:ObjectName::MethodName2|MethodName2}}
    |-
    |}
     
    Properties:
     
    {| class="wikitableShiny" border="1"
    |-
    ! '''Property'''
    ! '''Type'''
    ! '''Description'''
    |-
    | Property1Name
    | Property1Type
    |
    |-
    | Property2Name
    | Property2Type
    |
    |-
    |}
     
    [[Category:Scripting]]
    [[Category:Object Types]]
     
    
    How do you actually get a the method and property names for that?
    Well I'll give you a pastebin of the code that is used to bind these things to AS.
    Example, for CMap (and CTileEffect): http://pastebin.com/fc9Lv5D9.

    If you look at that you'll see several lines that look roughly like this:
    r = engine->RegisterObjectMethod("CMap", "void setTile(Vec2f pos, TileType tile)",
    or generically:
    r = engine->RegisterObjectMethod("Object Type", "return_type method_name( param1type param1name, param2type param2name )",
    For the list of methods, where you're replacing 'MethodName1' etc., you'll just want the method_name (getTile, etc.) bit. You'll use the other bits in the next step - the page stubs.
    If the same method is listed more than once, you just need to include it in this list once.

    For properties, its similar, but more straightforward. You'll see lines in that pastebin like this:
    r = engine->RegisterObjectProperty("CMap", "u32 tilemapwidth",
    or generically:
    r = engine->RegisterObjectProperty("Object Type", "property_type property_name",
    For the list of properties, where you're replacing Property2Name, Property2Type, etc. you'll want to replace PropertyXType with property_type and PropertyXName with property_name.

    Part two: Object Methods
    You need to go through the list of methods you've just created, clicking on them (to take you to the page for creating a page about them) and create a stub for that method there, using a simple format.

    You will get the method signature (the line describing a call to a method, made up of its return type, method name and parameters) from the same pastebin you were just getting your list of methods from. That + the object type is the only thing that you will need to paste into the standard copypaste stuff you will be adding to these wiki pages.

    Example of one already filled out: https://wiki.kag2d.com/wiki/CTileEffect::Set

    This is what the standard stubs will look like:
    Code:
    <onlyinclude>
     
    </onlyinclude>
     
    <syntaxhighlight lang="cpp">
     
    void Set(u8 effect, u32 vars)
     
    </syntaxhighlight>
     
    Object method of: [[ObjectName]]
    [[Category:Scripting]]
    [[Category:Object Methods]]
    
    Notice the 6th line there, void Set(u8 effect, u32 vars)? You'll be replacing that with the method signatures of the method you are creating the stub for at the time. For example, the 6th line above came from this line of the pastebin:
    r = engine->RegisterObjectMethod("CTileEffect", "void Set(u8 effect, u32 vars)",

    If there is more than one method variant (same method name, different return types/parameters), put them all in the syntax highlight section, like on this page, https://wiki.kag2d.com/wiki/Abs:
    <syntaxhighlight lang="cpp">
    int Maths::Abs(int v)
    float Maths::Abs(float v)
    </syntaxhighlight>
     
  2. jackitch

    jackitch :(){ :|: & };: Global Moderator Donator Tester
    1. SharSharShar - [SHARK]

    Messages:
    249
    Eff yes! I work full-time, but starting tonight I'll get on this right away. I can do this for about an hour each night. Pm me if you have any other specific requests.
     
    dnmr likes this.
  3. Shadlington

    Shadlington THD Team THD Team Administrator Global Moderator

    Messages:
    1,562
    Okay brilliant, I'll PM you some stuff to work through :D
     
  4. FuzzyBlueBaron

    FuzzyBlueBaron Warm, Caring, Benign, Good and Kind Philanthrope Global Moderator Forum Moderator Donator Tester
    1. The Young Blood Collective - [YB]

    Messages:
    2,508
    Hmm, I kinda of have a fill plate atm, but I've never been adverse to trying to overfill it some... :p

    Send me a few things and I'll see what I can do, Shad. ;)
     
  5. Antman

    Antman Base Burner

    Messages:
    344
    I want to repay you for changing my name for free long ago, so count me in :D
     
  6. ParaLogia

    ParaLogia tired Administrator Global Moderator Forum Moderator Tester Official Server Admin

    Messages:
    1,133
    Maybe I can use this to re-kick start my activity on the wiki (which, from what I can tell, is in sore need of extra work).
    PM me a bit please.
     
Mods: dnmr, Kazaco97