SomeAve Posted April 9, 2023 Share Posted April 9, 2023 (edited) I'm trying to add my own tooltip after the default DoTooltip, so i try to implement the steps in Lua. The problem is that it seems to not like calling Java method and passing a double parameter. Code : require "ISOriginals" --- @param self ISToolTipInv local function renderSkills(self) -- if not our mod, just return if not (self.item:IsLiterature() and self.item:isCustomName() and self.item:getModName() == "Skills Diary") then return end print("Skills Diary Tooltip") local var1 = self.tooltip var1:render() local var2 = var1:getFont() local var3 = var1:getLineSpacing() local var4 = 5 var1:adjustWidth(5, "100000000") local var14 = var4 + var3 + 5 local var7 local var8 local var9 local var10 local var15 = var1:beginLayout() var15:setMinLabelWidth(80) local var16 = var15:addItem() var16:setLabel("EDITED", 1.0, 0.5, 0.5, 1.0) var14 = var15:render(5, var14, var1) var1:endLayout(var15) var14 = var14 + var1.padBottom var1.setHeight(var14) if var1:getWidth() < 150.0 then var1:setWidth(150.0) end end ---@param self ISToolTipInv ISToolTipInv.render = function(self) --ISOriginal.origTooltipRender(self) -- idk, follow original code if ISContextMenu.instance and ISContextMenu.instance.visibleCheck then return end local mx = getMouseX() + 24; local my = getMouseY() + 24; if not self.followMouse then mx = self:getX() my = self:getY() if self.anchorBottomLeft then mx = self.anchorBottomLeft.x my = self.anchorBottomLeft.y end end self.tooltip:setX(mx+11); self.tooltip:setY(my); self.tooltip:setWidth(50) self.tooltip:setMeasureOnly(true) renderSkills(self) self.item:DoTooltip(self.tooltip); self.tooltip:setMeasureOnly(false) -- clampy x, y local myCore = getCore(); local maxX = myCore:getScreenWidth(); local maxY = myCore:getScreenHeight(); local tw = self.tooltip:getWidth(); local th = self.tooltip:getHeight(); self.tooltip:setX(math.max(0, math.min(mx + 11, maxX - tw - 1))); if not self.followMouse and self.anchorBottomLeft then self.tooltip:setY(math.max(0, math.min(my - th, maxY - th - 1))); else self.tooltip:setY(math.max(0, math.min(my, maxY - th - 1))); end self:setX(self.tooltip:getX() - 11); self:setY(self.tooltip:getY()); self:setWidth(tw + 11); self:setHeight(th); if self.followMouse then self:adjustPositionToAvoidOverlap({ x = mx - 24 * 2, y = my - 24 * 2, width = 24 * 2, height = 24 * 2 }) end self:drawRect(0, 0, self.width, self.height, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b); self:drawRectBorder(0, 0, self.width, self.height, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b); renderSkills(self) self.item:DoTooltip(self.tooltip); end ERROR Log : [09-04-23 02:38:48.947] ERROR: General , 1680982728947> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:48.947] ERROR: General , 1680982728947> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.060] ERROR: General , 1680982734060> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.061] ERROR: General , 1680982734061> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.094] ERROR: General , 1680982734094> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.094] ERROR: General , 1680982734094> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.127] ERROR: General , 1680982734127> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.127] ERROR: General , 1680982734127> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.160] ERROR: General , 1680982734160> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.160] ERROR: General , 1680982734160> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.193] ERROR: General , 1680982734193> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.194] ERROR: General , 1680982734194> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.228] ERROR: General , 1680982734228> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.228] ERROR: General , 1680982734228> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.261] ERROR: General , 1680982734261> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.262] ERROR: General , 1680982734262> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.294] ERROR: General , 1680982734294> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.295] ERROR: General , 1680982734295> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.327] ERROR: General , 1680982734327> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.327] ERROR: General , 1680982734327> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.360] ERROR: General , 1680982734360> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.361] ERROR: General , 1680982734361> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.393] ERROR: General , 1680982734393> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.394] ERROR: General , 1680982734394> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.426] ERROR: General , 1680982734426> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.427] ERROR: General , 1680982734427> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.460] ERROR: General , 1680982734460> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.461] ERROR: General , 1680982734461> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.494] ERROR: General , 1680982734494> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.494] ERROR: General , 1680982734494> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.526] ERROR: General , 1680982734526> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.528] ERROR: General , 1680982734528> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.561] ERROR: General , 1680982734561> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.561] ERROR: General , 1680982734561> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.594] ERROR: General , 1680982734594> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.594] ERROR: General , 1680982734594> DebugLogStream.printException> Stack trace:. [09-04-23 02:38:54.627] ERROR: General , 1680982734627> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __add not defined for operands in renderSkills at KahluaUtil.fail line:82.. [09-04-23 02:38:54.627] ERROR: General , 1680982734627> DebugLogStream.printException> Stack trace:. Edited April 9, 2023 by SomeAve Solved, now comes a different problem, made a new thread for it Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted April 9, 2023 Share Posted April 9, 2023 I assume you've checked that line 37 isn't trying to perform addition on a non-numeric value? Link to comment Share on other sites More sharing options...
SomeAve Posted April 9, 2023 Author Share Posted April 9, 2023 Ok, I was so dumb last night and so tired. Took a deep nap. Found out the reason was var1.padBottom is nil But when I break the debugger and inspected the value, it's valid and not nil I will make new thread for this Hugo Qwerty 1 Link to comment Share on other sites More sharing options...
SomeAve Posted April 9, 2023 Author Share Posted April 9, 2023 (edited) Nevermind, I forgot that you need to use --LuaManager.GlobalObject's : ---@public ---@param arg0 Object ---@param arg1 int ---@return Field function getClassField(arg0, arg1) end ---@public ---@param arg0 Object ---@param arg1 Field ---@return Object function getClassFieldVal(arg0, arg1) end to access a Java Object's public fields / members. the arg1 param for getClassField is the sequence of fields / members as compiled in the .java source Edited April 9, 2023 by SomeAve added some keyword to aid searches Hugo Qwerty 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now