Hard Light Productions Forums

FreeSpace Releases => Scripting Releases => Topic started by: Axem on September 16, 2012, 05:23:15 pm

Title: Script Request! - View all Sexp Variables
Post by: Axem on September 16, 2012, 05:23:15 pm
Oh great and powerful script gods, I come to you for your assistance.

I would like a lua script that automagically lists and displays all sexp variables and their names.

Now I can do this manually with sexps themselves but I can be known to... use a lot of sexp variables... So if there were a way to quickly and easily turn a complete sexp variable list on and off, that would be awesome. Ideally it would be a list that starts from the top and goes down.

As payment, I am willing to give you adorable pictures of cats.
Title: Re: Script Request! - View all Sexp Variables
Post by: Nuke on September 16, 2012, 10:44:01 pm
oooh kitties!

im abit rusty but do something like this on each frame. im not sure if im converting things to strings correctly and ive probibly misspelled things.

Code: [Select]
#Conditional Hooks
$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Frame: [
--tweakables!
printSexpVars = true
posX,posY = 10,50

--print stuffs
if printSexpVars then
 gr.drawString("Sexp Var Name: Value, Type, Persistence", posX, posY )
 for i=1, #mn.SEXPVariablesdo
  local var = mn.SEXPVariables[i]
  if var:isValid() then
   gr.drawString( tostring(var)..": "..tostring(var.Value)..", "..tostring(var.Type)..", "..tostring(var.Persistence) )
  end
 end
end
]
#end
Title: Re: Script Request! - View all Sexp Variables
Post by: Axem on September 19, 2012, 05:24:07 pm
Oh hey, I didn't think anyone would actually reply!

Anyway I get this error

Code: [Select]
LUA ERROR: [string "sexpvar-sct.tbm - On Frame"]:7: ')' expected near 'posX'
Title: Re: Script Request! - View all Sexp Variables
Post by: Admiral MS on September 19, 2012, 05:36:48 pm
Let me try to correct that by inserting some spaces and stuff:

Code: [Select]
#Conditional Hooks
$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Frame: [
--tweakables!
printSexpVars = true
posX,posY = 10,50

--print stuffs
if printSexpVars then
 gr.drawString("Sexp Var Name: Value, Type, Persistence", posX, posY )
 for i=1, #mn.SEXPVariables do
  local var = mn.SEXPVariables[i]
  if var:isValid() then
   gr.drawString( tostring(var)..": "..tostring(var.Value)..", "..tostring(var.Type)..", "..tostring(var.Persistence) )
  end
 end
end
]
#end


This one works for me so have fun getting half of your screen filled up with text  :P
You can remove the var.Type and var.Persistance parts and modify the displaying position (posX, posY) to fix that.
Title: Re: Script Request! - View all Sexp Variables
Post by: Axem on September 19, 2012, 06:48:36 pm
Payment as promised.

(http://25.media.tumblr.com/tumblr_m7oo1k2ZYW1qahxmso1_500.jpg)

This is exactly what I wanted. The only thing that would make it better is being able to turn it on and off, with a script-eval maybe? That would solicit a cat video then!

(Also more like the ENTIRE screen of variables)
Title: Re: Script Request! - View all Sexp Variables
Post by: Nuke on September 19, 2012, 06:50:42 pm
awww kitty!

i derped and forgot a comma.

im actually supprised it worked, i just typed it into the message and didnt test it.
Title: Re: Script Request! - View all Sexp Variables
Post by: mjn.mixael on December 11, 2012, 04:10:45 pm
With Admiral MS' help...

Toggle it on/off with 'Alt-2'.

Code: [Select]
#Conditional Hooks
$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Frame:
[
--tweakables!
posX,posY = 10,50

--print stuffs
if printSexpVars then
gr.drawString("Sexp Var Name: Value, Type, Persistence", posX, posY )
for i=1, #mn.SEXPVariables do
local var = mn.SEXPVariables[i]
if var:isValid() then
gr.drawString( tostring(var)..": "..tostring(var.Value)..", "..tostring(var.Type)..", "..tostring(var.Persistence) )
end
end
end

]

$Application: FS2_Open
$On Gameplay Start:
[
printSexpVars = false
]

$State: GS_STATE_GAME_PLAY
$On Key Pressed:
[
if hv.Key == "Alt-2" then
if printSexpVars  then
printSexpVars = false
elseif not printSexpVars then
printSexpVars = true
end
end
]

#end