|
#21
|
||||
|
||||
|
I saw io.popen in the list. The wiki says that it is unsupported, but as it appears in the list now, does this mean that it now is supported?
|
| Advertisement | [Remove Advertisement] |
|
|
|
|
#22
|
|||
|
|||
|
I don't know, I guess it's up to whoever wants to try it out to report back on whether it was successful or not. It'd be very useful if it does work.
|
|
#23
|
|||
|
|||
|
It was always on the list. Hence why it's on the wiki.
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#24
|
||||
|
||||
|
Anyone know of a good way to determine whether a variable is an even or odd number? I think that'd be useful on many ways, I at least need it.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#25
|
||||
|
||||
|
You might want to use the modulo operator (%):
Code:
if number % 2 == 1 then -- number is odd else -- number is even end
__________________
Zen X-Fi2 Apps: Notee-fi (notepad) | TicTacToe | Mahjongg http://www.starfare.eu/ - a free real-time strategy game. |
|
#26
|
||||
|
||||
|
Quote:
Code:
if n/2 == math.floor(n/2) then --Its even! else --Its odd! end |
|
#27
|
||||
|
||||
|
Quote:
That's just what I was looking for ^^
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#28
|
|||
|
|||
|
In case anyone was wondering: The Modulo operator returns the remainder after the division of the two operands.
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#29
|
||||
|
||||
|
So 10%4 returns the value 0,5? And 8%5 returns 0,6? Have I understood it right then?
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#30
|
|||
|
|||
|
10 mod 4 returns 2. 8 mod 5 returns 3.
Image attached, in paint lol:
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#31
|
||||
|
||||
|
Oh I see. Now I get it. Though I'm not very good with that method of division, I use it way too little to remember it xD
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#32
|
||||
|
||||
|
Since apps are beginning to become quite image heavy and the load time for some things have become noticeable I have created a general loading screen code which displays a custom message, it works with any orientation since it loads the screen height and width every time it's called:
Code:
--Draw loading screen
function loadingScreen(msg)
colorW = color.new(255,255,255) --Creates the color white
colorB = color.new(0,0,0,192) --Creates the color black, alpha 192 (75%)
shgt = screen.height() --Saves a variable with the screen height
swdt = screen.width() --Saves a variable with the screen width
text.size(20) --Set text size to 20 pixel
text.color(colorW) --Set text color to white
screen.fillrect(0,0,swdt,shgt,colorB) --Fill screen with black
text.draw(0,shgt/2-10,msg,"center",swdt) --Draw your message in the center
screen.update() --Draw image buffer to screen
end
loadingScreen("Loading Game...") --Loadfunction is called with a message in quotes which will be displayed
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ Last edited by Habhome; 05-09-2010 at 06:10 AM. |
|
#33
|
||||
|
||||
|
Haha, nice one, I created one as well for my project yesterday
Quite useful indeed.
__________________
Zen X-Fi2 Apps: Notee-fi (notepad) | TicTacToe | Mahjongg http://www.starfare.eu/ - a free real-time strategy game. |
|
#34
|
||||
|
||||
|
Cool, yeah I noticed that I needed it once more, so I just modified the one I used in Black Jack to become a very simple universal one =P Does your's differ much from mine? Always interesting to see different solutions ^^
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#35
|
||||
|
||||
|
It's not universal and it requires an external (sandclock) image which is shown up instead of text, but it's the same at all. Uh, and the background is black with 75% transparency, maybe you can try that out as well, looks a bit more fancy. :P
The image needs to be closed at the end of the program and takes some memory during the runtime so I guess your one is the best solution.
__________________
Zen X-Fi2 Apps: Notee-fi (notepad) | TicTacToe | Mahjongg http://www.starfare.eu/ - a free real-time strategy game. |
|
#36
|
||||
|
||||
|
Quote:
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it! Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it. Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^ |
|
#37
|
||||
|
||||
|
I use currently 50 which is quite decent, 128 and 192 work good as well.
__________________
Zen X-Fi2 Apps: Notee-fi (notepad) | TicTacToe | Mahjongg http://www.starfare.eu/ - a free real-time strategy game. |
|
#38
|
||||
|
||||
|
Here is a code to add volume control to any app. It sets the volume when you click on it, and you can also scroll it.
It's almost universal and works pretty well so I thought I'd post it here. You may have to change the colors if it doesn't fit your app well, or you can add some graphics to it.. I couldn't find a way to save the text.color the app is using (to temporarily change it and set it back at the end), so it uses the same text.color as set in the app. If you want another text.color for the volume control you can change the text.color at the start of function volume(), and change it back at the end of it. If you have any problems adding this to your code, pm me and I'll try to help you out. Copy paste this function: Code:
function volume() local oldsize=text.size(16) --save text size to set it back later, and for now use size 16 local sheight=screen.height() --get the current screen height (depends on screen orientation) local swidth=screen.width() --get the current screen width (depends on screen orientation) while 1 do screen.fillrect(swidth-30,sheight-220,30,210,color.new(0,0,0)) --black background text.draw(swidth-27,sheight-218,audio.volume(),"center") --text.draw current volume level screen.drawrect(swidth-20,sheight-201,swidth-10,sheight-20,color.new(255,255,255)) --frame of volume bar screen.fillrect(swidth-18,(sheight-200)+(180-(180*(audio.volume()/25))),7,180*(audio.volume()/25),color.new(155,155,155)) --volume bar screen.update() if control.read(1) then if control.isButton()==1 and button.event()==1 then break --use home button click to end this function elseif control.isTouch()==1 then touch_x,touch_y=touch.pos() if touch.event()==2 then -- =touch.down if touch_x>=(swidth-30) and touch_y>=(sheight-220) then --if you touched somewhere in the volume control window if touch_y>=(sheight-200) and touch_y<=(sheight-20) then --if you touched within the frame of the volume bar, audio.volume(math.floor(((touch_y-(sheight-20))/7)*-1)) --calculate where you touched and set the volume at that level elseif touch_y<(sheight-200) then --if you touched just above the volume bar, audio.volume(25) --set volume to 25 elseif touch_y>(sheight-20) then -- if you touched just below the volume bar, audio.volume(0) --set volume to 0 end end elseif touch.event()==4 then -- =touch.click if touch_x<swidth-30 or touch_y<sheight-220 then --if you clicked outside the volume control window, break --end this function else audio.beep(440,100) --after tapping the volume bar, play beep (or replace this with a nice sound) end elseif touch.event()==32 and touch_x>=(swidth-30) and touch_y>sheight-200 and touch_y<sheight-20 then --if you moved within the frame of the volume bar audio.volume((math.floor((touch_y-(sheight-200))/7)-25)*-1) --calculate the position where you are moving, and set the volume at that level for i=0, 50 do control.read() --clear queque for smooth movements end elseif touch.event()==1 then -- =touch.up audio.beep(440,100) --after scrolling the volume bar, play beep (or replace this with a nice sound) end end end end text.size(oldsize) --set text size back at what it was before --If your game doesn't refresh the screen automatically, place something like "drawgame()" here end Code:
if control.isButton()==1 then if button.event()==16 then -- =button.hold volume() elseif button.event()==1 then -- =button.click break end |
|
#39
|
||||
|
||||
|
Her is my preloader with processbar:
load2.pngload1.png Code:
function preload() new_proc = proc + resadd;preheight = height/4*3+41-(new_proc*2-12);screen.fillrect(width/4,preheight,width/4*2,new_proc*2-12,black);screen.update();return new_proc;end; Code:
height = screen.height() width= screen.width() white = color.new(255,255,255); black = color.new(0,0,0); screen.fillrect(0,0,width,height,white); text.size(30); text.color(black); screen.drawrect(width/4,height/6*2+20,width/4*3,height/4*3+40,black); text.draw(0,height/6+20,"Load","center",width); screen.update(); resadd = 100/5+1;--you have to replace the 5 with the number of your files which you want to load an this number proc = resadd; screen.update(); Code:
highscoreslogo_img = image.load("gfx/highscoreslogo.png");proc=preload();
howtobtn_img = image.load("gfx/howtobtn.png");proc=preload();
logo_img = image.load("gfx/logo.png");proc=preload();
Code:
screen.fillrect(0,0,width,height,white); text.size(30); text.color(black); screen.drawrect(width/4,height/6*2+20,width/4*3,height/4*3+40,black); screen.fillrect(width/4,height/6*2+20,width/4*2,proc*2-12,black); text.draw(0,height/6+20,"Finish","center",width); screen.update(); os.wait(600); Code:
screen.orientation(1); Code:
height = screen.height() width= screen.width() |
|
#40
|
||||
|
||||
|
Code:
This isnt really a function snippit but the formats for os.date() %a = abbreviated weekday names (ie:Wed) %A = full weekday names(ie: Wednesday) %b = abbreviated month names (ie:Dec) %B = full month names (ie:December) %c = date and time (ie: 09/16/98 23:48:10) %d = day of the month(ie:16) %H = hour in 24hour clock %I = hour in 12hour clock %M = minutes(ie:48) %m =month(i:9) %p = either am or pm %s = seconds(ie:10) %w = weekday(ie:3) %x = date (ie: 09/16/98) %X = time(ie: 23:48:10) %Y = full year(ie:1998) %y = two digit year(ie:98) %% = the character %
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:05 AM.












Quite useful indeed.
Linear Mode
