Jump to content


Photo

[WIP] Expanded Lua Console

For beta 0024

  • Please log in to reply
9 replies to this topic

#1 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 25 May 2012 - 03:05 PM

I am currently making a lot of additions to the Lua console to allow modders to debug a lot more stuff. In this topic, can you let me know what sort of things you would like be able to do with the Lua console for debug purposes? Think of this as a wish list.

The current plan of implementation is to hard-code as little extra functions as possible and use Lua 3.0 to code the rest.
Stuff that is currently broken in Lua console I am going to fix (e.g. StartStore).

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#2 Wisp

Wisp
  • Modder
  • 1353 posts

Posted 26 May 2012 - 05:50 AM

Maybe some direct way of querying a creature for stats and states?

Something like hovering the mouse cursor over the creature + GetState(SOME_STATE), with a boolean return value. Ditto for stats, but returning the integer value of that stat.

#3 i30817

i30817
  • Member
  • 611 posts

Posted 27 May 2012 - 12:44 PM

Could LStat be improved/integrated somehow without performance degradation until it is used?

#4 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 28 May 2012 - 12:38 AM

LStat?

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#5 William Imm

William Imm

    Obsessive Penguin Lover

  • Member
  • 486 posts

Posted 28 May 2012 - 05:43 AM

LStat?

It's mentioned in the FAQ for the Megamods. I presume Jarno or someone else made it.
At this point, I'm not really doing much Baldur's Gate related. More focused on Skyrim modding and the Born of Legend tabletop roleplaying game. Don't expect much activity here.

#6 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 01 June 2012 - 05:35 PM

As a brief preview, this is a list of current additions to Lua 3.0 console.

