Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 07:47:37 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 [2]   Go Down
  Print  
Author Topic: Numstrat - Stumbling into Lua -  (Read 1693 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Topic starter
Total Post Ratings: +50

View Profile WWW
« Reply #15 on: 11 April, 2012, 13:34:12 »
0

I think he's talking about your own work. I know you've been doing some edits, optimizations, and remakes, but you could try making your own project.  Wink

As a suggestion, you could try making a Lua sudoku. It'd be easy enough and it'd be pretty nice.  Cheesy

Well kind of cyano. I was talking about any project anywhere that someone started and even though it is from someone else's project I'd still count it. Very nice..

And good idea for the Lua Sudoku.
I'm possibly leaning towards making some card games in Lua including Texas Hold 'em Poker (porting my Basic version), Hearts Solitare etc.
Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
Nick
LV9 Veteran (Next: 1337)
*********
Offline Offline

Gender: Male
Last Login: Yesterday at 19:51:51
Date Registered: 05 June, 2011, 20:01:07
Location: 51° 12′ 34″ N, 3° 13′ 31″ E
Posts: 1178


Total Post Ratings: +158

View Profile WWW
« Reply #16 on: 11 April, 2012, 22:08:36 »
0

For card games you might learn a lot from chockosta. He made the freecell clone, which is really nice and runs perfect. dragable cards, checking for values and freee places etc.
Logged

adriweb
Editor
LV9 Veteran (Next: 1337)
*
Offline Offline

Gender: Male
Last Login: Today at 00:38:33
Date Registered: 13 April, 2011, 18:42:59
Location: South of France
Posts: 1196


Total Post Ratings: +185

View Profile WWW
« Reply #17 on: 11 April, 2012, 23:19:32 »
0

Levak made an excellent Lua sudoku btw (quite advanced/complex Nspire Lua though) available here :
http://levak.free.fr/ftp/nspire/Sudoku/
Logged


TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation
cyanophycean314
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 03 May, 2013, 19:28:34
Date Registered: 07 December, 2011, 02:44:32
Location: Somewhere?
Posts: 363


Total Post Ratings: +42

View Profile
« Reply #18 on: 12 April, 2012, 10:04:24 »
0

Where do all these Lua programs pop out of?  Huh? There always seems to be unreleased programs hiding everywhere...
Logged

Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Topic starter
Total Post Ratings: +50

View Profile WWW
« Reply #19 on: 15 April, 2012, 03:47:05 »
0

For card games you might learn a lot from chockosta. He made the freecell clone, which is really nice and runs perfect. dragable cards, checking for values and freee places etc.

Yeah I've learnt a bit from him already. He has lots of nice Lua programs
Cyano too Cheesy
And it does take an effort to release programs, so there would be many development/unreleased programs lying around.

Anyway the code by someone:
Spoiler for Code by someone:
I redefined some variables, I think is more legible this way:


1
2
3
4
5
6
7
8
9
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--[[Things to do:
Declare variables first within a function
Make things more fun and complex
Points System:
OLD: Atk -{1,2,3} +{4,5} Def +{1,2,3} -{4,5}
NEW: Atk -{4,5} +{4,5} Def +{1,2,3} -{1,2,3}
Any better ways? Maybe make Atk more risky, so it's less about luck]]--

chance = { [-1] = "",
            [0] = "unsuccessful . -",
            [1] = "successful . +" }

action = { nothing="", attack="Attack", defense="Defense"}

function initialize_variables()
    v = 0
    t = 0
    r1 = 0
    r2 = -1
    state = action.nothing
end

--function on.create()
initialize_variables()
--end

function on.paint(gc)
    gc:setFont("sansserif","r",11)
    gc:setColorRGB(0,0,0)
   
    gc:drawString("[A]tk or [D]ef?    [R]eset",10,10,"top")
    gc:drawString(v,10,30,"top")

    if state == action.attack then
        gc:drawString("Attack was "  .. chance[r2] .. r1, 10, 50, "top")
    elseif state == action.defense then
        gc:drawString("Defense was " .. chance[r2] .. r1, 10, 50, "top")
    end

    gc:drawString("Turn " .. t,200,10,"top")
    if v~=0 or t~=0 then
        gc:drawString("Average " .. round(v/t,2), 200, 30, "top")
    end
    gc:setFont("sansserif","r",8)
    gc:drawString("Numstrat - Jason Ho",10,200,"top")
end

function on.charIn(ch)
    if ch=="a" then
        state = action.attack
        r1=math.random(4,5)
        r2=math.random(0,1)
        if r2==1 then
            v=v+r1
        else    --if r2==0 then
            v=v-r1
        end
        t=t+1
    end

    elseif ch=="d" then
        state = action.defense
        r1=math.random(1,3)
        r2=math.random(0,1)
        if r2==1 then
            v=v+r1
        else    --if r2==0 then
            v=v-r1
        end
        state=action.defense
        t=t+1
    end

    elseif ch=="r" then
        initialize_variables()
    end

    platform.window:invalidate()
end

function round(value, digits)
    return string.format("%." .. digits .. "f", value)
end


Is a bit advanced for me. So I'll create things my own way and see if I can implement those things in as I go.
« Last Edit: 15 April, 2012, 03:48:24 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
someone
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 18 May, 2013, 02:40:46
Date Registered: 12 January, 2012, 19:07:23
Posts: 48


Total Post Ratings: +9

View Profile
« Reply #20 on: 16 April, 2012, 17:16:18 »
0

Well, I agree that the first part was a little abstract, so I removed it.

If you have any question on this code, be free to ask.


1
2
3
4
5
6
7
8
9
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--[[Things to do:
Declare variables first within a function
Make things more fun and complex
Points System:
OLD: Atk -{1,2,3} +{4,5} Def +{1,2,3} -{4,5}
NEW: Atk -{4,5} +{4,5} Def +{1,2,3} -{1,2,3}
Any better ways? Maybe make Atk more risky, so it's less about luck]]--

-- Call this function whenever you want to set the variables to their original values
function initialize_variables()
    v = 0
    t = 0
    r1 = 0
    r2 = -1
    state = ""
end

--function on.create()
initialize_variables()
--end

function on.paint(gc)
    gc:setFont("sansserif","r",11)
    gc:setColorRGB(0,0,0)
   
    gc:drawString("[A]tk or [D]ef?    [R]eset",10,10,"top")
    gc:drawString(v,10,30,"top")

    if state == "attack" then
        if r2 == 1 then
            gc:drawString("Attack was successful . + "  .. r1, 10, 50, "top")
        else    --if r2 == 0 then
            gc:drawString("Attack was unsuccessful . -" .. r1, 10, 50, "top")
        end
    elseif state == "defense" then
        if r2 == 1 then
            gc:drawString("Defense was successful . + "  .. r1, 10, 50, "top")
        else    --if r2 == 0 then
            gc:drawString("Defense was unsuccessful . -" .. r1, 10, 50, "top")
        end
    end

    gc:drawString("Turn " .. t,200,10,"top")
    if v~=0 or t~=0 then
        gc:drawString("Average " .. round(v/t,2), 200, 30, "top")
    end
    gc:setFont("sansserif","r",8)
    gc:drawString("Numstrat - Jason Ho",10,200,"top")
end

function on.charIn(ch)
    if ch=="a" then
        state = "attack"
        r1=math.random(4,5)
        r2=math.random(0,1)
        if r2==1 then
            v=v+r1
        else    --if r2==0 then
            v=v-r1
        end
        t=t+1

    elseif ch=="d" then
        state = "defense"
        r1=math.random(1,3)
        r2=math.random(0,1)
        if r2==1 then
            v=v+r1
        else    --if r2==0 then
            v=v-r1
        end
        t=t+1

    elseif ch=="r" then
        initialize_variables()
    end

    platform.window:invalidate()
end

--This function rounds the value passed depending on the number of digits needed
function round(value, digits)
    return string.format("%." .. digits .. "f", value)
end
Logged
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Topic starter
Total Post Ratings: +50

View Profile WWW
« Reply #21 on: 19 April, 2012, 07:45:27 »
0

I noticed that the number of lines has increased a bit from 67 to 84. But I guess your modification does allow for expansion if I wish.
Thanks for all your help someone.
Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Topic starter
Total Post Ratings: +50

View Profile WWW
« Reply #22 on: 10 September, 2012, 07:49:56 »
0

I'm back. I looked back at a copy I had a few days ago of the code that someone put in above and I get what it's saying.
I mostly get the first version here with the use of tables (which I'll have to familiarise myself with)
http://www.omnimaga.org/index.php?topic=13161.msg241277#msg241277
« Last Edit: 10 September, 2012, 07:50:01 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
Twilight Sparkle
LV1 Newcomer (Next: 20)
*
Offline Offline

Last Login: 23 September, 2012, 22:34:09
Date Registered: 17 September, 2012, 18:29:30
Posts: 5


Total Post Ratings: +2

View Profile
« Reply #23 on: 18 September, 2012, 17:34:33 »
+1

Hi, just wanted to note that you can change

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    if state == "attack" then
        if r2 == 1 then
            gc:drawString("Attack was successful . + "  .. r1, 10, 50, "top")
        else    --if r2 == 0 then
            gc:drawString("Attack was unsuccessful . -" .. r1, 10, 50, "top")
        end
    elseif state == "defense" then
        if r2 == 1 then
            gc:drawString("Defense was successful . + "  .. r1, 10, 50, "top")
        else    --if r2 == 0 then
            gc:drawString("Defense was unsuccessful . -" .. r1, 10, 50, "top")
        end
    end

to


1
2
3
4
if state ~= "" then
gc:drawString((state=="attack" and "Attack" or "Defense") .. " was " .. (r2==0 and "unsuccessful. -" or "successful. +") .. r1, 10, 50, "top")
end

Makes it a bit smaler Cheesy
« Last Edit: 18 September, 2012, 17:35:36 by Twilight Sparkle » Logged
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:47:15
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #24 on: 18 September, 2012, 17:42:54 »
0

Hmm, optimization's like that are good indeed.
I would also recommend you to *always* use at least a simple screen manager, it makes life easier for the developer, and it's easier for him to make the game look better too Smiley
« Last Edit: 18 September, 2012, 17:43:17 by Jim Bauwens » Logged

Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Topic starter
Total Post Ratings: +50

View Profile WWW
« Reply #25 on: 23 September, 2012, 03:29:34 »
0

Hmm I like that optimisation. I am still working on Lua programming, just a bit slowly.
And Jim Bauwens, what do you mean by a screen manager?
« Last Edit: 23 September, 2012, 03:29:55 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
Twilight Sparkle
LV1 Newcomer (Next: 20)
*
Offline Offline

Last Login: 23 September, 2012, 22:34:09
Date Registered: 17 September, 2012, 18:29:30
Posts: 5


Total Post Ratings: +2

View Profile
« Reply #26 on: 23 September, 2012, 13:08:17 »
+1

A screen manager is something that allows you to devide your Lua applications in several pieces.
Basically, you will have a paint handler for every scene in your program, without needing to put all your stuff in on.paint.

Here is a simple screen manager, so you can understand how it works a bit:

1
2
3
4
5
6
7
8
9
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

------ Screen Manager -------

-- In this table we will contain all 'screen' objects.
Screens = {}

-- This function is used to push a screen into the above table (Screens)
function pushScreen(scrn)
    table.insert(Screens, scrn)
    platform.window:invalidate()
end

-- This function is used to remove the last item in the 'Screens' table
function pullScreen()
    table.remove(Screens)
    platform.window:invalidate()
end

-- Return the last item of 'Screens', the current screen
function currentScreen()
    return Screens[#Screens]
end

-- This function will loop through all screens in the 'Screens' table and draw them
function paintScreens(gc)
    for _, screen in ipairs(Screens) do
        screen:paint(gc)
    end
end

-- Our screen object class
Screen = class()

function Screen:arrowKey() end
function Screen:paint()        end
function Screen:charIn()      end
function Screen:enterKey()  end

-- Link the Screen manager to 'on'

function on.paint(gc)              paintScreens(gc)                           end
function on.arrowKey(arrow) currentScreen():arrowKey(arrow) end
function on.charIn(ch)            currentScreen():charIn(ch)           end
function on.enterKey()            currentScreen():enterKey()          end

--- User code ----
popup = Screen()

function popup:paint(gc)
    gc:setColorRGB(255,255,255)
    gc:fillRect(50,50,200,100)
    gc:setColorRGB(0,0,0)
    gc:drawRect(50,50,200,100)
    gc:drawString("Hey!", 52, 50, "top")
    gc:drawString("Press enter to hide this popup", 52, 80, "top")
end

function popup:enterKey()
    pullScreen()
end


main = Screen()

function main:paint(gc)
    gc:drawString("Hello World! Press enter :D", 10, 10, "top")
end

function main:enterKey()
    pushScreen(popup)
end

pushScreen(main)

Adriweb and Jim Bauwens created a more advanced screen manager together with a nice widget API, you can find it on the github page for EEPro I think.
« Last Edit: 23 September, 2012, 20:42:09 by Twilight Sparkle » Logged
adriweb
Editor
LV9 Veteran (Next: 1337)
*
Offline Offline

Gender: Male
Last Login: Today at 00:38:33
Date Registered: 13 April, 2011, 18:42:59
Location: South of France
Posts: 1196


Total Post Ratings: +185

View Profile WWW
« Reply #27 on: 23 September, 2012, 14:04:03 »
0

Indeed, that's ETK. Jim created the core of it.
You can find the screen + widgets etc. here 
https://github.com/adriweb/EEPro-for-Nspire/blob/master/Global%20Libraries

But that's far more advanced and probably too complex for simpler usecases than FormulaPro (eepro).
Logged


TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:47:15
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #28 on: 23 September, 2012, 14:53:54 »
0

Jonius, that code that Twilight gave you should point you in the right direction Smiley (Thanks Twilight!)
You can also find some more info here: http://www.inspired-lua.org/2012/02/how-to-create-a-screen-manager/ .

Adriweb: isn't Tower defence more simple ? I think most apps will be more simple than FormulaPro Tongue
Logged

adriweb
Editor
LV9 Veteran (Next: 1337)
*
Offline Offline

Gender: Male
Last Login: Today at 00:38:33
Date Registered: 13 April, 2011, 18:42:59
Location: South of France
Posts: 1196


Total Post Ratings: +185

View Profile WWW
« Reply #29 on: 23 September, 2012, 15:18:03 »
0

Well, you can "simply" take this code until line 1440 : https://github.com/adriweb/LuaTowerDefense/blob/master/LuaTowerDefense.lua
Logged


TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.277 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.