Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
25 May, 2013, 17:42:04 *
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 1698 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: 20 May, 2013, 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
« on: 04 April, 2012, 08:27:10 »
0

Hi everyone,
I haven't been active much on the forums in the past few days (in comparison with the past few months), but I have created a simple Lua program while experimenting on oclua. I have transferred the code into a Lua file on the computer and here it is!
Basically you start with a value of 0 and you can choose to Attack or Defend to try and increase your value. right now I am experimenting with the points system as Attack carries no more risk than Defence and both are as equally likely to win as to lose.

Here is also the source code. Feel free to look through it, comment on my program, how my coding is, any improvements on optimising it or making it easier for another programmer to read, and stuff. The more feedback I get the more I can use the feedback to broaden my understanding of Lua!

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
--[[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]]--
v=0
t=0
r1=0
r2=2
r3=0
r4=2
function on.paint(gc)
gc:drawString("[A]tk or [D]ef?    [R]eset",10,10,"top")
gc:drawString(v,10,30,"top")
if r2==1 then
gc:drawString("Attack was successful. +" .. r1,10,50,"top")
end
if r2==0 then
gc:drawString("Attack was unsuccessful. -" .. r1,10,50,"top")
end
if r4==1 then
gc:drawString("Defence was successful. +" .. r3,10,50,"top")
end
if r4==0 then
gc:drawString("Defence was unsuccessful. -" .. r3,10,50,"top")
end
gc:drawString("Turn " .. t,200,10,"top")
if v~=0 or t~=0 then
gc:drawString("Average " .. v/t,200,30,"top")
end
gc:setFont("sansserif","r",8)
gc:drawString("Numstrat - Jason Ho",10,200,"top")
end
function on.charIn(ch)
cha=ch
if cha=="a" or cha=="d" then
if cha=="a" then
r4=2
r1=math.random(4,5)
r2=math.random(0,1)
if r2==1 then
v=v+r1
end
if r2==0 then
v=v-r1
end
end
if cha=="d" then
r2=2
r3=math.random(1,3)
r4=math.random(0,1)
if r4==1 then
v=v+r3
end
if r4==0 then
v=v-r3
end
end
t=t+1
end
if cha=="r" then
v=0
t=0
r1=0
r2=2
r3=0
r4=2
end
platform.window:invalidate()
end

With my current knowledge, I think a Lua version of my TI-nspire Basic Game, Jason's TI-nspire Hold'em is achievable. I just need to get working on it, persistently Wink

Thanks everyone!

* Numstrat.lua (1.46 KB - downloaded 19 times.)
* Numstrat.tns (1.33 KB - downloaded 18 times.)
« Last Edit: 04 April, 2012, 08:45:51 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):
Nick
LV9 Veteran (Next: 1337)
*********
Offline Offline

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


Total Post Ratings: +158

View Profile WWW
« Reply #1 on: 04 April, 2012, 08:50:13 »
+1

looks good. I've tried it and it runs fine. But there are some things i would change:
- make the average value round (floor or ceil whatever, but it does not now so it dissapears partly from screen because it's too long)
- why do you do "cha = ch" ? since you could just be using the ch from your argument, couldn't you?
- i would make a on.create() which contains all the r1=0, r2=2 etc so that when you press "r" you can just call on.create() and you don't have to type it twice.
- maybe make a table with those value instead of 5 different variables. Like r1 = table[1] etc. but then you have to know what value is at what place

These are just thought, it's already great as is Smiley

edit: and why do you do "if cha=="a" or cha=="d" then if cha=="a" then.." ? that's just twice the same statement that follows, this only takes time and space Smiley
« Last Edit: 04 April, 2012, 08:51:43 by Nick » Logged

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

Gender: Male
Last Login: 20 May, 2013, 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 #2 on: 04 April, 2012, 08:59:18 »
0

Thanks Nick! That's a great summary of things to fix.
Most of that stuff I was partly aware of already, but just hadn't put in yet.
- So how about if I wanted to display the average up to 2 decimal places? i.e. Fix2?
- cha=ch probably because I changed it from a getchar program I got from jimbauwens and just left it there
- Yes on.create() was what I was looking for thanks
- For a table is that different to a matrix/array/list?
- "if cha=="a" or cha=="d" then if cha=="a" then.." I think I did that because there is t=t+1 at the end. But it would make more sense (and save more space), to put t=t+1 inside the if cha=="a" and if cha=="d" I think then.

Thanks for the help!
I used http://wiki.inspired-lua.org/ for some help.
« Last Edit: 04 April, 2012, 12:35:10 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):
Nick
LV9 Veteran (Next: 1337)
*********
Offline Offline

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


Total Post Ratings: +158

View Profile WWW
« Reply #3 on: 04 April, 2012, 12:04:50 »
0

to mak eit only display 2 decimals after the comma, you can do math.floor(average*10)/10. I don't know if there's another way to do this, but that's my way Smiley And i don't think there's an easy way to make it only have to decimals at all...

and i think it's faster to put twice t = t+1 than if since if is a statement, the other one just an addition, which is faster

a table is te same as a list in lua, you don't have two dimensional things. just do e.g.

1
2
3
4
5
6
7
8
9
10
11
12
13
function on.create()
     vars = {0, 0, 0, 2, 0, 2}
end

--this must in the if ch=="a" thingie

if vars[3] = 0 then
     vars[1] = vars[1]+1
end
[code]

this might be a bit more timeconsuming to type, but it think it's more beautiful to see, rather than 5 vars :)
 
[/code]
Logged

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

