Modding Discussion Colony Manager (WIP title)

Discussion in 'Starbound Modding' started by cybersam, Sep 5, 2016.

  1. cybersam

    cybersam Subatomic Cosmonaut

    thanks for the info for far...
    i've been trying to make things work on my end...
    it seems that you won't need that extra variable in the end...
    as i wasn't able to load the things needed due to limitations...

    also i'm now overwriting the isRentDue() function to activate the nodes for my scritp... so it won't conflict with yourscript...
    i'm still trying a few things out before releasing it...

    also... it seems like there are some changes in the new nightlies for the tenants and the colonydeed scripts

    also if i'm seeing this correctly... it lookslike they are adding support for inventory modding... so we will finaly be able to modify the inventory.. well i hope... ^_^


    @LordBaconator
    about the vacated state..
    that actually sounds good... just need to think of a way and position where to put it ^_^

    @bk3k
    thanks for the debug info... that info should be really be put somewhere people can find easier ^_^''

    ----
    edit...
    as for git hub... its a good idea...
    first i'll need to clean up my code...
    i can't really show this as it is right now xD
     
  2. bk3k

    bk3k Oxygen Tank

    If you want to have a lot more current state info in your logs about what you're working on without a lot of effort on your part, you could use my terribly incomplete logging thingy. Incomplete or not, it is still pretty useful and can easily output something like this(directly pulled from my log)


    Code:
    End of init() for object: 4 at location (1348.0, 686.0) -
      Beginning dump : {
        self : {
          chameleonCooldown : 0,
          openCooldown : 0,
          npcClosed : false,
          doDebug : true,
          closeCooldown : 0,
        }
      }
      Ending dump of table : self
    from End of init() for object: 4 at location (1348.0, 686.0) -
    
    End of init() for object: 4 at location (1348.0, 686.0) -
      Beginning dump : {
        storage : {
          playerOpened : false,
          queryRadius : 5,
          realSpaces : {
            1 : {
              1 : 1348,
              2 : 686
            },
            2 : {
              1 : 1348,
              2 : 687
            },
            3 : {
              1 : 1348,
              2 : 688
            },
            4 : {
              1 : 1348,
              2 : 689
            },
            5 : {
              1 : 1348,
              2 : 690
            },
            6 : {
              1 : 1348,
              2 : 691
            },
            7 : {
              1 : 1348,
              2 : 692
            },
            8 : {
              1 : 1348,
              2 : 693
            },
            9 : {
              1 : 1349,
              2 : 686
            },
            10 : {
              1 : 1349,
              2 : 687
            },
            11 : {
              1 : 1349,
              2 : 688
            },
            12 : {
              1 : 1349,
              2 : 689
            },
            13 : {
              1 : 1349,
              2 : 690
            },
            14 : {
              1 : 1349,
              2 : 691
            },
            15 : {
              1 : 1349,
              2 : 692
            },
            16 : {
              1 : 1349,
              2 : 693
            }
          },
          lightAware : false,
          doorException : false,
          id : 4,
          noAuto : true,
          doorDirection : -1,
          objectName : "bk3k_chameleonDoor",
          out0 : false,
          maxOutputNode : -1,
          lightColors : {
            1 : {
              1 : 0,
              2 : 0,
              3 : 0,
              4 : 0
            },
            2 : {
              1 : 0,
              2 : 0,
              3 : 0,
              4 : 0
            }
          },
          isHorizontal : false,
          doorPosition : {
            1 : 1348.0,
            2 : 686.0
          },
          liquidActions : {
            default : "ignore",
          },
          wireControlled : false,
          scanTargets : {
            1 : "player",
            2 : "vehicle"
          },
          state : false,
          locked : false,
          noNPCuse : false,
          matTableClosed : {
            1 : {
              1 : {
                1 : {
                  1 : 0,
                  2 : 0
                },
                2 : "moondust"
              },
              2 : {
                1 : {
                  1 : 0,
                  2 : 1
                },
                2 : "moondust"
              },
              3 : {
                1 : {
                  1 : 0,
                  2 : 2
                },
                2 : "moondust"
              },
              4 : {
                1 : {
                  1 : 0,
                  2 : 3
                },
                2 : "moondust"
              },
              5 : {
                1 : {
                  1 : 0,
                  2 : 4
                },
                2 : "moondust"
              },
              6 : {
                1 : {
                  1 : 0,
                  2 : 5
                },
                2 : "moondust"
              },
              7 : {
                1 : {
                  1 : 0,
                  2 : 6
                },
                2 : "moondust"
              },
              8 : {
                1 : {
                  1 : 0,
                  2 : 7
                },
                2 : "moondust"
              },
              9 : {
                1 : {
                  1 : 1,
                  2 : 0
                },
                2 : "moondust"
              },
              10 : {
                1 : {
                  1 : 1,
                  2 : 1
                },
                2 : "moondust"
              },
              11 : {
                1 : {
                  1 : 1,
                  2 : 2
                },
                2 : "moondust"
              },
              12 : {
                1 : {
                  1 : 1,
                  2 : 3
                },
                2 : "moondust"
              },
              13 : {
                1 : {
                  1 : 1,
                  2 : 4
                },
                2 : "moondust"
              },
              14 : {
                1 : {
                  1 : 1,
                  2 : 5
                },
                2 : "moondust"
              },
              15 : {
                1 : {
                  1 : 1,
                  2 : 6
                },
                2 : "moondust"
              },
              16 : {
                1 : {
                  1 : 1,
                  2 : 7
                },
                2 : "moondust"
              }
            },
            2 : {
              1 : {
                1 : {
                  1 : 0,
                  2 : 0
                },
                2 : "moondust"
              },
              2 : {
                1 : {
                  1 : 0,
                  2 : 1
                },
                2 : "moondust"
              },
              3 : {
                1 : {
                  1 : 0,
                  2 : 2
                },
                2 : "moondust"
              },
              4 : {
                1 : {
                  1 : 0,
                  2 : 3
                },
                2 : "moondust"
              },
              5 : {
                1 : {
                  1 : 0,
                  2 : 4
                },
                2 : "moondust"
              },
              6 : {
                1 : {
                  1 : 0,
                  2 : 5
                },
                2 : "moondust"
              },
              7 : {
                1 : {
                  1 : 0,
                  2 : 6
                },
                2 : "moondust"
              },
              8 : {
                1 : {
                  1 : 0,
                  2 : 7
                },
                2 : "moondust"
              },
              9 : {
                1 : {
                  1 : 1,
                  2 : 0
                },
                2 : "moondust"
              },
              10 : {
                1 : {
                  1 : 1,
                  2 : 1
                },
                2 : "moondust"
              },
              11 : {
                1 : {
                  1 : 1,
                  2 : 2
                },
                2 : "moondust"
              },
              12 : {
                1 : {
                  1 : 1,
                  2 : 3
                },
                2 : "moondust"
              },
              13 : {
                1 : {
                  1 : 1,
                  2 : 4
                },
                2 : "moondust"
              },
              14 : {
                1 : {
                  1 : 1,
                  2 : 5
                },
                2 : "moondust"
              },
              15 : {
                1 : {
                  1 : 1,
                  2 : 6
                },
                2 : "moondust"
              },
              16 : {
                1 : {
                  1 : 1,
                  2 : 7
                },
                2 : "moondust"
              }
            }
          },
          spaces : {
            1 : {
              1 : 0,
              2 : 0
            },
            2 : {
              1 : 0,
              2 : 1
            },
            3 : {
              1 : 0,
              2 : 2
            },
            4 : {
              1 : 0,
              2 : 3
            },
            5 : {
              1 : 0,
              2 : 4
            },
            6 : {
              1 : 0,
              2 : 5
            },
            7 : {
              1 : 0,
              2 : 6
            },
            8 : {
              1 : 0,
              2 : 7
            },
            9 : {
              1 : 1,
              2 : 0
            },
            10 : {
              1 : 1,
              2 : 1
            },
            11 : {
              1 : 1,
              2 : 2
            },
            12 : {
              1 : 1,
              2 : 3
            },
            13 : {
              1 : 1,
              2 : 4
            },
            14 : {
              1 : 1,
              2 : 5
            },
            15 : {
              1 : 1,
              2 : 6
            },
            16 : {
              1 : 1,
              2 : 7
            }
          },
          openMaterialSpaces : {
          },
          out1 : false,
          closedMatSpacesDefined : false,
          corners : {
            lowerLeft : {
              1 : 1348,
              2 : 686
            },
            upperRight : {
              1 : 1349,
              2 : 693
            },
            lowerRight : {
              1 : 1349,
              2 : 686
            },
            upperLeft : {
              1 : 1348,
              2 : 693
            },
          },
          openingAnimation_stateName : "opening",
          boundVar : "CollisionArea",
          playerClosed : false,
          anyInputNodeConnected : false,
          queryCenter : {
            1 : 1348.5,
            2 : 689.5
          },
          lockingAnimation_stateName : "locking",
          liquidAware : false,
          postInit : true,
          lockedAnimation_stateName : "locked",
          maxInputNode : -1,
          defaultInteractive : true,
          wireOpened : false,
          center : {
            1 : 1348.5,
            2 : 689.5
          },
          noClearOpen : false,
          closedMaterialSpaces : {
            1 : {
              1 : {
                1 : 0,
                2 : 0
              },
              2 : "moondust"
            },
            2 : {
              1 : {
                1 : 0,
                2 : 1
              },
              2 : "moondust"
            },
            3 : {
              1 : {
                1 : 0,
                2 : 2
              },
              2 : "moondust"
            },
            4 : {
              1 : {
                1 : 0,
                2 : 3
              },
              2 : "moondust"
            },
            5 : {
              1 : {
                1 : 0,
                2 : 4
              },
              2 : "moondust"
            },
            6 : {
              1 : {
                1 : 0,
                2 : 5
              },
              2 : "moondust"
            },
            7 : {
              1 : {
                1 : 0,
                2 : 6
              },
              2 : "moondust"
            },
            8 : {
              1 : {
                1 : 0,
                2 : 7
              },
              2 : "moondust"
            },
            9 : {
              1 : {
                1 : 1,
                2 : 0
              },
              2 : "moondust"
            },
            10 : {
              1 : {
                1 : 1,
                2 : 1
              },
              2 : "moondust"
            },
            11 : {
              1 : {
                1 : 1,
                2 : 2
              },
              2 : "moondust"
            },
            12 : {
              1 : {
                1 : 1,
                2 : 3
              },
              2 : "moondust"
            },
            13 : {
              1 : {
                1 : 1,
                2 : 4
              },
              2 : "moondust"
            },
            14 : {
              1 : {
                1 : 1,
                2 : 5
              },
              2 : "moondust"
            },
            15 : {
              1 : {
                1 : 1,
                2 : 6
              },
              2 : "moondust"
            },
            16 : {
              1 : {
                1 : 1,
                2 : 7
              },
              2 : "moondust"
            }
          },
          defaultLocked : false,
          chameleonSet : true,
          matTableOpen : {
            1 : {
            },
            2 : {
            }
          },
          quickCheck : true,
        }
      }
      Ending dump of table : storage
    from End of init() for object: 4 at location (1348.0, 686.0)
    All that involved was me calling this function from init()

    Code:
    function initPackages()
      cMath = _ENV.bk3kcMath
      L = _ENV.bk3kLogger
    
      if self.doDebug then
        L = _ENV.bk3kLogger
        L.context = {"Beginning of ", "init()", " for object: ", tostring(storage.id), " at location ", cMath.cString(storage.doorPosition), " - " }
         
        L.dumpTable.storage = storage
        L.dumpTable.self = self       
          --you COULD just do L.dump({storage, self}, L.context) but
          --L.dump(L.dumpTable, L.context) preserves the table names in the logs.
      else
        L = _ENV.bk3kLogger.blankPackage()
         
      end
     
    end
    And then at the end of init() I do this.

    Code:
      L.context[1] = "End of "
      
      L.dumpTable.storage = storage  --updating before dump
      L.dumpTable.self = self  -- but could go the metatable route if preferred to avoid the need
      L.dump(L.dumpTable, L.context)
    Initially it would say at the beginning of init() but I swapped a string piece in the context table. Likewise I can swap a string piece to tell me a different function name, or anything really. So that's a pretty versatile setup, but totally optional. You can just dump values/tables/etc if you prefer, but context and dumpTable provide convenient, segregated tables so they won't accidentally end up as part of the dumped data(thus doubling the data).



    You send dump() a table containing the tables you want to dump(in my example state and self), and a table containing strings (which will be concatenated automatically) or a single string. The strings are to provide context to the values. Such as in my example it tells me that it is being called at the end of init() from a door at a particular position.

    For your purposes, you could trigger a dump based off any condition, and thus you'd know which stupid deed is having issues - issues that don't necessarily lead to a LUA error but rather undesirable behavior. And you'd know every value that lead to that condition, and from which function.

    Any amount of table nesting isn't a problem, and as you can see they'll be properly indented and bracketed for easy parsing. With something like my initPackages() above, you don't need to comment out all the debugging code. You just set self.doDebug to false. The now blank functions won't clog logs, won't cause errors, and won't hurt performance. Possibly this is overkill, but if you love complete data married to specific context, then here you go. Maybe this interests you, and maybe it doesn't. But I figured I'd offer either way.
     
    cybersam likes this.
  3. cybersam

    cybersam Subatomic Cosmonaut

    actually that looks awesome...
    i'll try it out when i get home ^_^

    thanks for that ^_^
     
  4. lornlynx

    lornlynx Cosmic Narwhal

    Use Sublime Text, it also updates on realtime without having to go fancy :)
     

Share This Page