Thread: Debug examples
-
April 5th, 2021, 18:20 #1
- Join Date
- Mar 2009
- Location
- Lidingö, Sweden, Europe
- Posts
- 374
Debug examples
Hi all,
I don't get the debug function to work. I've tried Debug.chat(variable) and Debug.console(variable) but I get no output. I've also tried printstack() but with the same result - no output. The print function does produce output but only in the top level of a function. Even though I now that a certain deeper level code will get executed the print statement doesn't produce any output. I can see the changes the code produces in the character sheet, but in the current case gets no printout of the calculations, it's quite frustrating. Anyhow, if anyone has any working examples of how to use the debug functions that they like to share, that would be appreciated.
TIA,
Peter
-
April 6th, 2021, 16:28 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,564
I use these every day in my work.
Debug.chat(...)
Debug.console(...)
Debug.printstack()
The first one outputs the variables separated by pipe symbols to the chat window (if defined), otherwise to the console.
The second one outputs the variables separated by pipe symbols to the console.
The third one outputs the current Lua call stack.
To access the console, type /console while FG is running. If the debug statements run before the console is open, they may not appear.
All console messages are output to the console.log file located in the FG data folder.
Regards,
JPG
-
April 6th, 2021, 23:53 #3
I use soooo many Debug statements when Im coding stuff.
My best guess is that its either not running the code the way you think it is or its running from another copy of the ruleset (unpacked vs packed) etc?
Debug.chat("onLanded", rRoll, rSource);
-
January 11th, 2023, 01:15 #4
Revising an old thread because the topic is perfect
So some more info from Moon regarding Debug Statement:
Debug.chat(window.control); will return the control information
Debug.chat(window); will return the window information.
Debug.chat(window.control.isVisible); will return "fn" because it's just a function variable.
Debug.chat(window.control.isVisible()); will return the returned value from the execution of the isVisible function for that object. (Make sure you have not accidentally overriden the isVisible API inside the function.)
Code:<rsw_combobox name="item_type"> <frame> <name>fielddark</name> <offset>8,0,8,0</offset> </frame> <bounds>88,40,59,30</bounds> <empty textres="item_item_type_EmptyText" /> <listdirection>down</listdirection> <script>function onInit() super.onInit(); onValueChanged(); super.onInit(); add("gear","Gear"); add("weapon","Weapon"); add("defense","Defense"); add("scanner","Scanner"); add("implant","Implant"); end function onValueChanged() Debug.chat(getValue()); if getValue() == '' then setValue("gear"); end getValue() if getValue() == 'Gear' then window.sub_gear.setVisible(true); window.sub_weapon.setVisible(false); window.sub_defense.setVisible(false); window.sub_scanner.setVisible(false); window.sub_implant.setVisible(false); elseif getValue() == 'Weapon' then window.sub_gear.setVisible(false); window.sub_weapon.setVisible(true); window.sub_defense.setVisible(false); window.sub_scanner.setVisible(false); window.sub_implant.setVisible(false); elseif getValue() == 'Defense' then window.sub_gear.setVisible(false); window.sub_weapon.setVisible(false); window.sub_defense.setVisible(true); window.sub_scanner.setVisible(false); window.sub_implant.setVisible(false); elseif getValue() == 'Scanner' then window.sub_gear.setVisible(false); window.sub_weapon.setVisible(false); window.sub_defense.setVisible(false); window.sub_scanner.setVisible(true); window.sub_implant.setVisible(false); elseif getValue() == 'Implant' then window.sub_gear.setVisible(false); window.sub_weapon.setVisible(false); window.sub_defense.setVisible(false); window.sub_scanner.setVisible(false); window.sub_implant.setVisible(true); end Debug.chat("Return sub Window statuses") Debug.chat(window.sub_gear.isVisible()); Debug.chat(window.sub_weapon.isVisible()); Debug.chat(window.sub_defense.isVisible()); Debug.chat(window.sub_scanner.isVisible()); Debug.chat(window.sub_implant.isVisible()); end </script> </rsw_combobox>
Problems? See; How to Report Issues, Bugs & Problems
On Licensing & Distributing Community Content
Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
Note, I am not a SmiteWorks employee or representative, I'm just a user like you.
-
January 11th, 2023, 08:20 #5
You can also put those variables/objects together in a single statement or combined with text (so you know which is which). For example:
Code:Debug.chat("Is visible? sub_window = ", (window.sub_gear.isVisible());
Code:Debug.chat("Is visible? sub_gear, sub_weapon = ", window.sub_gear.isVisible(), window.sub_gear.isVisible());
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 15th, 2023, 11:22 #6
You can combine Debug with string.format, but you have to remember that Debug automatically converts
every parameter to string, string.format doesn't, so you have to convert explicitly.
Code:Debug.console(string.format("%s control: visibility is %s and readonly is %s", getName(), tostring(isVisible()), tostring(isReadOnly())));
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks