Author Topic: Ti RPG 2 done in Lua (V0.06)  (Read 32786 times)

0 Members and 5 Guests are viewing this topic.

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #30 on: March 05, 2012, 05:47:59 pm »
In the code I give him credit, but I know what you mean about showing more direct credit in the game. It IS his game, and even though I am doing all the work with the lua with his permission, it is all based on his mechanics. He made a great game considering the massive limitations of the Nspire Basic, and I am in awe still as I would have given up with the prgm defines and deconstructs he does all through the game.

In other other news, I was slightly way-laid, so the playable version of the lua code wont be until tomorrow. (Although I doubt there was a line waiting for it to release, I will still do my best to have it come out relatively soon) Thanks for the interest! But what I would like too is if there are better ways of doing the certain things I am doing. My code is always available on the host-post. I know time is valuable though. Have a great monday everyone!



OH, and what is a way through Lua and the Nspire that you can prompt for user input and get it in as a string.. I'll be looking through lua-inspired as well.
« Last Edit: March 05, 2012, 05:52:36 pm by Ghezra »

Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #32 on: March 05, 2012, 07:40:58 pm »
Nevermind (for now anyways) I ended up using a combination of on.char and on.enter to expand the banking system. It works now.. more or less. Although I can imagine there are definitely better ways of doing it.
Code: [Select]
function on.charIn(char)
     ....
     elseif place == "bank" then
if char=="0" or char=="1" or char=="2"or char=="3"or char=="4"or char=="5"or char=="6"or char=="7"or char=="8"or char=="9" then
if transaction == 0 then
transaction = char + 0
else
transaction = transaction..char
end
elseif char == "-" then
banktype = -1
                        line6 = "Withdraw : "..transaction
elseif char == "+" then
banktype = 1
                        line6 = "Deposit : "..transaction
end
     end
     ....
end
function on.enterKey()
     ....
     elseif place == "bank" then
if transaction ~= 0 and transaction ~= nil then
money = 0 + transaction
if bankgold >= -1*money and money <= gold then
bankgold = bankgold + (banktype*money)
gold = gold - (banktype*money)
end
line2 = "Balance : "..bankgold
transaction = 0
end
     end
     ....
end

Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #33 on: March 05, 2012, 08:05:39 pm »
Quote
if char=="0" or char=="1" or char=="2"or char=="3"or char=="4"or char=="5"or char=="6"or char=="7"or char=="8"or char=="9" then

in python, it would just be "if char in {"1","2","3","4","5","6","7","8","9","0"}" I haven't really figured out a good way to shorten this either.

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #34 on: March 05, 2012, 10:09:09 pm »
Combat is coming along faster than I thought.

Here's a simple teaser... :) Scrolling combat text... graphical HP bars?!...
Spoiler For Spoiler:


Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #35 on: March 06, 2012, 04:59:37 am »
Wow I like the graphical health bar and stats along the right. Definitely improving on the Basic version.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #36 on: March 06, 2012, 05:13:46 am »
Quote
if char=="0" or char=="1" or char=="2"or char=="3"or char=="4"or char=="5"or char=="6"or char=="7"or char=="8"or char=="9" then

in python, it would just be "if char in {"1","2","3","4","5","6","7","8","9","0"}" I haven't really figured out a good way to shorten this either.

if char >= "0" and char <= "9" then

kthxbye

end
« Last Edit: March 06, 2012, 05:14:47 am by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Ti RPG 2 for the Nspire done in Lua
« Reply #37 on: March 06, 2012, 06:06:09 am »
Of course, so simple, Levak, I didn't get the opportunity to look at that properly and post about that.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04)
« Reply #38 on: March 06, 2012, 07:39:29 pm »
Thanks Levak!!

Updated the code and completed combat enough to where its possible to fight, level up, and die. Save and load work.

If you encounter any major issues, post here (I'm sure I know of them, because obviously the code isn't done yet.) but at least it will focus me into fixing those bugs first.

