This the only thing that seems to be holding me back from finishing my app from what I can tell. attempt to index global ‘coordinatedUniversalTime’ (a nil value)
?? [import]uid: 69302 topic_id: 31517 reply_id: 331517[/import]
I think a little more information on your problem is needed, we can’t read minds on the forum
Obviously, the variable you’re trying to access is not initialized or it’s a scoping issue or some such.
Perhaps post a little source code? [import]uid: 87794 topic_id: 31517 reply_id: 125928[/import]
I feel like there was another thread you had going about this - was there? It may have been someone else but IIRC the code called on coordinatedUniversalTime without ever defining it.
As digitaloragnes said we really need to see code to be able to help at all here. [import]uid: 52491 topic_id: 31517 reply_id: 125929[/import]
Hello Peach, I thought I did to but if I did I cant find it.
[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene(“Scene2”)
– include Corona’s “widget” library
local widget = require “widget”
local storyboard = require “storyboard”
storyboard.purgeOnSceneChange = true
– forward declarations and other locals
local playBtn
– ‘onRelease’ event listener for playBtn
local function onButtonEvent(Scene2)
storyboard.gotoScene(“Scene1”)
return true – indicates successful touch
end
local background = display.newRect(0,0,display.contentWidth,display.contentHeight)
background:setFillColor(0,0,0)
–> Starts our app
– BEGINNING OF YOUR IMPLEMENTATION
– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
– create a widget button (which will loads scene2.lua on release)
playBtn = widget.newButton{
label=“Go Back”,
labelColor = { default={255}, over={120} },
default=“button.png”,
over=“button-over.png”,
width=100, height=40,
onEvent = onButtonEvent – event listener function
}
playBtn:setReferencePoint( display.TopLeftReferencePoint )
–group:display(remove)
–group:insert(background)
–end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
– INSERT code here (e.g. start timers, load audio, start listeners, etc.)
–group:insert( background )
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view
if playBtn then
playBtn:removeSelf()
– widgets must be manually removed
playBtn = nil
end
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
– create a grey rectangle as the backdrop
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 255 )
group:insert(bg)
bg.x = display.contentWidth * 0.5;
bg.y = display.contentHeight * 0.5;
local font = native.systemFont;
end
local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}
– create first column
columnData[1] = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
–columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1
– second column (lots of rows)
columnData[2] = {}
columnData[2].alignment = “center”
for i=1,31 do
columnData[2][i] = i
end
columnData[2].startIndex = 1
– third column
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=50,
columns=columnData
}
local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}
– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1
– second column (lots of rows)"
columnData[2] = { “00”,“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59” }
columnData[2].alignment = “center”
for i= 1,59 do
– columnData[2][i] = i
end
columnData[2].startIndex = 1
– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1
– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}
local label = display.newText(“Test”, 0, 0, font, 18) ;
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .94;
–group:insert( background )
function label:tap(e)
native.showAlert(“Message”,“Scheduled to be sent!”,{“Ok”})
native.showPopup(“sms”,{}) ;
local pickerValues = picker:getValues()
print(pickerValues[1].index)
print((pickerValues[2].index)-1)
time_to_notify( pickerValues[1].index, (pickerValues[2].index)-1 )
end
label:addEventListener(“tap”, label);
system.vibrate()
–end
function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min
segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)
if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end
if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end
back = os.date( “!*t”, os.time() + seg_reg )
return back
end
system.scheduleNotification( coordinatedUniversalTime [options] )
[/code] [import]uid: 69302 topic_id: 31517 reply_id: 125939[/import] </segundos_in>
Not 100% sure if this will work, but try adding the following at the top of your file:
[lua]coordinatedUniversalTime = os.date( “!*t” )[/lua] [import]uid: 62706 topic_id: 31517 reply_id: 125942[/import]
Just saying.
For what reason would you want to index something that doesn’t exist ?
You haven’t defined coordinatedUniversalTime
.
You might also want to consider that the index options
doesn’t exist, too. [import]uid: 142361 topic_id: 31517 reply_id: 125976[/import]
Thank you CraftyDeano. That def got rid of my error. [import]uid: 69302 topic_id: 31517 reply_id: 126037[/import]
I think a little more information on your problem is needed, we can’t read minds on the forum
Obviously, the variable you’re trying to access is not initialized or it’s a scoping issue or some such.
Perhaps post a little source code? [import]uid: 87794 topic_id: 31517 reply_id: 125928[/import]
I feel like there was another thread you had going about this - was there? It may have been someone else but IIRC the code called on coordinatedUniversalTime without ever defining it.
As digitaloragnes said we really need to see code to be able to help at all here. [import]uid: 52491 topic_id: 31517 reply_id: 125929[/import]
Hello Peach, I thought I did to but if I did I cant find it.
[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene(“Scene2”)
– include Corona’s “widget” library
local widget = require “widget”
local storyboard = require “storyboard”
storyboard.purgeOnSceneChange = true
– forward declarations and other locals
local playBtn
– ‘onRelease’ event listener for playBtn
local function onButtonEvent(Scene2)
storyboard.gotoScene(“Scene1”)
return true – indicates successful touch
end
local background = display.newRect(0,0,display.contentWidth,display.contentHeight)
background:setFillColor(0,0,0)
–> Starts our app
– BEGINNING OF YOUR IMPLEMENTATION
– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
– create a widget button (which will loads scene2.lua on release)
playBtn = widget.newButton{
label=“Go Back”,
labelColor = { default={255}, over={120} },
default=“button.png”,
over=“button-over.png”,
width=100, height=40,
onEvent = onButtonEvent – event listener function
}
playBtn:setReferencePoint( display.TopLeftReferencePoint )
–group:display(remove)
–group:insert(background)
–end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
– INSERT code here (e.g. start timers, load audio, start listeners, etc.)
–group:insert( background )
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view
if playBtn then
playBtn:removeSelf()
– widgets must be manually removed
playBtn = nil
end
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
– create a grey rectangle as the backdrop
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 255 )
group:insert(bg)
bg.x = display.contentWidth * 0.5;
bg.y = display.contentHeight * 0.5;
local font = native.systemFont;
end
local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}
– create first column
columnData[1] = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
–columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1
– second column (lots of rows)
columnData[2] = {}
columnData[2].alignment = “center”
for i=1,31 do
columnData[2][i] = i
end
columnData[2].startIndex = 1
– third column
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=50,
columns=columnData
}
local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}
– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1
– second column (lots of rows)"
columnData[2] = { “00”,“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59” }
columnData[2].alignment = “center”
for i= 1,59 do
– columnData[2][i] = i
end
columnData[2].startIndex = 1
– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1
– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}
local label = display.newText(“Test”, 0, 0, font, 18) ;
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .94;
–group:insert( background )
function label:tap(e)
native.showAlert(“Message”,“Scheduled to be sent!”,{“Ok”})
native.showPopup(“sms”,{}) ;
local pickerValues = picker:getValues()
print(pickerValues[1].index)
print((pickerValues[2].index)-1)
time_to_notify( pickerValues[1].index, (pickerValues[2].index)-1 )
end
label:addEventListener(“tap”, label);
system.vibrate()
–end
function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min
segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)
if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end
if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end
back = os.date( “!*t”, os.time() + seg_reg )
return back
end
system.scheduleNotification( coordinatedUniversalTime [options] )
[/code] [import]uid: 69302 topic_id: 31517 reply_id: 125939[/import] </segundos_in>
Not 100% sure if this will work, but try adding the following at the top of your file:
[lua]coordinatedUniversalTime = os.date( “!*t” )[/lua] [import]uid: 62706 topic_id: 31517 reply_id: 125942[/import]
Just saying.
For what reason would you want to index something that doesn’t exist ?
You haven’t defined coordinatedUniversalTime
.
You might also want to consider that the index options
doesn’t exist, too. [import]uid: 142361 topic_id: 31517 reply_id: 125976[/import]
Thank you CraftyDeano. That def got rid of my error. [import]uid: 69302 topic_id: 31517 reply_id: 126037[/import]