PSP Hacks - Forums
Go Back   PSP Hacks - Forums > Tech Talk > LUA Scripting

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2008, 01:56 AM
Organized_Chaos Organized_Chaos is offline
PSP Smarty
 
Join Date: May 2008
Location: Neosho, MO
Posts: 126
Organized_Chaos User Has a Beginner Reputation
Default

Hello everyone.. As you can probably tell I am new at LUA programing. I followed all the directions in this tutorial at http://www.evilmana.com/tutorials/lua_tutorial_03.php and I am having problems. How do I make this error go away and make my "program" work?
I get an error message that says
"Error: Variable Tut.LUA:18: attempt to perform arithmetic on global 'myBirthYear' (a nil value)
Press start to restart"

("Variable Tut.LUA" is my file name.)
-
Here is my code:
Code:
-- NOTES
-- Green Color Object
green = Color.new(0, 255, 0)

-- Store birth year in variable myBirthYear
myBirthyear = 1991

-- Store current year in currentYear
currentYear = 2008

-- create an empty variable
myAge = nil

-- Store some text in a variable (Note the 

space after the last word before the end ")
someText = "My age is roughly "

-- Subtract myBirthYear from currentYear 

and store in myAge
myAge = currentYear - myBirthYear

-- Print our text variable to the screen 

(NOTE that there are no "" surrounding 

someText)
screen:print(10,100,someText .. 

myAge,green)

-- Buffer offscreen to onscreen (If this 

was a human, offscreen would be thinking 

about it, onscreen would be saying it)
screen.flip()
-- Loop forever
while true do
screen.waitVblankStart()
end
The only thing I did differently was use my birth year and the current year instead of the years in this tutorial. And I added a few custom notes using the "-- text" format. Since this was a tutorial I figured I might add in a few things in case I use this file later as a reference or something. That stuff shouldn't make a difference should it?
__________________
------------------------------------------------------------------------------------
A true master of control is one who never seems to be in control
------------------------------------------------------------------------------------
Reply With Quote
  #2  
Old 05-28-2008, 02:07 AM
hotrocker hotrocker is offline
Programmer
PSP Hacker
 
Join Date: Jun 2007
Location: yesterday
Posts: 853
hotrocker User Has a Beginner Reputation
Default

we have a lua section ;)
__________________

(Compliments of Chode)
Reply With Quote
  #3  
Old 05-28-2008, 02:21 AM
Organized_Chaos Organized_Chaos is offline
PSP Smarty
 
Join Date: May 2008
Location: Neosho, MO
Posts: 126
Organized_Chaos User Has a Beginner Reputation
Default

Yes I see that. Sorry :)
__________________
------------------------------------------------------------------------------------
A true master of control is one who never seems to be in control
------------------------------------------------------------------------------------
Reply With Quote
  #4  
Old 05-28-2008, 03:08 AM
hotrocker hotrocker is offline
Programmer
PSP Hacker
 
Join Date: Jun 2007
Location: yesterday
Posts: 853
hotrocker User Has a Beginner Reputation
Default

repost it over there for now and this one'l get deleted next time a mod is on
__________________

(Compliments of Chode)
Reply With Quote
  #5  
Old 05-28-2008, 03:39 AM
RazorChrist's Avatar
RazorChrist RazorChrist is offline
PSP Smarty
 
Join Date: Jan 2008
Location: Tulsa, OK
Posts: 191
RazorChrist User Has a Beginner Reputation
Default

Chaos, here's part, if not all, of the problem...look at your math, versus how your variable is setup:

Code:
-- Store birth year in variable myBirthYear
myBirthyear = 1991

and store in myAge
myAge = currentYear - myBirthYear
Notice that when you setup your variable, it's spelled "myBirthyear" with a lower case Y in year....but in your math, you have an upper case Y. Try changing the Y in your variable setup to an upper-case Y and see if that fixes the issue. Case-sensitive is a bitch sometimes.
__________________

PSP = Phat 3.71 m33-4 > 3.90 m33 > 3.90 m33-2 > 3.90 m33-3 > 3.93 GEN w/ 1.50 Kernel Addon >
3.95 GEN > 3.90 m33-3 > 4.01 m33 > 3.90 m33-3 w/ 1.50 Kernel Addon
PS2 = Slim Unmodded
Reply With Quote
  #6  
Old 05-28-2008, 04:26 AM
Organized_Chaos Organized_Chaos is offline
PSP Smarty
 
Join Date: May 2008
Location: Neosho, MO
Posts: 126
Organized_Chaos User Has a Beginner Reputation
Default

Damn, can't believe I missed that. I knew everything was case sensitive.. I just over looked that.
Thanks I changed that and it worked fine.
__________________
------------------------------------------------------------------------------------
A true master of control is one who never seems to be in control
------------------------------------------------------------------------------------
Reply With Quote
  #7  
Old 05-28-2008, 06:18 AM
Blade_punk's Avatar
Blade_punk Blade_punk is offline
Moderator
PSP Monk
 
Join Date: Nov 2006
Location: Candy Mountain
Posts: 2,584
Blade_punk will become famous soon enoughBlade_punk will become famous soon enough
Default

Il move just so anyone else who visits the LUA Section with the same error can find this
Reply With Quote
  #8  
Old 05-28-2008, 08:37 AM
RazorChrist's Avatar
RazorChrist RazorChrist is offline
PSP Smarty
 
Join Date: Jan 2008
Location: Tulsa, OK
Posts: 191
RazorChrist User Has a Beginner Reputation
Default

Haha, yeah I miss stupid crap like that all the time till I start getting errors on compile/runtime. You just have to go all the way back through, line by line, usually looking for a missing equals sign or semi colon.
__________________

PSP = Phat 3.71 m33-4 > 3.90 m33 > 3.90 m33-2 > 3.90 m33-3 > 3.93 GEN w/ 1.50 Kernel Addon >
3.95 GEN > 3.90 m33-3 > 4.01 m33 > 3.90 m33-3 w/ 1.50 Kernel Addon
PS2 = Slim Unmodded
Reply With Quote
  #9  
Old 05-28-2008, 01:28 PM
Organized_Chaos Organized_Chaos is offline
PSP Smarty
 
Join Date: May 2008
Location: Neosho, MO
Posts: 126
Organized_Chaos User Has a Beginner Reputation
Default

Is C or C++ coding case sensitive like this? Are all programing languages like that? I am use to HTML where most of the time everything is either all lowercase or all uppercase. HTML is the only code I am somewhat use to writing.. But I'm no expert on it either.
__________________
------------------------------------------------------------------------------------
A true master of control is one who never seems to be in control
------------------------------------------------------------------------------------
Reply With Quote
  #10  
Old 05-28-2008, 04:23 PM
RazorChrist's Avatar
RazorChrist RazorChrist is offline
PSP Smarty
 
Join Date: Jan 2008
Location: Tulsa, OK
Posts: 191
RazorChrist User Has a Beginner Reputation
Default

Not sure about "most" but usually unless it's a web-based scripting, it's usually case sensative. I know C++ and C are for sure.
__________________

PSP = Phat 3.71 m33-4 > 3.90 m33 > 3.90 m33-2 > 3.90 m33-3 > 3.93 GEN w/ 1.50 Kernel Addon >
3.95 GEN > 3.90 m33-3 > 4.01 m33 > 3.90 m33-3 w/ 1.50 Kernel Addon
PS2 = Slim Unmodded
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:09 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©