For introduction to Lua 3.0 and lua programming syntax, read Chapter 4 (http://www.lua.org/manual/3.0/).

Pre-defined lua functions
The functions described in Chapter 6.1 of the reference manual (http://www.lua.org/manual/3.0/).
pow() - pushes x to the power of y onto the Lua stack (this is set to the operator ^)
mod() - pushes x mod y onto the Lua stack
band() - pushes x & y onto the Lua stack (there is no operator for this)
bor() - pushes x | y onto the Lua stack (there is no operator for this)
dec2hex() - pushes a string containing the hexadecimal equivalent of a decimal number onto the Lua stack
hex2dec() - pushes a decimal number equivalent to a string containing a hexadecimal number onto the Lua stack
pushuserdata() - converts a number to userdata and pushes onto Lua stack
u2n() - converts a userdata to number and pushes onto Lua stack
pushfunction() - converts a number to cfunction and pushes onto Lua stack
getsprite() - pushes a userdata referencing a game sprite by index or script name onto Lua stack
createobject() - creates a TobExObject from userdata and sets its type

TobExObject methods (available to TobExObjects)
cdecl() - calls a cfunction using __cdecl
stdcall() - calls a cfunction using __stdcall/__thiscall
getaddress() - gets the relative address within this object (pushes as userdata)
getpointer() - gets the value that is an address at a relative address within this object (pushes as userdata)
getbyte() - gets the byte value at a relative address within this object (pushes as number)
getword() - gets the word value at a relative address within this object (pushes as number)
getdword() - gets the dword value at a relative address within this object (pushes as number)
getstring() - gets the ASCII value at a relative address within this object (pushes as string, length can be specified)
getlist() - gets a list at a relative address within this object (pushes as table)
print() - does a hard-coded dump of the object to the Lua console

Newly defined lua functions (because all of these functions are defined externally in .lua files, you can define your own things given a knowledge of parts of the Infinity Engine)
p(<text>) - short-hand for CLUAConsole::DisplayText(tostring(<text>))
area_getcurrent() - pushes a TobExObject of the current area
area_listsprites() - does a dump of all the sprites in the current area
creature_getstat() - pushes the value of a stat number of a creature onto the Lua stack
creature_liststates() - does a dump of the all the states that apply to the creature
creature_listtriggers() - does a dump of all the triggers of the creature
creature_listactions() - does a dump of the action list of the creature
creature_listtriggerobjects() - does a dump of all the trigger objects of the creature
creature_listscripts() - does a dump of the script names assigned to the creature as well as which script, which block, and which response is currently running
dump_table() - does a dump of a lua table
dump() - does a dump of all lua global variables
sprite_getcurrent() - pushes a TobExObject of the current sprite highlighted by the cursor
sprite_gettype() - pushes a string of the specific type of the current sprite onto the Lua stack


CLUAConsole:StartStore() has also been fixed.

Edited by Ascension64, 01 June 2012 - 08:26 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#7 Sam.

Sam.
  • Administrator
  • 1292 posts

Posted 02 June 2012 - 08:02 PM

It would be very useful if the Lua Console would override all other game modes, and say could be used to break out of an infinite dialogue loop or broken cutscene. Similarly, a listdialog() that does a dump of the dialog file currently open and the current state in the dialog file would be useful when reporting/debugging dialog issues as you wouldn't have to quote/search for the line of dialog itself.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#8 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 02 June 2012 - 08:43 PM

It would be very useful if the Lua Console would override all other game modes, and say could be used to break out of an infinite dialogue loop or broken cutscene. Similarly, a listdialog() that does a dump of the dialog file currently open and the current state in the dialog file would be useful when reporting/debugging dialog issues as you wouldn't have to quote/search for the line of dialog itself.

That is slightly tricky, since you cannot access the game console in dialog or during a cutscene. An accelerator (hotkey) to break the cutscene could certainly be added, though. maybe such as the Escape key. Where is a case of infinite dialogue?

I certainly need feedback as to how people are using the current functions in place. Proper documentation is yet to come, so I won't assume people know how to use a single command at this stage.

Edited by Ascension64, 02 June 2012 - 08:48 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#9 Sam.

Sam.
  • Administrator
  • 1292 posts

Posted 02 June 2012 - 10:16 PM

Where is a case of infinite dialogue?

Well the last one I came across while beta testing for Miloch's Xvart Caverns mod:

In T-1000 when I encounter Vayiza in the back corner she goes into an infinite dialog loop where she says her line that starts “Ha! Ha-ha-ha… you gullible fool!”. I click “End Dialog” then she starts same dialog again. I haven’t looked at the dialog code to see if I can spot what’s going on yet.

A bug of the "dumb" category. I the last block in t-erinye.d, the trigger should be changed from GlobalGT("t-erimad","GLOBAL",0) to !Global("t-erimad","GLOBAL",3). Actually, I probably have to revise the two previous blocks since the last one should be triggering once you see her in the north part of the area with her minions. After you first arrive in Baator and she does a JumpToPoint([4180.960]) I should SetGlobal("t-erimad","GLOBAL",3) and then change the last block to check and augment that to 4. If it still loops, might have to add more checks to t-vayiza.baf but there are already checks there to make sure she doesn't try to talk when hostile (and the last block in her dialogue makes her hostile). Edit: also should change the checks for t-abird1 to t-abird2 in t-erinye.d.

but I have run across them while playing other mods in the past. Here is one that happened in Classic Adventures:

First attempt at talking to Azimer i got into an infinite dialog loop.
Second attempt at dialog with Azimer I managed to get a confused Azimer who teleported to library (multiple images of Azimer) dialog in library ended with "No valid replies or links"
Third attempt did not error but dialog quits without required conclusion. [ no path to 14 in TCAZIMER.d]


EDIT: There are many more examples. Just search the forum for "infinite dialog" or "dialog loop".

Edited by Sam., 02 June 2012 - 10:22 PM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#10 i30817

i30817
  • Member
  • 611 posts

Posted 03 June 2012 - 03:22 AM

That could be dangerous if you saved after, since dialogs can change the game state, and if it gets into a 'inconsistent' state, the quest would get (more) messed up (not to mention mods that change the state of other mods variables - i hope that doesn't happen at runtime).

If there was something like a 'transaction mode' for dialogs such a loop breaker could be useful for reporting dialog bugs - activate debug mode, game variables get copied before dialog, enter infinite cycle, break out of dialog by hotkey, old game state gets restored, auto-savegame (with a name like dialogxxx_1213 - last number being the dialog options taken) and give the save on the mod forum
(fancier would be some way to figure out which mod was responsible and email directly, but that is pushing it to unstandardized realms).

Edited by i30817, 03 June 2012 - 03:29 AM.






Also tagged with one or more of these keywords: For beta 0024