View previous topic :: View next topic |
Author |
Message |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 12, 2013 7:37 am Post subject: Few question |
|
|
1.
I use the function
Because Im importing it from my server.
Now I want to set the form a icon, how can I do so?
I use socket.
Code: | http = require("socket.http")
local response = http.request("http://examplepage.com/Files/example.lua") --url is diff..
file = io.open('C:\\testthis.lua', "w")
location = ('C:\\testthis.lua')
file:write(response)
file:close()
f = loadfile(location)
f() |
Which is getting the LUA file, saving it locally (because Idk how to run in it instantly, its counts a string..).
And then loading the file, and executing it (will create form and define the functions..)
Anyway,
If there no response, it returns nil, and then Lua Engine is popping out.
Is it possible to set LUA Engine window as invisible?
Because I want to display a message, and some other options in case that it would fail.
And I don't want people to use use it...
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Apr 12, 2013 8:24 am Post subject: Re: Few question |
|
|
Flash hacker wrote: | If there no response, it returns nil, and then Lua Engine is popping out. |
Just add additional checks. So Lua Engine will not pop out.
_________________
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 12, 2013 8:50 am Post subject: |
|
|
yup tried something different this time.
Code: | http = require("socket.http")
local mystring = http.request("http://worldtimeengine.com/function/sync")
if mystring ==nil then return end
local timeTotalSeconds = mystring:sub(21,-3) / 1000
print(os.date("%c", timeTotalSeconds)) |
Last time I did it wrong .
Thanks.
Any insights about how to set an created form icon?
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Apr 12, 2013 9:50 am Post subject: |
|
|
Flash hacker wrote: | yup tried something different this time.
Code: | http = require("socket.http")
local mystring = http.request("http://worldtimeengine.com/function/sync")
if mystring ==nil then return end
local timeTotalSeconds = mystring:sub(21,-3) / 1000
print(os.date("%c", timeTotalSeconds)) |
Last time I did it wrong .
Thanks. |
return - "A return statement returns occasional results from a function or simply finishes a function"
Flash hacker wrote: | Any insights about how to set an created form icon? |
hmm, CE 6.3 maybe.
Edit:
another example: Code: |
http = require("socket.http")
function timeZoneOffset()
local now = os.time()
return os.difftime(now, os.time(os.date('!*t',now)))
end
-- human readable date and time (GMT/Zulu time)
EndTime = os.time{year=2013, month=4, day=15, hour=20, min=00, sec=00, isdst=false}
EndTime = EndTime + timeZoneOffset()
UserLocalTime = 0
HoursLeft = 0
function checkDateAndTime()
local mystring = http.request("http://worldtimeengine.com/function/sync")
if mystring==nil then return false end
if tonumber(mystring:sub(21,-3))==nil then return false end
UserLocalTime = mystring:sub(21,-3) / 1000
HoursLeft = (EndTime - UserLocalTime) / 60 / 60
return true
end
checkDateAndTime()
print('current time ', os.date("%a %d %b %Y %X", UserLocalTime ))
print('end time ', os.date("%a %d %b %Y %X", EndTime ))
print('hours left ', HoursLeft) |
I get this output:
current time Fri 12 Apr 2013 17:31:28
end time Mon 15 Apr 2013 22:00:00
hours left 76.475385833316
note:
checkDateAndTime function return true if there was internet connection and was able to parse current time from response.
you can use another function like this one:
Code: | function expired() -- returns true if expired,
local check = checkDateAndTime()
if check==false then return true end
if HoursLeft>0 then
return false
else
return true
end
end |
_________________
Last edited by mgr.inz.Player on Fri Apr 12, 2013 10:08 am; edited 4 times in total |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 12, 2013 9:54 am Post subject: |
|
|
Sad that setting an Icon isn't possible.
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Apr 12, 2013 10:03 am Post subject: |
|
|
I don't know. Probably DB knows the answer.
I know that we can load any image when using "Form Designer".
_________________
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 12, 2013 10:04 am Post subject: |
|
|
Yes I know that too.
In main lua there no such thing mentioned.
|
|
Back to top |
|
 |
|