Modding Help Lua Error - Require help

Discussion in 'Starbound Modding' started by RexTheFox, May 29, 2017.

  1. RexTheFox

    RexTheFox Phantasmal Quasar

    i dont know what i would put in if i wanted a object to break when a player collides with it, like a collectible or something
     
  2. RexTheFox

    RexTheFox Phantasmal Quasar

    this is what i have but it crashes every time i place down the coin

    collectable.lua
    Code:
    function update(dt)
        if object.isTouching(0 entityId) then
        object.smash([true smash])
    end
    
     
  3. RexTheFox

    RexTheFox Phantasmal Quasar

    this is the coin object file

    Code:
    {
      "objectName" : "coinnsmb",
      "colonyTags" : ["outdoor"],
      "rarity" : "Common",
      "category" : "furniture",
      "price" : 55,
      "description" : "A coin from NSMB",
      "shortdescription" : "Coin",
      "race" : "generic",
    
      "apexDescription" : "This looks nothing from what i seen.",
      "avianDescription" : "I have an urge to go fast.",
      "floranDescription" : "Thissss guy issss too fassst for me.",
      "glitchDescription" : "Classic, a blue hedgehog.",
      "humanDescription" : "GOTTA GO FAST.",
      "hylotlDescription" : "a intresting artifact... a post with a hedgehog on it.",
      "novakidDescription" : "what even is this.",
    
      "inventoryIcon" : "coinnsmbicon.png",
      "orientations" : [
        {
          "image" : "coinnsmb.png:<color>",
          "imagePosition" : [-8, 0],
    
          "spaceScan" : 0.1,
          "anchors" : [  ]
        }
      ],
    
      "scripts" : [ "/objects/generic/coinNSMB/collectable.lua" ],
      "scriptDelta" : 5
    }
    
     
  4. Cyel

    Cyel Scruffy Nerf-Herder

    Your syntax is quite broken, and you aren't using that function correctly:
    It takes an entityId as a parameter; those Ids are dynamic, you aren't supposed to just throw one like that there. You'd do something like
    Code:
    function update(dt)
      --get the object's hitbox
      local boundbox = object.boundBox()
      --get an array of players colliding with that hitbox
      local players = world.playerQuery({boundbox[1],boundbox[2]}, {boundbox[3], boundBox[4]})
    
      --iterate trough that array
      for _,playerId in pairs(players) do
        --and do the check for every entities around
        if object.isTouching(playerId) then
          object.smash(true)
        end
      end
    end
    (Also, you can edit your posts via the "edit" button, instead of doing multiple posts)
     
  5. RexTheFox

    RexTheFox Phantasmal Quasar

    would i have to change the boundbox[1] ect?
     
  6. Cyel

    Cyel Scruffy Nerf-Herder

    No, boundBox is a table, and [1] is to get access to the first variable in that table
     
  7. RexTheFox

    RexTheFox Phantasmal Quasar

    something is wrong then, its crashing still
     
  8. Cyel

    Cyel Scruffy Nerf-Herder

    Ah, yeah, my bad, I messed up one letter's capitalization.
    Code:
    function update(dt)
      --get the object's hitbox
      local boundbox = object.boundBox()
      --get an array of players colliding with that hitbox
      local players = world.playerQuery({boundbox[1],boundbox[2]}, {boundbox[3], boundbox[4]})
    
      --iterate trough that array
      for _,playerId in pairs(players) do
        --and do the check for every entities around
        if object.isTouching(playerId) then
          object.smash(true)
        end
      end
    end
    Note that infos on errors and crashes can be found in your starbound.log file.

    Also, object.smash() won't drop anything by default, you'll likely need to add
    Code:
      "breakDropOptions" : [
      [ [ "coinnsmb", 1, { } ] ]
      ]
    in your .object file
     
    RexTheFox likes this.
  9. RexTheFox

    RexTheFox Phantasmal Quasar

    weird, still crashing
    Code:
    [15:21:06.319] [Info] Root: Preparing Root...
    [15:21:06.322] [Info] Root: Done preparing Root.
    [15:21:06.322] [Info] Client Version 1.2.3b (windows x86_64) Source ID: 69bc1c906122a1c61453c6cff15aa088b613db78 Protocol: 729
    [15:21:06.322] [Info] Root: Scanning for asset sources in directory '..\assets\'
    [15:21:06.681] [Info] Root: Scanning for asset sources in directory '..\mods\'
    [15:21:06.694] [Warn] Root: Unrecognized file in asset directory 'Screenshot 1.PNG', skipping
    [15:21:06.694] [Warn] Root: Unrecognized file in asset directory 'mods_go_here', skipping
    [15:21:06.694] [Info] Root: Detected asset source named 'base' at '..\assets\packed.pak'
    [15:21:06.694] [Info] Root: Detected asset source named 'MegaCrossover' at '..\mods\MegaCrossover'
    [15:21:06.694] [Info] Root: Detected unnamed asset source at '..\assets\user'
    [15:21:06.694] [Info] Loading assets from: '..\assets\packed.pak'
    [15:21:07.133] [Info] Loading assets from: '..\mods\MegaCrossover'
    [15:21:07.153] [Info] Loading assets from: '..\assets\user'
    [15:21:08.280] [Info] Assets digest is 6539a0584e757c45630cfc29f7bbd539befc02e7743515a9e52e4cd4a4ab2953
    [15:21:08.280] [Info] Root: Loaded Assets in 1.9583 seconds
    [15:21:08.285] [Info] Application: Initializing SDL Video
    [15:21:08.298] [Info] Application: Initializing SDL Joystick
    [15:21:08.334] [Info] Application: Initializing SDL Sound
    [15:21:08.447] [Info] Initialized Steam services
    [15:21:08.448] [Info] Application: Creating SDL Window
    [15:21:08.588] [Info] Application: Enabling VSync with late swap tearing
    [15:21:08.615] [Info] Application: Opened default audio device with 44.1khz / 16 bit stereo audio, 2048 sample size buffer
    [15:21:08.618] [Info] OpenGL version: '4.4.0 - Build 20.19.15.4463' vendor: 'Intel' renderer: 'Intel(R) HD Graphics 520' shader: '4.40 - Build 20.19.15.4463'
    [15:21:08.627] [Info] Application: initialization...
    [15:21:08.629] [Info] Root: Loaded Configuration in 0.00170983 seconds
    [15:21:08.635] [Info] Application: renderer initialization...
    [15:21:08.651] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 128
    [15:21:08.651] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 64
    [15:21:08.653] [Info] Root: Loaded ImageMetadataDatabase in 5.92593e-06 seconds
    [15:21:08.673] [Info] Application: main update loop...
    [15:21:08.675] [Info] Loading mods from user generated content with id '729523203' from directory 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\729523203'
    [15:21:08.675] [Info] Loading mods from user generated content with id '930050525' from directory 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\930050525'
    [15:21:08.675] [Info] Reloading to include all user generated content
    [15:21:08.675] [Info] Root: Reloading from disk
    [15:21:08.675] [Info] Root: Writing runtime configuration to '..\storage\starbound.config'
    [15:21:08.734] [Info] Root: Loaded Configuration in 0.00172366 seconds
    [15:21:08.734] [Info] Root: Scanning for asset sources in directory '..\assets\'
    [15:21:09.177] [Info] Root: Scanning for asset sources in directory '..\mods\'
    [15:21:09.190] [Warn] Root: Unrecognized file in asset directory 'Screenshot 1.PNG', skipping
    [15:21:09.190] [Warn] Root: Unrecognized file in asset directory 'mods_go_here', skipping
    [15:21:09.190] [Info] Root: Scanning for asset sources in directory 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\729523203'
    [15:21:09.191] [Info] Root: Scanning for asset sources in directory 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\930050525'
    [15:21:09.191] [Info] Root: Detected asset source named 'base' at '..\assets\packed.pak'
    [15:21:09.191] [Info] Root: Detected asset source named 'MegaCrossover' at '..\mods\MegaCrossover'
    [15:21:09.191] [Info] Root: Detected asset source named 'Better Barren' at 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\729523203\contents.pak'
    [15:21:09.191] [Info] Root: Detected asset source named 'Text To Speech Glitch Voices' at 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\930050525\contents.pak'
    [15:21:09.191] [Info] Root: Detected unnamed asset source at '..\assets\user'
    [15:21:09.191] [Info] Loading assets from: '..\assets\packed.pak'
    [15:21:09.758] [Info] Loading assets from: '..\mods\MegaCrossover'
    [15:21:09.779] [Info] Loading assets from: 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\729523203\contents.pak'
    [15:21:09.780] [Info] Loading assets from: 'C:\Program Files (x86)\Steam Games\steamapps\workshop\content\211820\930050525\contents.pak'
    [15:21:09.781] [Info] Loading assets from: '..\assets\user'
    [15:21:10.903] [Info] Assets digest is b3267ec57e6f5bdddad7e2797e5ee41bc176e9f38c3a387ebc2954f7097fa450
    [15:21:10.903] [Info] Root: Loaded Assets in 2.16898 seconds
    [15:21:10.907] [Info] Root: Loaded ImageMetadataDatabase in 5.53087e-06 seconds
    [15:21:10.919] [Info] Root: Loaded NameGenerator in 0.0154967 seconds
    [15:21:10.925] [Error] OpenGL errors this frame:  GL_INVALID_VALUE
    [15:21:11.085] [Info] Root: Loaded PlantDatabase in 0.165744 seconds
    [15:21:11.719] [Info] Root: Loaded ObjectDatabase in 0.814491 seconds
    [15:21:11.876] [Info] Root: Loaded ProjectileDatabase in 0.791017 seconds
    [15:21:12.016] [Info] Root: Loaded NpcDatabase in 0.139416 seconds
    [15:21:12.018] [Info] Root: Loaded StagehandDatabase in 0.00182242 seconds
    [15:21:12.024] [Info] Root: Loaded VehicleDatabase in 0.00596939 seconds
    [15:21:12.029] [Info] Root: Loaded PlayerFactory in 0.00489087 seconds
    [15:21:12.081] [Info] Root: Loaded MonsterDatabase in 0.362892 seconds
    [15:21:12.084] [Info] Root: Loaded VersioningDatabase in 0.00304395 seconds
    [15:21:12.084] [Info] Root: Loaded EntityFactory in 0.0558021 seconds
    [15:21:12.350] [Info] Root: Loaded ParticleDatabase in 0.265341 seconds
    [15:21:12.828] [Info] Root: Loaded MaterialDatabase in 0.743279 seconds
    [15:21:12.838] [Info] Root: Loaded TerrainDatabase in 0.00985482 seconds
    [15:21:12.915] [Info] Root: Loaded BiomeDatabase in 0.0773231 seconds
    [15:21:12.917] [Info] Root: Loaded LiquidsDatabase in 0.00150124 seconds
    [15:21:12.942] [Info] Root: Loaded StatusEffectDatabase in 0.025553 seconds
    [15:21:13.460] [Info] Root: Loaded DamageDatabase in 0.516894 seconds
    [15:21:13.468] [Info] Root: Loaded EffectSourceDatabase in 0.00818885 seconds
    [15:21:13.471] [Info] Root: Loaded FunctionDatabase in 0.00348642 seconds
    [15:21:13.510] [Info] Root: Loaded TreasureDatabase in 0.0384281 seconds
    [15:21:13.524] [Error] Could not load image asset '/Objects/Teleporter/gpipebottomtel/gpipebottomtellit.png:default', using placeholder default.
    (AssetException) No associated frames file found for image '/Objects/Teleporter/gpipebottomtel/gpipebottomtellit.png' while resolving image frame '/Objects/Teleporter/gpipebottomtel/gpipebottomtellit.png:default'
    [15:21:13.965] [Info] Root: Loaded DungeonDefinitions in 0.455231 seconds
    [15:21:13.965] [Info] Root: Loaded TilesetDatabase in 5.29383e-05 seconds
    [15:21:13.971] [Info] Root: Loaded StatisticsDatabase in 0.00493709 seconds
    [15:21:13.971] [Info] Root: Loaded EmoteProcessor in 8.9284e-05 seconds
    [15:21:13.987] [Info] Root: Loaded SpeciesDatabase in 0.0161438 seconds
    [15:21:14.020] [Info] Root: Loaded QuestTemplateDatabase in 0.0330959 seconds
    [15:21:14.022] [Info] Root: Loaded AiDatabase in 0.00199269 seconds
    [15:21:14.026] [Info] Root: Loaded TechDatabase in 0.00354173 seconds
    [15:21:14.039] [Info] Root: Loaded CodexDatabase in 0.0136095 seconds
    [15:21:14.649] [Info] Root: Loaded BehaviorDatabase in 0.60967 seconds
    [15:21:14.653] [Info] Root: Loaded DanceDatabase in 0.00361087 seconds
    [15:21:14.662] [Info] Root: Loaded SpawnTypeDatabase in 0.0090489 seconds
    [15:21:14.665] [Info] Root: Loaded RadioMessageDatabase in 0.00372188 seconds
    [15:21:16.502] [Info] Root: Loaded ItemDatabase in 4.42039 seconds
    [15:21:16.724] [Info] Root: Loaded CollectionDatabase in 2.05847 seconds
    [15:21:17.233] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 256
    [15:21:19.892] [Info] UniverseServer: Acquiring universe lock file
    [15:21:19.893] [Info] UniverseServer: Loading settings
    [15:21:19.895] [Info] UniverseServer: Starting UniverseServer with UUID: 16d8ac31b34f178f30cb7d8a3f9d21ee
    [15:21:19.904] [Info] UniverseServer: Logged in player 'Michael-Mod Test' locally
    [15:21:19.904] [Info] UniverseServer: Logged in account '<anonymous>' as player 'Michael-Mod Test' from address local
    [15:21:19.987] [Info] UniverseServer: Reviving player at ClientShipWorld:6f3dbff1107be99f63f9ff7d7f494c57
    [15:21:19.987] [Info] UniverseServer: Client 'Michael-Mod Test' <1> (local) connected
    [15:21:19.995] [Info] UniverseClient: Joined server as client 1
    [15:21:20.080] [Info] UniverseServer: Loading client ship world ClientShipWorld:6f3dbff1107be99f63f9ff7d7f494c57
    [15:21:20.258] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 64
    [15:21:20.258] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 128
    [15:21:20.267] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 256
    [15:21:20.267] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 256
    [15:21:20.267] [Info] Setting steam rich presence connection as steam id 76561198075019221
    [15:21:20.815] [Info] UniverseServer: Warping player 1 to ClientShipWorld:6f3dbff1107be99f63f9ff7d7f494c57
    [15:21:23.749] [Info] UniverseServer: Loading celestial world -607390636:278490534:75337367:2
    [15:21:24.051] [Info] UniverseServer: Warping player 1 to CelestialWorld:-607390636:278490534:75337367:2
    [15:21:24.058] [Info] UniverseServer: Stopping idle world ClientShipWorld:6f3dbff1107be99f63f9ff7d7f494c57
    [15:21:24.058] [Info] Client received world stop packet, leaving: Removed
    [15:21:30.645] [Error] Exception caught loading asset: /objects/generic/coinNSMB/collectable.lua, (AssetException) No such asset '/objects/generic/coinNSMB/collectable.lua'
    [0] 7ff7d86a4403 Star::captureStack
    [1] 7ff7d86a318e Star::StarException::StarException
    [2] 7ff7d86c0154 Star::Assets::read
    [3] 7ff7d86b63ea <lambda_d89d63ab62ee311906d2449a8fa8f4ad>::operator()
    [4] 7ff7d86ad74f std::_Invoker_functor::_Call<<lambda_d89d63ab62ee311906d2449a8fa8f4ad> & __ptr64>
    [5] 7ff7d86b1196 std::invoke<<lambda_d89d63ab62ee311906d2449a8fa8f4ad> & __ptr64>
    [6] 7ff7d86aeea0 std::_Invoke_ret<std::shared_ptr<Star::Assets::AssetData>,<lambda_d89d63ab62ee311906d2449a8fa8f4ad> & __ptr64>
    [7] 7ff7d86b74a6 std::_Func_impl<<lambda_d89d63ab62ee311906d2449a8fa8f4ad>,std::allocator<int>,std::shared_ptr<Star::Assets::AssetData> >::_Do_call
    [8] 7ff7d8da3787 std::_Func_class<Star::WidgetConstructResult,Star::String const & __ptr64,Star::Json const & __ptr64>::operator()
    [9] 7ff7d86bfbe8 Star::Assets::processAssetData
    [10] 7ff7d86bd088 Star::Assets::loadBytes
    [11] 7ff7d86bceb9 Star::Assets::loadAsset
    [12] 7ff7d86baaef Star::Assets::doLoad
    [13] 7ff7d86bc06b Star::Assets::getAsset
    [14] 7ff7d86b9d2c Star::Assets::bytes
    [15] 7ff7d8ca2a5b Star::LuaRoot::ScriptCache::loadScript
    [16] 7ff7d8ca29a5 Star::LuaRoot::ScriptCache::loadContextScript
    [17] 7ff7d8ca26ee Star::LuaRoot::createContext
    [18] 7ff7d8c90cf3 Star::LuaBaseComponent::init
    [19] 7ff7d891b4be Star::Object::init
    [20] 7ff7d8be79fe Star::WorldServer::addEntity
    [21] 7ff7d8bf14fc Star::WorldServer::handleIncomingPackets
    [22] 7ff7d8c05b2b Star::WorldServerThread::update
    [23] 7ff7d8c056a8 Star::WorldServerThread::run
    [24] 7ff7d86a0f2e Star::ThreadImpl::runThread
    [25] 7ffb5e368364 BaseThreadInitThunk
    [26] 7ffb5e9470d1 RtlUserThreadStart
    [15:21:30.654] [Error] WorldServerThread exception caught handling incoming packets for client 1: (AssetException) Error loading asset /objects/generic/coinNSMB/collectable.lua
    [0] 7ff7d86a4403 Star::captureStack
    [1] 7ff7d86a318e Star::StarException::StarException
    [2] 7ff7d86b056a Star::AssetException::format<Star::AssetPath>
    [3] 7ff7d86bc11b Star::Assets::getAsset
    [4] 7ff7d86b9d2c Star::Assets::bytes
    [5] 7ff7d8ca2a5b Star::LuaRoot::ScriptCache::loadScript
    [6] 7ff7d8ca29a5 Star::LuaRoot::ScriptCache::loadContextScript
    [7] 7ff7d8ca26ee Star::LuaRoot::createContext
    [8] 7ff7d8c90cf3 Star::LuaBaseComponent::init
    [9] 7ff7d891b4be Star::Object::init
    [10] 7ff7d8be79fe Star::WorldServer::addEntity
    [11] 7ff7d8bf14fc Star::WorldServer::handleIncomingPackets
    [12] 7ff7d8c05b2b Star::WorldServerThread::update
    [13] 7ff7d8c056a8 Star::WorldServerThread::run
    [14] 7ff7d86a0f2e Star::ThreadImpl::runThread
    [15] 7ffb5e368364 BaseThreadInitThunk
    [16] 7ffb5e9470d1 RtlUserThreadStart
    [15:21:30.666] [Info] Client received world stop packet, leaving: Removed
    [15:21:30.755] [Info] UniverseServer: Client 'Michael-Mod Test' <1> (local) disconnected for reason: Incoming client packet has caused exception
    [15:21:30.755] [Info] UniverseServer: Stopping idle world CelestialWorld:-607390636:278490534:75337367:2
    [15:21:30.756] [Error] You were disconnected from the server for the following reason:
    Incoming client packet has caused exception
    [15:21:31.027] [Info] UniverseServer: Stopping UniverseServer
    [15:21:31.084] [Info] Clearing steam rich presence connection
    [15:21:32.268] [Info] detected supported OpenGL texture size 16384, using atlasNumCells 256
    [15:21:33.319] [Info] Application: quit requested
    [15:21:33.320] [Info] Application: quitting...
    [15:21:33.320] [Info] Application: shutdown...
    [15:21:33.456] [Info] Root: Shutting down Root
    [15:21:33.758] [Info] Application: Destroying SDL Window
    [15:21:33.822] [Info] Application: stopped gracefully
    
     
  10. Cyel

    Cyel Scruffy Nerf-Herder

    The problem isn't with the script's code, your .object doesn't specify a proper path to the script.

    (also, remove the "true" in smash, as I just checked and it causes it to not drop anything upon breaking. -> object.smash()
     
  11. RexTheFox

    RexTheFox Phantasmal Quasar

    i set the path right, or does it have to be a certain thing at the start to choose the mod location?
     
  12. RexTheFox

    RexTheFox Phantasmal Quasar

    ok got it working, the only request now is, how can i change the drop item
     

Share This Page