Need Help C Mod Element

  • MassacreLand
    11th Feb 2012 Member 0 Permalink
    I need help making it so that wood grows plant off of it when introduced to watr.
    And I need help with some other elemental mods if anyone is willing!
    I took the watr and salt water thing and edited it but it didnt seem to work.

  • vanquish349
    11th Feb 2012 Member 0 Permalink
    @MassacreLand (View Post)
    have a look at plants code
  • MassacreLand
    11th Feb 2012 Member 0 Permalink
    @vanquish349 (View Post)
    I tried that :/ It did not error in any way but it would not allow the plnt to grow off of wood from watr.
    Could you look at it? You dont have to do anything just look at it and tell me what to change. Ill let you know if it worked or not. I do have to create A wood.c file correct? Because I do not believe there is already one in powder toy.
  • vanquish349
    11th Feb 2012 Member 0 Permalink
    @MassacreLand (View Post)
    i will see if i can knock one up quickly

    edit: done, you will have to add the stuff to powder.h and elementdata.c to get wood to include the function
    #include

    int update_WOOD(UPDATE_FUNC_ARGS) {
    int r, rx, ry, np;
    for (rx=-2; rx<3; rx++)<br/> for (ry=-2; ry<3; ry++)<br/> if (x+rx>=0 && y+ry>0 && x+rx {
    r = pmap[y+ry][x+rx];
    if (!r)
    continue;
    if ((r&0xFF)==PT_WATR && 1>(rand()%250))
    {
    np = create_part(r>>8,x+rx,y+ry,PT_PLNT);
    if (np<0) continue;<br/> parts[np].life = 0;
    }

    }
    return 0;
    }


    edit: changed the tabs to spaces
  • MassacreLand
    11th Feb 2012 Member 0 Permalink
    @vanquish349 (View Post)

    E:\Unknown\L\Powder\Mod\MassacreToy\src\elements\wood.cIn function 'update_WOOD':
    E:\Unknown\L\Powder\Mod\MassacreToy\src\elements\wood.c5error: expected expression before '<' token
    E:\Unknown\L\Powder\Mod\MassacreToy\src\elements\wood.c17error: expected declaration or statement at end of input
    === Build finished: 2 errors, 0 warnings ===

  • vanquish349
    11th Feb 2012 Member 0 Permalink
    @MassacreLand (View Post)
    ummm you need to follow the wiki on how to make an element use a .c file
  • MasterMind555
    11th Feb 2012 Member 0 Permalink

    MassacreLand:

    @vanquish349 (View Post)

    E:\Unknown\L\Powder\Mod\MassacreToy\src\elements\wood.cIn function 'update_WOOD':

  • jacksonmj
    11th Feb 2012 Developer 0 Permalink
    The source code in @vanquish349's post is slightly messed up because the forum is trying to interpret it as HTML. Quote the post and then copy the source code.

    Here it is with the <'s and >'s fixed:
    #include <element.h>

    int update_WOOD(UPDATE_FUNC_ARGS) {
    int r, rx, ry, np;
    for (rx=-2; rx<3; rx++)
    for (ry=-2; ry<3; ry++)
    if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
    {
    r = pmap[y+ry][x+rx];
    if (!r)
    continue;
    if ((r&0xFF)==PT_WATR && 1>(rand()%250))
    {
    np = create_part(r>>8,x+rx,y+ry,PT_PLNT);
    if (np<0) continue;
    parts[np].life = 0;
    }

    }
    return 0;
    }
  • MassacreLand
    11th Feb 2012 Member 0 Permalink

    @vanquish349 (View Post)


    I know how to make
    an element using c.

    @jacksonmj (View Post)
    @MasterMind555 (View Post)

    Thank you very much for helping me. Thank you!
    Your guys help is damn near the only thing that is making this mod possible. Other wise I'd still be trying to compile the whole thing. XD