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

0 Members and 7 Guests are viewing this topic.

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.04c)
« Reply #60 on: March 08, 2012, 07:38:42 pm »
You should definitely be getting post ratings for this ambitious project. I have given you some, as you deserve it and I like what I am seeing right now.
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 cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04c)
« Reply #61 on: March 08, 2012, 09:49:21 pm »
You've really been working nonstop! The improvements are great! You have the work ethic.  :)

About the number case on the previous page, you can also do
if tonumber(char) then
  your code
end

The main problem with that is if they enter another character say ".", it'll crash.
Edit: Never mind, I see what you did there. That's a lot better!
« Last Edit: March 08, 2012, 09:51:02 pm by cyanophycean314 »

Offline someone

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +9/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04c)
« Reply #62 on: March 09, 2012, 11:14:30 am »
I know that there is no case switch statement in LUA (although there's a work-around explained here, which I never got it to work like I wanted). However, if you have an ordered list, you can use the following code:

Code: [Select]
function equipment()
    --Define strings for current equipment
    --Helmet descriptions
    str_helm = {"Level 1 Leather Cap",
                "Level 2 Iron Guard",
                "Level 3 Mithril Helm",
                "Level 4 Mage Helm",
                "Level 5 3rd Age Helm",
                "Level 6 Ultimate Visage",
                "L3v31 7 L33t H31m"}
    curhelm = str_helm[helm]

    --Armor descriptions
    str_armor = {"Level 1 Leather Body",
                 "Level 2 Iron Mail",
                 "Level 3 Mithril Plate",
                 "Level 4 Enchanted Armor",
                 "Level 5 3rd Age Armor",
                 "Level 6 Champion's Plate",
                 "L3v31 7 L33t P1@t3"}
    curarmor = str_armor[armor]
   
    --Sword descriptions
    str_sword = {"Level 1 Bronze Dagger",
                 "Level 2 Iron Shortsword",
                 "Level 3 Mithril Longsword",
                 "Level 4 Godsword",
                 "Level 5 3rd Age Greatsword",
                 "Level 6 Great Broadsword",
                 "L3v31 7 L33t D3s1r0Y3r"}
    cursword = str_sword[sword]

    --Shield descriptions
    str_shield = {"Level 1 Wooden Guard",
                  "Level 2 Iron Buckler",
                  "Level 3 Mithril Square Shield",
                  "Level 4 Mirror Shield",
                  "Level 5 3rd Age Heraldic Shield",
                  "Level 6 Champion's Kiteshield",
                  "L3v31 7 L33t D3f3?d?r"}
    curshield = str_shield[shield]

    --Robe descriptions
    str_robe = {"Level 1 Brown Robe",
                "Level 2 Grey Robe",
                "Level 3 Blue Robe",
                "Level 4 White Robe",
                "Level 5 Black Robe",
                "Level 6 Epic Robe",
                "L3v31 7 l33t r0b3"}
    currobe = str_robe[robe]

    --Shoes descriptions
    str_shoes = {"Level 1 Leather Shoes",
                 "Level 2 Iron Studded Boots",
                 "Level 3 Mithril Studded Boots",
                 "Level 4 Shoes of Light",
                 "Level 5 3rd Age Runners",
                 "Level 6 Boots of Lightness",
                 "L3v31 7 L33t R?pp3rs"}
    curshoes = str_shoes[shoes]

    --Ring descriptions
    if ring == 0 then
        cur_ring = "None"
    else
        if ring_sight == 2 then
            cur_ring = "Ring of Sight"
        elseif ring_fear == 2 then
            cur_ring = "Ring of Fear"
        elseif ring_train == 2 then
            cur_ring = "Training Ring"
        elseif ring_wealth == 2 then
            cur_ring = "Ring of Wealth"
        elseif ring_cure == 2 then
            cur_ring = "Ring of Curing"
        elseif ring_health == 2 then
            cur_ring = "Ring of Health"
        elseif ring_l33t == 2 then
            cur_ring = "L33t R1ng"
        end
    end
   
    --Bow descriptions
    str_bow = {"None",
               "Level 2 Oak Shortbow",
               "Level 3 Maple Bow",
               "Level 4 Righteous Longbow",
               "Level 5 3rd Age Horn Bow",
               "Level 6 Champion's Bow",
               "L3v31 7 L33t b0W"}
    curbow = str_bow[bow]

    --Arrow descriptions
    if arrow_type == "normal" then
        cur_arrows = "Normal"
    elseif arrow_type == "fire" then
        cur_arrows = "Fire     "
    elseif arrow_type == "poison" then
        cur_arrows = "Poison "
    elseif arrow_type == "ice" then
        cur_arrows = "Ice      "
    elseif arrow_type == "magic" then
        cur_arrows = "Magic ?"
    elseif arrow_type == "light" then
        cur_arrows = "Light   "
    else
        cur_arrows = "L33t    "
    end
end

Skips some IF statements & reduce a couple of lines too... You could move the descriptions into the function on.create() so that you only create the description once (Or do the same thing you do with the image logo)...

I didn't changed the Ring & Arrow descriptions since I'm not sure how you use them. Well, they could be reduced if you use a single array for all rings...


At last, the function on.paint(gc) is getting a little to big, it would be good to split some parts into new functions, just remember to pass "gc" as a parameter:

Code: [Select]
--Define the height and width of the screen to be used the rest of on.paint
h = platform.window:height()
w = platform.window:width()

function on.paint(gc)
    --Sets the initial font and color
    gc:setFont("sansserif", "b", 10)
    gc:setColorRGB(0, 0, 0)
   
    ---values used throughout on.paint()
    local string_h = gc:getStringHeight(line[1])
    local pos_x = 0
    local pos_y = 0
    local shape_h = 0
    local shape_w = 0
-----------------------------Intro Screen of the game-----------------------------------------------
    if mainMenu == 1 then
        intro(gc)
       
    ---With mainMenu = 0 and init = 0, it means we are out of the Title screen, but in the middle of initialization aka character select
    elseif mainMenu == 0 and init == 0 then
        ...
    end
end

function intro(gc)
    --placing credits to superbany
        gc:setFont("sansserif", "b", 10)
        gc:drawString("Presenting Superbany's...", 4, 20)
       
        --placing credits to myself
        gc:setFont("sansserif", "b", 8)
        gc:drawString("Ported to Lua by Ghezra", w-gc:getStringWidth("Ported to Lua by Ghezra"), h)
       
        ...
end
h & w are globals now. You could rather put them also inside the on.create() function & redefine them on the function on.resize() if you feel the screen size could change.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Ti RPG 2 done in Lua (V0.04c)
« Reply #63 on: March 09, 2012, 11:19:25 am »
There is a better way to manage different scenes, using a screen manager.
http://www.inspired-lua.org/2012/02/how-to-create-a-screen-manager/ is a tutorial on how to make them, but it's in french.
I also posted something similar here on the forum a couple of times, so you might find it with a search.

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04c)
« Reply #64 on: March 09, 2012, 12:55:10 pm »
Excellent suggestions, on.paint is now half of its size with basically the different menu displays pulled out into their own functions.

