0 Members and 2 Guests are viewing this topic.
Okay, I changed it a little to get it to work, but a big problem was that you were trying to compare a number and a string.However, I noticed that if you multiply the string of a number by one, it makes it that number.Also, I moved the congrats and correcting strings into the function on.paint(gc) sectionMy changes are probably w=quite ugly and inefficient, but it gets all the way to the “lets get rolling” stringCode: [Select]--[[TI-nspire Hold 'em - A Lua RemakeHistory:v0.01 Created 2012/09/23 really started working 2012/10/07Buggy can hardly do anything, currently can change Chips, Big Blind, Small Blind]]--function init_variables() cc=0 bb=0 sb=0 gopt=1 scrn=1 message=""endinit_variables() function on.paint(gc) gc:setFont("sansserif","r",10) gc:setColorRGB(0,0,0) -- gc:setPen("thin","smooth") Is this necessary? if scrn==1 then gc:drawString("[c] Chips " .. cc,10,10,"top") gc:drawString("[b] Big Blind " .. bb,10,25,"top") gc:drawString("[s] Small Blind " .. sb,10,40,"top") gc:drawRect(10,70,20,20) if message=="wrong" then gc:drawString("Check these conditions",10,70,"top") gc:drawString("Chips between 100 and 10 million",10,85,"top") gc:drawString("Big blind between 0.001 and 0.1 Chips",10,100,"top") gc:drawString("Small blind between 0.01 and 0.5 Big Blind",10,115,"top") end elseif scrn==3 then gc:drawString("Right let's get rolling!",10,10,"top") end if scrn==2 then if message=="congrats" then gc:drawString("Congrats! Settings set up correctly",10,70,"top") end end endfunction on.charIn(ch) if ch >= "0" and ch <= "9" then -- checking for digit inputs if scrn==1 then if gopt==1 then if string.len(cc) <= 7 then -- limit string length cc = cc .. ch -- concatenate platform.window:invalidate() -- screen refresh end elseif gopt==2 then if string.len(bb) <= 6 then -- and sb <= 0.1bb then -- limit string length and bb to <= 0.1cc (now moved) bb = bb .. ch -- concatenate platform.window:invalidate() -- screen refresh end elseif gopt==3 then if string.len(sb) <= 6 then -- and sb <= 0.1bb then -- limit string length and sb to <= 0.1bb (now moved) sb = sb .. ch -- concatenate platform.window:invalidate() -- screen refresh end end end end--Game settings keys if scrn==1 then if ch=="c" then --Ok there must be a way to optimise this block gopt = 1 elseif ch=="b" then gopt = 2 elseif ch=="s" then gopt = 3 end platform.window:invalidate() endendfunction on.enterKey()cc=1*ccbb=1*bbsb=1*sb if scrn==2 then scrn=3 end if scrn==1 and cc >= 100 and cc <= 10000000 and bb >= 0.001*cc and bb <= 0.1*cc and sb >= 0.01*bb and sb <= 0.5*bb then message="congrats" scrn=2 gopt=0 else message="wrong" end endfunction on.backspaceKey() if gopt==1 then --Ok there must be a way to optimise this block. Again. cc = string.usub(cc,0,-2) -- deleting last char elseif gopt==2 then bb = string.usub(bb,0,-2) -- deleting last char elseif gopt==3 then sb = string.usub(sb,0,-2) -- deleting last char end platform.window:invalidate() endplatform.window:invalidate()
--[[TI-nspire Hold 'em - A Lua RemakeHistory:v0.01 Created 2012/09/23 really started working 2012/10/07Buggy can hardly do anything, currently can change Chips, Big Blind, Small Blind]]--function init_variables() cc=0 bb=0 sb=0 gopt=1 scrn=1 message=""endinit_variables() function on.paint(gc) gc:setFont("sansserif","r",10) gc:setColorRGB(0,0,0) -- gc:setPen("thin","smooth") Is this necessary? if scrn==1 then gc:drawString("[c] Chips " .. cc,10,10,"top") gc:drawString("[b] Big Blind " .. bb,10,25,"top") gc:drawString("[s] Small Blind " .. sb,10,40,"top") gc:drawRect(10,70,20,20) if message=="wrong" then gc:drawString("Check these conditions",10,70,"top") gc:drawString("Chips between 100 and 10 million",10,85,"top") gc:drawString("Big blind between 0.001 and 0.1 Chips",10,100,"top") gc:drawString("Small blind between 0.01 and 0.5 Big Blind",10,115,"top") end elseif scrn==3 then gc:drawString("Right let's get rolling!",10,10,"top") end if scrn==2 then if message=="congrats" then gc:drawString("Congrats! Settings set up correctly",10,70,"top") end end endfunction on.charIn(ch) if ch >= "0" and ch <= "9" then -- checking for digit inputs if scrn==1 then if gopt==1 then if string.len(cc) <= 7 then -- limit string length cc = cc .. ch -- concatenate platform.window:invalidate() -- screen refresh end elseif gopt==2 then if string.len(bb) <= 6 then -- and sb <= 0.1bb then -- limit string length and bb to <= 0.1cc (now moved) bb = bb .. ch -- concatenate platform.window:invalidate() -- screen refresh end elseif gopt==3 then if string.len(sb) <= 6 then -- and sb <= 0.1bb then -- limit string length and sb to <= 0.1bb (now moved) sb = sb .. ch -- concatenate platform.window:invalidate() -- screen refresh end end end end--Game settings keys if scrn==1 then if ch=="c" then --Ok there must be a way to optimise this block gopt = 1 elseif ch=="b" then gopt = 2 elseif ch=="s" then gopt = 3 end platform.window:invalidate() endendfunction on.enterKey()cc=1*ccbb=1*bbsb=1*sb if scrn==2 then scrn=3 end if scrn==1 and cc >= 100 and cc <= 10000000 and bb >= 0.001*cc and bb <= 0.1*cc and sb >= 0.01*bb and sb <= 0.5*bb then message="congrats" scrn=2 gopt=0 else message="wrong" end endfunction on.backspaceKey() if gopt==1 then --Ok there must be a way to optimise this block. Again. cc = string.usub(cc,0,-2) -- deleting last char elseif gopt==2 then bb = string.usub(bb,0,-2) -- deleting last char elseif gopt==3 then sb = string.usub(sb,0,-2) -- deleting last char end platform.window:invalidate() endplatform.window:invalidate()
My Klondike game is one of the first things I made, my code isn't that good. But if it helps you, go ahead and dig through it
function black()rcurrent=0gcurrent=0bcurrent=0endfunction red()rcurrent=255gcurrent=0bcurrent=0endfunction orange()rcurrent=255gcurrent=128bcurrent=0endfunction yellow()rcurrent=255gcurrent=255bcurrent=0endfunction green()rcurrent=0gcurrent=255bcurrent=0endfunction blue()rcurrent=0gcurrent=0bcurrent=255endfunction violet()rcurrent=255gcurrent=0bcurrent=255endfunction other()drawcolor=1drawwindow=0platform.window:invalidane()endfunction thin()linecurrent="thin"endfunction medium()linecurrent="medium"endfunction thick()linecurrent="thick"endfunction eraser()linecurrent="thick"rcurrent=255gcurrent=255bcurrent=255endmenu={}menu[1]={}menu[1][1]="color"menu[1][2]={"black",black}menu[1][3]={"red",red}menu[1][4]={"orange",orange}menu[1][5]={"yellow",yellow}menu[1][6]={"green",green}menu[1][7]={"blue",blue}menu[1][8]={"violet",violet}menu[1][9]={"other",other}menu[2]={}menu[2][1]="thickness"menu[2][2]={"thin",thin}menu[2][3]={"medium",medium}menu[2][4]={"thick",thick}menu[3]={"eraser",{"eraser",eraser}}toolpalette.register(menu)
I am going to try continuing this... AGAIN.Still that piece of code up there took close to over 7 hours?