I uploaded the .tns of the newest version V0.04, so check it out! Suggestions always welcome!

Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04)
« Reply #39 on: March 06, 2012, 07:52:28 pm »
Oh yeah... That is good way, forgot about alphabetical comparison of strings. :P

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Ti RPG 2 done in Lua (V0.04)
« Reply #40 on: March 07, 2012, 05:31:46 am »
Nice! Some of the options don't work yet of course, but what you have so far definitely reflects on superbany's version while bringing in the advantages of Lua at the same time!
Also, there's a bug when I try to upgrade my defence, looks like you've spelled defence "defense".

I'll try and look for other bugs in your source code too. I am also trying to learn Lua at the moment, so this could help.
EDIT: Lol, Now the document is stuck at the error page, not sure how to return to the game.
« Last Edit: March 07, 2012, 05:41:14 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04)
« Reply #41 on: March 07, 2012, 09:09:21 am »
If there is a lua code problem, the only way to return is to reload it from the computer. (Or you can try exiting out of that document without saving and reloading it.)

I'll have a fixed version with another 1-2 features implemented out in a few hours.

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04)
« Reply #42 on: March 07, 2012, 11:54:11 am »
Updated original post.

V0.04a
-Fixed Defence bug
-Added Inn
-Added Town conversations
-Days now cycle with Inn stays and not with combat
-Money in the bank gets interest per Inn stay now

Offline someone

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +9/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04a)
« Reply #43 on: March 07, 2012, 02:11:33 pm »
Nice to see there's activity again in this game :)

I see that there is no color, I guess that was just something I was modifying :P (changed the text to have a blue color instead of black...)

Also noticed that you don't use arrays, I highly recommend you to change the variables you use for the strings into arrays of strings. It should help a lot reducing the amount of code you have. Well, you should really use it when you have variables like foo1, foo2, etc. that are related each other...

For example:
Instead of talkLine1, talkLine2, etc., you can create a variable talkLine = {} and then call them like this talkLine[1], talkLine[2], etc.

Here's a code example, so that you can see it easier:
Code: [Select]
function on.create()
    initChoice  = 1
    showEquip   = 0
    showUp      = 0
    mainChoice  = 1
    magicSelect = 0
    race        = "Spirit"
    mainMenu    = 1
    init        = 0
    escMenu     = 0
    
    line = {}
    for i=1, 10 do
        line[i] = ""
    end

    castleLine = {}
    for i=1, 4 do
        castleLine[i] = ""
    end

    townLine = {}
    for i=1, 10 do
        townLine[i] = ""
    end

    combatLine = {}
    for i=1,8 do
        combatLine[i] = ""
    end

    upLine = {}
    for i=1, 8 do
        upLine[i] = ""
    end

    talkLine = {}
    for i=1,5 do
        talkLine[i] = ""
    end
    
    platform.window:invalidate()
    --what else would be good to do as the program initializes?
end

function on.paint(gc)
    ...
    for i=1,#talkLine do
        gc:drawString(talkLine[i], 5, 20+shm*(i-1))
    end
    ...
« Last Edit: March 07, 2012, 02:52:06 pm by someone »

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04a)
« Reply #44 on: March 07, 2012, 04:53:31 pm »
Someone, that's a great suggestion! I'm unfamiliar with arrays, so I coded to my strengths but it would definitely help with cleaning up some of the code. I'll have to work a little bit to try to implement it soon after I get some more features ironed out.

Color is something that I'd love to do, but I was suggested to hash out all the feature/mechanics first and then work in the color afterwards. Based on how everything is drawn in on.paint() I can easily see how I can work in colors once I do get to that point. I personally only have a black and white Nspire (not the blue face one).

I also plan on adding sprites everywhere too. Not just the mainbanner as it is now. But I want to make sure that ALL Nspires have a good experience, instead of catering to CX's.

Keep the coding suggestions coming!