equipment() now is reduced drastically as the equipment strings are all defined now in the arrays on.create() like someone suggested.

Also translated the screen manager into english and read it. But it just didn't feel right as a fit for my style of coding and it seemed too big of a changed that I'd have to spend too much time reworking code and not enough time finishing the code I need to add.

Also, in about 30 minutes I'll have encounter screen more like how it is in TI RPG 2, since there you could PICK which fight you did instead of it being random based on level. But I will still have a few tricks up my sleeve so no worries.


Wait.. I said I was going to take today off. Crackerjacks!

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04c)
« Reply #65 on: March 09, 2012, 02:21:30 pm »
Working on killing a few new bugs I had found while working with code (namely, game saving on death resulting in a loaded game with -3 hp...)

But to give you a glimpse at the new update that'll come tonight, Heres an animated gif of the new fight selection screen. Complete with if you've scanned the monster, its name is displayed as you select it, along with all of its scanned goodness in the combat screen. (Poison is in green on colored screen.. I just dont have the ability to show you that.. lol)

and control is through the up and down arrows. I know how much people like to use them :)


« Last Edit: March 09, 2012, 02:22:23 pm by Ghezra »

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04d)
« Reply #66 on: March 09, 2012, 07:01:09 pm »
Update posted.

Equipment store completed. Also I've been taking almost all of your suggestions to heart. You can see that reflected in the lua code.

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.04d)
« Reply #67 on: March 09, 2012, 11:27:00 pm »
The bugs that I had, I fixed.

The save game issue was that on.save and on.restore didn't work as I had intended. So I made it to where its saving inside the tns again with var.store

but to keep the save games from being altered, I used monitor and varChange. I attempted to modify them myself and it seems to prevent any sort of modification outside of the lua code. So theres that.

Also, scan works as intended now even from a loaded game. Win.

---Oh, and since the .lua was only grabbed once, I just kept the same version number, so that one person should download v0.04d again. FYI.
« Last Edit: March 09, 2012, 11:27:40 pm by Ghezra »

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.05)
« Reply #68 on: March 10, 2012, 12:54:55 am »
Update:
Newest version is runnable. 0.05 3/9/2012.

