![]() |
|
#1
|
|||
|
|||
|
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
__________________
------------------------------------------------------------------------------------ A true master of control is one who never seems to be in control ------------------------------------------------------------------------------------ |
|
#2
|
|||
|
|||
|
we have a lua section ;)
__________________
![]() (Compliments of Chode) |
|
#3
|
|||
|
|||
|
Yes I see that. Sorry :)
__________________
------------------------------------------------------------------------------------ A true master of control is one who never seems to be in control ------------------------------------------------------------------------------------ |
|
#4
|
|||
|
|||
|
repost it over there for now and this one'l get deleted next time a mod is on
__________________
![]() (Compliments of Chode) |
|
#5
|
||||
|
||||
|
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
__________________
![]() 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 |
|
#6
|
|||
|
|||
|
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 ------------------------------------------------------------------------------------ |
|
#7
|
||||
|
||||
|
Il move just so anyone else who visits the LUA Section with the same error can find this
__________________
The PSP Programming and Development Mega Thread VDrum downloaded over 10000 times! PSN: Xsjado7
|
|
#8
|
||||
|
||||
|
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 |
|
#9
|
|||
|
|||
|
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 ------------------------------------------------------------------------------------ |
|
#10
|
||||
|
||||
|
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 |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|