Gender: Male
Last Login: 20 May, 2013, 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 #4 on: 04 April, 2012, 12:37:07 »
0

to mak eit only display 2 decimals after the comma, you can do math.floor(average*10)/10. I don't know if there's another way to do this, but that's my way Smiley And i don't think there's an easy way to make it only have to decimals at all...

and i think it's faster to put twice t = t+1 than if since if is a statement, the other one just an addition, which is faster

a table is te same as a list in lua, you don't have two dimensional things. just do e.g.

1
2
3
4
5
6
7
8
9
10
11
12
13
function on.create()
     vars = {0, 0, 0, 2, 0, 2}
end

--this must in the if ch=="a" thingie

if vars[3] = 0 then
     vars[1] = vars[1]+1
end
[code]

this might be a bit more timeconsuming to type, but it think it's more beautiful to see, rather than 5 vars :)
 
[/code]

Thanks Nick, I shall update this if I have time.
From what I gather table is equivalent to list
and an array is equivalent to matrix
Thanks!
Hopefully this will just be the beginning of my Journey in Lua Cheesy
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):
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 14:29:04
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #5 on: 04 April, 2012, 13:21:01 »
0

Lua doesn't have list, arrays or matrices.
The only thing similar are tables, and tables blow all of the other things away.
You can easily combine tables to get a matrix:


1
2
3
4
5
6
7
8
matrix= {
    {1,2,3},
    {4,5,6},
    {7,8,9}
}

print(matrix[2][3]) -- prints 6

You can put any lua object in a table, and you can use any object as a key.
Lua tables can also be manipulated by metatables and metamethods, making them extremely cool. But that is a bit more advanced Smiley
Logged

someone
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: Today at 00:50:32
Date Registered: 12 January, 2012, 19:07:23
Posts: 48


Total Post Ratings: +9

View Profile
« Reply #6 on: 05 April, 2012, 02:52:28 »
+1

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
« Last Edit: 08 April, 2012, 20:22:41 by someone » Logged
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 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 #7 on: 08 April, 2012, 01:34:18 »
0

Thanks someone, though I'm don't completely understand sections of it.
So in your version "state" plays an important part here. and I also see "chance" defined as a table?
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: Today at 00:50:32
Date Registered: 12 January, 2012, 19:07:23
Posts: 48


Total Post Ratings: +9

View Profile
« Reply #8 on: 08 April, 2012, 20:20:22 »
0

"action" was used to classify which actions can be performed when you press a key. I'm not sure if you intend to add more command actions (like flee, heal, steal, etc.), but if you do, you can now easily add them on the table.

"state", behaves as a filter event. It keeps track of the action executed. Then you can control in your program what to do when something happened.

"chance" was created to reduce the amount of lines. Since attack & defense behave alike, you can group them. I added the blank one just in case you want to create something like a "miss" or so. This is an ordered table, so when the variable r2 = 1, chance[r2] is the same as "successful . +"


This link might be helpful for understanding more about how to use tables
http://nixstaller.sourceforge.net/manual/0.2/nixstaller_9.html#Tables
Logged
linuxgeek96
LV3 Member (Next: 100)
***
Offline Offline

Last Login: Today at 04:12:09
Date Registered: 17 October, 2011, 18:15:24
Location: WLHS
Posts: 97


Total Post Ratings: +3

View Profile WWW
« Reply #9 on: 08 April, 2012, 22:56:47 »
0

any easy way to rotate a table 90 degrees?
Logged

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 #10 on: 08 April, 2012, 23:58:45 »
0

any easy way to rotate a table 90 degrees?

What exactly do you mean by that?

You can transpose matrices I guess.
Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 13:26:24
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50235


Total Post Ratings: +2615

View Profile WWW
« Reply #11 on: 09 April, 2012, 00:03:29 »
0

From what I remember this was possible in TI-83+ BASIC, although it was rather slow and would only let you rotate the matrix in one direction (meanign rotating the opposite way took 3 times more time, as you had to use the transpose command 3 times), so I wouldn't be surprised if it was possible on the Nspire too.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 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 #12 on: 09 April, 2012, 02:23:00 »
0

"action" was used to classify which actions can be performed when you press a key. I'm not sure if you intend to add more command actions (like flee, heal, steal, etc.), but if you do, you can now easily add them on the table.

"state", behaves as a filter event. It keeps track of the action executed. Then you can control in your program what to do when something happened.

"chance" was created to reduce the amount of lines. Since attack & defense behave alike, you can group them. I added the blank one just in case you want to create something like a "miss" or so. This is an ordered table, so when the variable r2 = 1, chance[r2] is the same as "successful . +"


This link might be helpful for understanding more about how to use tables
http://nixstaller.sourceforge.net/manual/0.2/nixstaller_9.html#Tables

Thanks someone, it seems you know a great deal about Lua. Have you got or are planning any Lua projects yourself?

Also it would probably be possible to transpose matrices, you would somehow do a for .... do command to transpose x and y coordinates of each value in the matrix over to the new coordinates.
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: Today at 00:50:32
Date Registered: 12 January, 2012, 19:07:23
Posts: 48


Total Post Ratings: +9

View Profile
« Reply #13 on: 09 April, 2012, 22:05:48 »
0

Well, I've been reading some documentation regarding LUA & Nspire LUA, so I know it more or less. I would say like at intermediate level...

As for projects, I recently remade a Nonogram program, that you can check on its topic:
http://www.omnimaga.org/index.php?topic=13134.0
Logged
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 #14 on: 11 April, 2012, 08:18:20 »
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
Logged

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.382 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.