Magic store is added and fully functional
All spells work in combat as intended (That I know of)
revised code more (finally got loadstring() to work.. so have to revamp potion system again)


Heres an example of what I mean:
Code: [Select]
...
spellstats = {"spell_bolt", spell_bolt, 20, (spell_bolt+1)*5, 25}
...

...
assert(loadstring(spellstats[1].." = "..spellstats[1].." + 1"))()
...

That runs as if it was:
Code: [Select]
...
spell_bolt = spellbolt + 1
...

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.05)
« Reply #69 on: March 11, 2012, 01:21:50 am »
Whoah nice updates! But you must be really careful not to post too many posts in a short period of time (5 posts!) A minimum of 6 hours between posts is required, but sometimes that rule can be broken if you talk about another subject, though it's not recommended. ;)
« Last Edit: March 13, 2012, 01:12:01 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 Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Ti RPG 2 done in Lua (V0.05)
« Reply #70 on: March 11, 2012, 07:56:16 am »
Code: [Select]
...
spellstats = {"spell_bolt", spell_bolt, 20, (spell_bolt+1)*5, 25}
...

...
assert(loadstring(spellstats[1].." = "..spellstats[1].." + 1"))()
...

That runs as if it was:
Code: [Select]
...
spell_bolt = spellbolt + 1
...

Loadstring is not the correct thing to use here, there is something much better.
You need to know that every function, table, variable, etc is part of a table.
string.char is the same as string["char"].
_G is reference to the global table, the table that contains string, math, spell_bolt and other variables.
You can do something like this instead of using loadstring:
Code: [Select]
_G[ spellstats[1] ] = _G[ spellstats[1] ] +1

This is a much better and cleaner method :)

Offline Ghezra

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +4/-0
    • View Profile
Re: Ti RPG 2 done in Lua (V0.06)
« Reply #71 on: March 18, 2012, 10:47:23 pm »
Thank you for the _G ! It's worked perfectly, or at least, it hasn't spit an error at me yet.

I've been down a bit, but not because I haven't been busy. Reallly close to getting all the features finished into the game from TIRPG2. Once content is fully loaded, then I can do more fine tuning on the Gui and display/colors and such.

Spoiler For Spoiler:
Also, If anyone wants to give a crack at drawing some sprites for the enemies, I plan on adding pictures to each enemy.
"Imp","Slime","Goblin","Giant Spider","Ghost","Hill Giant","Shade","Medusa","Leviathan","The Greater Demon","The Great Dragon","The Demonic Beast",The Reborn Wrath","Doppelganger","Failure Elemental","Death herself"

They can be from 16x16 -> 60x60. And anywhere in between. I'll obviously credit you in the credits (a better credits page than I currently have on the game)

Also also,
I'll be sitting down and working on making a readme file for the game here soon too. Have to take Superbany's and make it to where it accounts for all the changes in use.
-----------------------
Update:
Newest version is runnable. 0.06 3/18/2012.

***.tns file not uploaded until I can have more time testing stability, next version I'll include the tns***

Basic Item Store added (ring shop and arrow shop coming in next update)
Items can be used in combat now (poison daggers, bombs, molotovs, lamps, etc)
Status effects work on players and enemies alike now
General bug-fixing previous code (removing of loadstring in favor of _G, and many more)


Next 3 on list to finish:
-Finishing bug fixing Item use in combat (some have slipped through)
-Arrow type store and Ring store/implementing Rings
-Re-vamping introduction to game
-----------------------

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: Ti RPG 2 done in Lua (V0.06)
« Reply #72 on: September 06, 2012, 02:50:26 pm »
Heya and welcome to the forums. I hope you enjoy your stay (and calc programming). :D

I unfortunately cannot help you, but I was wondering if you had some screenshots and more information on what the RPG will be about, or if it's still too early for that? Of course for such info you may want to use the projects and ideas section, though.

I would like to see a graphical RPG for the TI-Nspire eventually.

I'm on the case! I am making an RPG for the nspire cx and it's 2p. It's called phil.

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.06)
« Reply #73 on: September 10, 2012, 01:38:41 am »
Wow I remembered this from a long time ago - 6 months ago! Yikes! Looks like Ghezra hasn't been around for a while.
Augs, I wonder how in what way will you make an RPG 2player?
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 Superbany

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
    • Superbany's Games
Re: Ti RPG 2 done in Lua (V0.06)
« Reply #74 on: October 27, 2012, 04:01:49 pm »
I'd really like to see where he's gone with this too. It looks like it was turning out pretty well.

Also, to Ghezra, sorry about any difficulties in converting. I never planned for anyone to try to port it somewhere else, so the code was probably a bit difficult to understand.  ;D But you've done a great job so far!