Modding Help LUA world.damageTiles problems

Discussion in 'Starbound Modding' started by C0bra5, Apr 24, 2016.

  1. C0bra5

    C0bra5 Oxygen Tank

    does anyone know what the parameters are for this function?
    Code:
    world.damageTiles(...)
    
    all i managed to find out is that the 5th parameter is a xy coordinate because the error said so.
    but even if i try world.damageTiles(1,1,1,1,mcontroller.position());

    I'm getting this error, i know what it means, it complains about not beeing able to parse a "LuaValue" which could be basically anything to a float... the thing is the stack trace in't exactly meaningful and adding a bunch of ones after the position doesn't work.
    Code:
    [05:30:10.891] Error: Exception while invoking lua function 'input'. (LuaException) Error code 2, [string "/tech/sblaud/sblaud.lua"]:22: (LuaConversionException) Error converting LuaValue to type 'float'
    [0] 7ff692bd1933
    [1] 7ff692bce2c8
    [2] 7ff692538a7c
    [3] 7ff6925389c5
    [4] 7ff6925336f6
    [5] 7ff6926c7512
    [6] 7ff6926e27bc
    [7] 7ff692835c7f
    [8] 7ff6928051ef
    [9] 7ff692818770
    [10] 7ff69280b9a9
    [11] 7ff69283ad7b
    [12] 7ff692c2b816
    [13] 7ff692c2aa8f
    [14] 7ff692c75f1a
    [15] 7ff692c7d832
    [16] 7ff692c76064
    [17] 7ff692c765fb
    [18] 7ff692c76100
    [19] 7ff692c64d54
    [20] 7ff6926c48e9
    [21] 7ff692a16a05
    [22] 7ff692a1694b
    [23] 7ff692a1017e
    [24] 7ff6925fa1c0
    [25] 7ff692637863
    [26] 7ff6925ef9b9
    [27] 7ff69244e49d
    [28] 7ff69244b794
    [29] 7ff692bb9a6d
    [30] 7ff692461d70
    [31] 7ff692d5035b
    [32] 7ff692d500c3
    [33] 7ff692d18a1e
    [34] 7fff9b468102 BaseThreadInitThunk
    [35] 7fff9db1c5b4 RtlUserThreadStart
    [0] 7ff692bd1933
    [1] 7ff692bce2c8
    [2] 7ff692538b65
    [3] 7ff692c2327b
    [4] 7ff6926c4902
    [5] 7ff692a16a05
    [6] 7ff692a1694b
    [7] 7ff692a1017e
    [8] 7ff6925fa1c0
    [9] 7ff692637863
    [10] 7ff6925ef9b9
    [11] 7ff69244e49d
    [12] 7ff69244b794
    [13] 7ff692bb9a6d
    [14] 7ff692461d70
    [15] 7ff692d5035b
    [16] 7ff692d500c3
    [17] 7ff692d18a1e
    [18] 7fff9b468102 BaseThreadInitThunk
    [19] 7fff9db1c5b4 RtlUserThreadStart
    [05:30:10.903] Error: Exception caught in client main-loop: (LuaComponentException) Duplicate callbacks named 'tech' in LuaBaseComponent
    [0] 7ff692bd1933
    [1] 7ff692bce2c8
    [2] 7ff692698395
    [3] 7ff6926975f6
    [4] 7ff69269641e
    [5] 7ff692a125ec
    [6] 7ff692a0fbbc
    [7] 7ff6925fa1c0
    [8] 7ff692637863
    [9] 7ff6925ef9b9
    [10] 7ff69244e49d
    [11] 7ff69244b794
    [12] 7ff692bb9a6d
    [13] 7ff692461d70
    [14] 7ff692d5035b
    [15] 7ff692d500c3
    [16] 7ff692d18a1e
    [17] 7fff9b468102 BaseThreadInitThunk
    [18] 7fff9db1c5b4 RtlUserThreadStart
    
     
  2. v6ooo

    v6ooo Space Kumquat

    Has it changed since the documentation on it was made? otherwise here's the documentation

    There's this
    http://starbounder.org/Modding:Lua/Tables/World#world.damageTiles

    and this
    Code:
    --- Applies damage to the tiles at the given positions
    --
    -- @param positions List of { x, y } positions to damage tiles at
    -- @param layer The tile layer to damage: "foreground" or "background"
    -- @param sourcePosition The { x, y } position of the cause of the damage
    -- @param type The type of damage to apply, allowed values are:
    -- "plantish", "blockish", "beamish", "explosive", "fire", "tilling"
    -- or "crushing". Note that "crushing" damage will prevent destroyed
    -- tiles from dropping a material item.
    -- @param amount The amount of damage to apply to each tile
    --
    -- @returns true if any tiles were actually damaged, false otherwise
    damageTiles = function(positions, layer, sourcePosition, type, amount) end,
    
     
    Errors4l likes this.
  3. C0bra5

    C0bra5 Oxygen Tank

    i'll have to test it later but it might just work who knows, it's 5am and i need to go to bed
     
  4. Errors4l

    Errors4l Spaceman Spiff

    The documentation v6ooo posted is correct. Here's an example, I'm sure you can figure out the rest!

    Code:
    local pos = {10,20}
    world.damageTiles({pos}, "foreground", pos, "blockish", 9999, 0)
    This will break a single block at x10,y=20.
    I'm not actually sure if the last parameter '0' does anything. I use it everywhere ><. Maybe it indicates whether the broken material should be dropped or not, maybe not. As far as I can remember 'crushing' no longer exists as a damage type, but I may be wrong.
     
    C0bra5 likes this.
  5. C0bra5

    C0bra5 Oxygen Tank

    ya it toes nothing, the function only has 5 parameters and the 0 is a sixth
     
  6. Errors4l

    Errors4l Spaceman Spiff

    Just did a small experiment; the 6th parameter is in fact related to the tile dropping or not.

    Expected value: class Star::Maybe<unsigned int>
    Code used:
    Code:
    local pos = tech.aimPosition()
    world.damageTiles({pos}, "foreground", pos, "blockish", 9999, 0)
    world.damageTiles({{pos[1] + 2, pos[2]}}, "foreground", pos, "blockish", 9999, 1)
    Result:
    [​IMG]

    Edit: I'm not sure what the number actually does, it just seems like a dumb implementation of a boolean to me (0 = false, not 0 = true).
    Edit 2: ^ It is indeed.
     
    Last edited: Apr 25, 2016
  7. C0bra5

    C0bra5 Oxygen Tank

    well that is interesting...
     

Share This Page