Author Topic: Stupid newbie question re: variables  (Read 2006 times)

Qwinn

  • Guest
Stupid newbie question re: variables
« on: January 13, 2005, 10:25:07 AM »
Sorry for such a n00b question.  I'm trying to learn my way around by debugging a certain mod, but there's something really basic I'm missing.

I can see from an area .BAF file that the mod is looking for a particular area variable (checking to see if the value is set to 0).  I use the CLUAConsole:GetGlobal command to try and figure out what the value of that variable is in-game, but it responds that the "variable does not exist".  So here's my question - how/where do variables get defined?  Are they just implicitly created on the fly by the SetGlobal command?  Cause looking through all the files that come zipped up in the mod, I can't find any place where the variables are actually defined.

Also - if the variable doesn't exist according to the CLUAConsole:GetGlobal command, but there's an IF THEN statement in a given .BAF file that has a check on that variable as part of the condition, what's the result of the condition?  Does the value of a non-existent variable = 0 as far as the conditional is concerned?  Or does it just automatically return false?

I'm a programmer by trade, and I think that's actually hampering me at the moment.  I'm used to seeing variables defined explicitly in very obvious places, so not being able to find them here is throwing me for a loop :/

Thanks much for the help!

Qwinn

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Stupid newbie question re: variables
« Reply #1 on: January 13, 2005, 10:27:32 AM »
In BG2, variables that haven't been set yet are considered 0.
Earn Money Sleeping.

Qwinn

  • Guest
Re: Stupid newbie question re: variables
« Reply #2 on: January 13, 2005, 10:29:35 AM »
Okay, phew.  I'm not insane.  So I'll take that to mean that if the CLUA GetGlobal command on a given variable returns "variable does not exist", that's the exact same thing as if it said that it does exist and is  = 0.

Thanks for the (amazingly fast) reply!

Qwinn

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: Stupid newbie question re: variables
« Reply #3 on: January 13, 2005, 10:46:44 AM »
Are they just implicitly created on the fly by the SetGlobal command?  Cause looking through all the files that come zipped up in the mod, I can't find any place where the variables are actually defined.

They are implicitly created/defined on the fly in all IE games except PST (for some el-bizarro reason.) There's a VAR.VAR file that defines variables for PST. It's documented how to add to it, but has never been implemented in WeiDU because nobody's ever said "I plan to make a PST mod with WeiDU, please give me VAR.VAR adding" to Weimer.

There are special rules for dealing with timers that have not yet been defined. SimDing0's Scripting Tutorial goes through the logic of what is and is not TRUE in the case of checking that a timer that doesn't exist is not expired, etc. etc.
« Last Edit: January 13, 2005, 10:56:42 AM by jcompton »
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Qwinn

  • Guest
Re: Stupid newbie question re: variables
« Reply #4 on: January 13, 2005, 10:55:19 AM »
Thanks for the additional info, jcompton :)  I'll look for SimDing0's tutorial ASAP.

Okay, exceedingly stupid newb question #2 (I did a search on CLUAConsole on this forum and didn't find an answer).  Is there a way to use the CLUA Console to check the value returned by a function?  I tried targetting my main character and typing CLUAConsole:HaveAnySpells() to see if it would return False (he's a fighter), but instead it yells at me "lua:  call expression not a function".

Better yet, is there a link somewhere that contains a FULL list of commands available through the Console?  Every list I've found through googling seems limited to what would be useful only as far as cheating goes, not debugging.

Qwinn

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: Stupid newbie question re: variables
« Reply #5 on: January 13, 2005, 11:00:19 AM »
http://iesdp.gibberlings3.net/clua/bg2.htm

For more sophisticated functions that you need to check on the fly like that, typically people create script snippets that can be assigned to a CRE and activated, say, by a keypress, which will DisplayStringHead some value if the function returns true, etc.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Qwinn

  • Guest
Re: Stupid newbie question re: variables
« Reply #6 on: January 13, 2005, 11:06:37 AM »
Ewwwww, ok thanks.  It's gonna take me a little bit before I get to the point of being able to do that.  Not that what you said didn't make sense, it actually makes perfect sense, I've just only been looking at this stuff for about 3 hours now.  Not quite up to speed on creating CRE's yet ;)  (no, I'm not asking you to explain how, I'm sure that's in every tutorial out there, I just gotta plow through them, heheh)

Incidentally, I've been looking at the IESDP for most of those 3 hours (what a -fantastic- reference) and can't believe I missed seeing "CLUA Console" on the contents page.  *sigh*  I think some sleep might be in order before I start those tutorials...

Qwinn

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: Stupid newbie question re: variables
« Reply #7 on: January 13, 2005, 11:43:33 AM »
You can assign the script using the game interface, actually.

For an example of the assignable script-snippet approach, look at Idobek's entry from Iron Modder 3.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline igi

  • IESDP Guardian
  • Planewalker
  • *****
  • Posts: 124
  • IESDP Guardian
Re: Stupid newbie question re: variables
« Reply #8 on: January 13, 2005, 03:14:55 PM »
Get some sleep (and dream about the IESDP), and everything will make sense.
There are a few tutorials on creating .cre files, but iirc, they are terribly out of date.
I'd recommend DLTCEP, where you just fill in the fields shown, though NI is also perfectly competent. Or, for a challenge, try CCIE :)
NPC: Arg || Galoomp || Thash
Mods: Dark Heart of the Xvart || GbG
Tweak Pack: iiTweak

mcwrench.com
mcwrench.com forums

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: