Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Ghezra on October 23, 2011, 08:51:42 pm

Title: Ti RPG 2 done in Lua (V0.06)
Post by: Ghezra on October 23, 2011, 08:51:42 pm
-----------------------
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
-----------------------

Known bugs: (oh noes!)
-Molotov,lamp, bomb hasn't been tested thoroughly enough


Thank you for your time!

Spoiler For Pictures (3/9/2011):
(http://i39.tinypic.com/iyzc5v.jpg)
(http://i.picasion.com/pic50/2d0fb27e42f0246a58ce4bed1fe6f79d.gif)

Title: Re: RPG for Nspire done in Lua
Post by: DJ Omnimaga on October 23, 2011, 10:02:42 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.
Title: Re: RPG for Nspire done in Lua
Post by: Ghezra on October 23, 2011, 10:22:31 pm
Thank you for the welcome!

I added a screen shot, which pretty much shows everything that's available/working right now.

Before I solidify the storyline, I wanted to iron out some of the logistics on getting some of the mechanics to work; Or, What I am ABLE to do, will dictate what I WILL do. lol in simpler terms.



And as for the placement of this thread, I put it in the Lua Programming section because the biggest thing I need at the moment, is pointers on my current Lua code to see if there are better ways at doing some of the things I am doing. I address most of my concerns/wants in comments through the code itself. But when I get a bit farther in development I'll look to the project section for help. Thanks again!
Title: Re: RPG for Nspire done in Lua
Post by: Jim Bauwens on October 28, 2011, 08:46:27 am
I somehow must have missed this thread, sorry :/

I looked over your code, and the first thing I noticed is that you put platform.window:invalidate() in your timer event, which ticks every .2 seconds. I would try to change this, its a bit rough in my opinion :p

About keyboard input, on.charIn the only way right now to fetch character input.

I haven't tested your code, but I can tell that its nice and clean :)
Good job!

Edit: and I have actually created a RPG in Lua, just never released it.
Title: Re: RPG for Nspire done in Lua
Post by: Adriweb on October 28, 2011, 08:50:12 am
Yep, welcome and congratulations for making an RPG, while it's still in development, it lloks really nice already :)

I haven't had time to look at the code yet, but I'll comment on it as soon as I can :)


NB : Did you use http://www.inspired-lua.org (http://www.inspired-lua.org) or http://wiki.inspired-lua.org (http://wiki.inspired-lua.org) to learn Nspire Lua ?
(Thanks if you did so :P)
Title: Re: RPG for Nspire done in Lua
Post by: DJ Omnimaga on November 01, 2011, 03:20:57 pm
Aaah ok, I hope to see more progress on it soon. I'm curious if you will add some graphics like sprites? It would actually become the first TI-Nspire RPG to have tilemaps actually :D, although I'm not sure if it's really easy to do graphical tilemaps on this calc.
Title: Re: RPG for Nspire done in Lua
Post by: Jim Bauwens on November 01, 2011, 05:04:34 pm
Its very easy, you just have to think a bit how you implement it so that it doesn't run as slow as a snail :)
Title: Re: RPG for Nspire done in Lua
Post by: BalancedFury on November 01, 2011, 05:12:52 pm
Hi!
Is it possible to be played on Nspire CX?
I just got that calc 3 days ago :D
EDIT: Did you introduce your self?
Title: Re: RPG for Nspire done in Lua
Post by: Yeong on November 01, 2011, 07:08:20 pm
Is it possible to be played on Nspire CX?

Lua is only for CX or OS>3 ;)
Title: Re: RPG for Nspire done in Lua
Post by: Levak on November 01, 2011, 07:37:52 pm
Is it possible to be played on Nspire CX?

Lua is only for CX or OS>3 ;)

Optimisation :

Lua is only for OS >= 3
Title: Re: RPG for Nspire done in Lua
Post by: DJ Omnimaga on November 01, 2011, 08:20:10 pm
Its very easy, you just have to think a bit how you implement it so that it doesn't run as slow as a snail :)
Does the screen refresh everytime you display a sprite or is it possible to wait until you displayed everything to refresh the LCD? On the 83+ in ASM and Axe Parser that speeds things up considerably and reduce flickering, for example when a character is moving around.
Title: Re: RPG for Nspire done in Lua
Post by: Jim Bauwens on November 02, 2011, 04:50:40 am
The screen refreshes after you displayed everything. You can also refresh parts of the screen, so that you don't have to redraw everything.
Title: Re: RPG for Nspire done in Lua
Post by: Ghezra on November 06, 2011, 01:53:41 pm


Instead of trying to re-invent the wheel, I talked to Superbany of Ti RPG 2, and I got permission to try to port his game into Lua. This is what I have got so far, I agree that having a timer refresh is dicey at best, so I made it just to where when anything changes from an event it updates.

Although I didn't know until just now you can refresh certain parts of the screen instead of all of it.

I actually DID use the wiki from inspired-lua actually to learn Lua for the Nspire. Its a great website.

Pictures of the latest build here (11/6/2011):
Spoiler For Pictures:
(http://i.picasion.com/pic46/b511cc1749907c94e49fbdb197050a74.gif)

Spoiler For Source Code:
Build 11/06/2011
Code: [Select]
--[[This is a port of TI RPG 2 v2.0 by Superbany
Original code taken from TI RPG 2.tns (10/25/2011)
with permission from Superbany.
Ported into Lua by Ghezra
V0.02b
 =Changed option selection appearance in main menu and races
 +Inventory screen, Spells screen added
 =No longer have timer refresh main game, only mainmenu and intro.
V0.02
 +Added savegame() and loadgame() completely
 +Endie() loaded completely
 +Added Escape Menu for in game saving, loading, quiting
 =Text optimization thus far
V0.01b
 +Added Main Menu graphic
 +Finished converting showequip to equipment()
 +Added Equipment screen fully (e)
V0.01a
 -Removed redundant functions no longer needed in Lua
 +Have character creation working while running on Nspire
 +Have HUD for player stats working
V0.01
 +Copied code into lua]]
function on.timer()
gameTime = gameTime + 1
if gameTime == 20 then
gameTime = 0
end
platform.window:invalidate()
end
function on.arrowUp()
if mainMenu==1 then
if mainChoice>1 then
mainChoice=mainChoice-1
end
end
platform.window:invalidate()
end
function on.arrowDown()
if mainMenu==1 then
if mainChoice<2 then
mainChoice=mainChoice+1
end
end
platform.window:invalidate()
end
function on.arrowRight()
if init==0 then
if initChoice<4 then
initChoice=initChoice+1
end
introduction()
end
platform.window:invalidate()
end
function on.arrowLeft()
if init==0 then
if initChoice>1 then
initChoice=initChoice-1
end
introduction()
end
platform.window:invalidate()
end
function on.charIn(char)
if escMenu==1 then
if char=="s" then
savegame()
escMsg="Game Successfully Saved"
elseif char=="l" then
loadgame()
escMsg="Game Successfully Loaded"
elseif char=="q" then
on.create()
end
else
if char=="e" and showEquip==0 then
equipment()
showEquip=1
else
showEquip=0
end
if char=="i" and showInventory==0 then
showInventory=1
else
showInventory=0
end
if char=="m" and showMagic==0 then
showMagic=1
else
showMagic=0
end
if char=="s" and showStatus==0 then
showStatus=1
else
showStatus=0
end

if place == "world" then
if char == "1" then
place = "forest"
forest()
elseif char == "2" then
place = "town"
town()
elseif char == "3" then
place = "castle"
castle()
end
end


--Testing purposes *everything below line---
if char == "x" then
xp = xp + 1
elseif char == "f" then
endie()
end
--------------------------------------------
end
platform.window:invalidate()
end
function on.enterKey()

if mainMenu == 1 then
if mainChoice == 1 then
introduction()
mainMenu = 0
lineMain = ""
elseif mainChoice == 2 then
savetest = var.recall("savegame1")
if savetest == nil then
lineMain = "Not a valid option at this time."
else
mainMenu = 0
init = 1
loadgame()
world()
end
end
elseif mainMenu == 0 then
if init == 0 then
charCreation()
timer.stop()
end
end
platform.window:invalidate()
end
function on.escapeKey()
if mainMenu == 0 and init == 1 then
showEquip = 0
showInventory = 0
showMagic = 0
showStatus = 0
if escMenu == 0 then
escMsg = ""
escMenu = 1
else
escMenu = 0
end
end
platform.window:invalidate()
end
function on.create()
gameTime = 0
timer.start(1/20)
initChoice = 1
showEquip = 0
mainChoice = 1
race = "Spirit"
mainMenu = 1
init = 0
escMenu = 0
line1 = " "
line2 = " "
line3 = " "
line4 = " "
line5 = " "
line6 = " "
line7 = " "
line8 = " "
line9 = " "
line10 = " "
platform.window:invalidate()
--what else would be good to do as the program initializes?
end
function introduction()

line1 = "Every story has a beginning."
line2 = "Choose the race your character will be."
line3 = "Each race has certain advantages."
line4 = "(use arrow keys, then press enter)"
line6 = "Human  Elf  Halfling  Dwarf"
if initChoice == 1 then
line7 = "High Strength and HP"
elseif initChoice == 2 then
line7 = "High Magic and Speed"
elseif initChoice == 3 then
line7 = "High Speed and Dexterity"
else
line7 = "High Defense and Strength"

end
platform.window:invalidate()

end
function equipment()
--Define strings for current equipment
--Helmet descriptions
if helm == 1 then
curhelm = "Level 1 Leather Cap"
elseif helm == 2 then
curhelm = "Level 2 Iron Guard"
elseif helm == 3 then
curhelm = "Level 3 Mithril Helm"
elseif helm == 4 then
curhelm = "Level 4 Mage Helm"
elseif helm == 5 then
curhelm = "Level 5 3rd Age Helm"
elseif helm == 6 then
curhelm = "Level 6 Ultimate Visage"
elseif helm == 7 then
curhelm = "L3v31 7 L33t H31m"
end
--Armor descriptions
if armor == 1 then
curarmor = "Level 1 Leather Body"
elseif armor == 2 then
curarmor = "Level 2 Iron Mail"
elseif armor == 3 then
curarmor = "Level 3 Mithril Plate"
elseif armor == 4 then
curarmor = "Level 4 Enchanted Armor"
elseif armor == 5 then
curarmor = "Level 5 3rd Age Armor"
elseif armor == 6 then
curarmor = "Level 6 Champion's Plate"
elseif armor == 7 then
curarmor = "L3v31 7 L33t P1@t3"
else
curarmor = "What?"
end
--Sword descriptions
if sword == 1 then
cursword = "Level 1 Bronze Dagger"
elseif sword == 2 then
cursword = "Level 2 Iron Shortsword"
elseif sword == 3 then
cursword = "Level 3 Mithril Longsword"
elseif sword == 4 then
cursword = "Level 4 Godsword"
elseif sword == 5 then
cursword = "Level 5 3rd Age Greatsword"
elseif sword == 6 then
cursword = "Level 6 Great Broadsword"
elseif sword == 7 then
cursword = "L3v31 7 L33t D3s1r0Y3r"
end
--Shield descriptions
if shield == 1 then
curshield = "Level 1 Wooden Guard"
elseif shield == 2 then
curshield = "Level 2 Iron Buckler"
elseif shield == 3 then
curshield = "Level 3 Mithril Square Shield"
elseif shield == 4 then
curshield = "Level 4 Mirror Shield"
elseif shield == 5 then
curshield = "Level 5 3rd Age Heraldic Shield"
elseif shield == 6 then
curshield = "Level 6 Champion's Kiteshield"
elseif shield == 7 then
curshield = "L3v31 7 L33t D3f3?d?r"
end
--Robe descriptions
if robe == 1 then
currobe = "Level 1 Brown Robe"
elseif robe == 2 then
currobe = "Level 2 Grey Robe"
elseif robe == 3 then
currobe = "Level 3 Blue Robe"
elseif robe == 4 then
currobe = "Level 4 White Robe"
elseif robe == 5 then
currobe = "Level 5 Black Robe"
elseif robe == 6 then
currobe = "Level 6 Epic Robe"
elseif robe == 7 then
currobe = "L3v31 7 l33t r0b3"
end
--Shoes descriptions
if shoes == 1 then
curshoes = "Level 1 Leather Shoes"
elseif shoes == 2 then
curshoes = "Level 2 Iron Studded Boots"
elseif shoes == 3 then
curshoes = "Level 3 Mithril Studded Boots"
elseif shoes == 4 then
curshoes = "Level 4 Shoes of Light"
elseif shoes == 5 then
curshoes = "Level 5 3rd Age Runners"
elseif shoes == 6 then
curshoes = "Level 6 Boots of Lightness"
elseif shoes == 7 then
curshoes = "L3v31 7 L33t R?pp3rs"
end
--Ring descriptions
if ring == 0 then
curring = "None"
else
if ringsight == 2 then
curring = "Ring of Sight"
elseif ringfear == 2 then
curring = "Ring of Fear"
elseif ringtrain == 2 then
curring = "Training Ring"
elseif ringwealth == 2 then
curring = "Ring of Wealth"
elseif ringcure == 2 then
curring = "Ring of Curing"
elseif ringhealth == 2 then
curring = "Ring of Health"
elseif ringl33t == 2 then
curring = "L33t R1ng"
end
end
--Bow descriptions
if bow == 1 then
curbow = "None"
elseif bow == 2 then
curbow = "Level 2 Oak Shortbow"
elseif bow == 3 then
curbow = "Level 3 Maple Bow"
elseif bow == 4 then
curbow = "Level 4 Righteous Longbow"
elseif bow == 5 then
curbow = "Level 5 3rd Age Horn Bow"
elseif bow == 6 then
curbow = "Level 6 Champion's Bow"
elseif bow == 7 then
curbow = "L3v31 7 L33t b0W"
end
--Arrow descriptions
if arrowtyp == "normal" then
curarrows = "Normal"
elseif arrowtyp == "fire" then
curarrows = "Fire     "
elseif arrowtyp == "poison" then
curarrows = "Poison "
elseif arrowtyp == "ice" then
curarrows = "Ice      "
elseif arrowtyp == "magic" then
curarrows = "Magic ?"
elseif arrowtyp == "light" then
curarrows = "Light   "
else
curarrows = "L33t    "
end
end
function endie()
--[[This is the function that is called when a monster is beaten
Although will most likely change depending on how combat
is handled in the future.]]
if entyp == 1 then
battleline1 = "You defeated the imp!"
elseif entyp == 2 then
battleline1 = "You defeated the slime!"
elseif entyp == 3 then
battleline1 = "You defeated the goblin!"
elseif entyp == 4 then
battleline1 = "You defeated the giant spider!"
elseif entyp == 5 then
battleline1 = "You defeated the ghost!"
elseif entyp == 6 then
battleline1 = "You defeated the hill giant!"
elseif entyp == 7 then
battleline1 = "You defeated the shade!"
elseif entyp == 8 then
battleline1 = "You defeated the medusa!"
elseif entyp == 9 then
battleline1 = "You defeated the leviathan!"
elseif entyp == 10 then
battleline1 = "You defeated the greater demon!"
boss1 = 1
elseif entyp == 11 then
battleline1 = "You defeated the Great Dragon!"
boss2 = 1
elseif entyp == 12 then
battleline1 = "You defeated the Demonic Beast"
boss3 = 1
elseif entyp == 13 then
battleline1 = "You defeated the doppelganger!"
elseif entyp == 14 then
entyp = 15
enhpmax = 2500
enhp = enhpmax
enmag = 70
enpys = 75
enspeed = 50
enfire = 1
envenom = 0
battleline1 = "You will always encounter Failure"
--call fight function as these bosses string together
elseif entyp == 15 then
entyp = 16
enhpmax = 5000
enhp = enhpmax
enpys = 140
enmag = 100
enspeed = 80
envenom = 1
enfire = 0
battleline1 = "You cannot best Death"
--call fight function as these bosses string together
elseif entyp == 16 then
entyp = 17
enhp = 25000
enhpmax = 25000
enpys = 175
enmag = 150
enspeed = 85
envenom = 0
enfire = 1
battleline1 = "You cannot face the Wrath!"
--call fight function as these bosses string together
elseif entyp == 17 then
battleline1 = "You have defeated the Programmer's Wrath! A WINNER IS YOU!"
boss4 = 1
hpmax = 100
bag = 100
strength = 100 + strboost
defence = 100 + defboost
speed = 100 + speboost
dexterity = 100 + dexboost
intelligence = 100 + intboost
mpmax = 100
--End game with Win!
end

--Testing purposes --
if enxp == nil then

enxp = 5
end
---------------------

local itemdrop = math.random(0,day+20)
if itemdrop < day then
local get = math.random(1,11)
if get == 1 and bomb<bag then
bomb = bomb+1
elseif get == 2 and poisdag < bag then
poisdag = poisdag+1
elseif get == 3 and lamp < bag then
lamp = lamp+1
elseif get == 4 and molotov < bag then
molotov = molotov+1
elseif get == 5 and defpotion < bag then
defpotion = defpotion+1
elseif get == 6 and spepotion < bag then
spepotion = spepotion+1
elseif get == 7 and strpotion < bag then
strpotion = strpotion+1
elseif get == 8 and intpotion < bag then
intpotion = intpotion+1
elseif get == 9 and mppotion < bag then
mppotion = mppotion+1
elseif get == 10 and hppotion < bag then
hppotion = hppotion+1
elseif get == 11 and dexpotion < bag then
dexpotion = dexpotion+1
end
end
gold = gold + math.random(1,round(((enxp*3)/2)))
if ringwealth == 2 or ringl33t == 2 then
gold = gold + math.random(1,enxp)
end
if gold > bag^(2) then
gold = bag^(2)
end
if level < 100 then
xp = xp + enxp
if ringtrain == 2 or ringl33t == 2 then
xp = xp+math.random(1,enxp)
end
end
while xp > level^(2) and level<100 do
points = points + 4
level = level + 1
--Disp "Level Up!"
if level == 5 and skillrun == 0 then
skillrun = 1
--Disp "You learned the skill ""run""!Now you can flee from battle"
end
if level == 10 and skillscan == 0 then
skillscan = 1
--Disp "You learned the skill ""scan""!Now you can scan the enemy's stats"
end
if level == 15 and skillretreat == 0 then
skillretreat = 1
--Disp "You learned the skill ""retreat""!Now you can increase the enemy's distance"
end
if level == 10 then
--Disp "You can now use level 2 Iron equipment!"
elseif level == 20 then
--Disp "You can now use level 3 Mithril equipment!"
elseif level == 30 then
--Disp "You can now use level 4 Holy equipment!"
elseif level == 40 then
--Disp "You can now use level 5 3rd Age equipment!"
elseif level == 50 then
--Disp "You can now use level 6 Champion's equipment!"
elseif level == 100 then
--Disp "--Max Level Reached!--"
xp = 10000
end
end
enburn = 0
enpois = 0
enlife = 0
stun = 0
end
function savegame()
--Current savegame process. Split up because the Nspire losses variables after 14 entries--
local saveGame1 = {race,arrows,arrowtyp,bag,bankgold,bomb,bow,boss1,boss2,boss3,boss4,burn,day,defboost}
local saveGame2 = {defense,defpotion,dexboost,dexpotion,dexterity,distance,enburn,enlife,enpois,game,gold,gotboss1,gotboss2,gotboss3}
local saveGame3 = {gotboss4,helm,herb,hp,hpmax,hppotion,intboost,intelligence,intpotion,lamp,level,molotov,mp,mpmax}
local saveGame4 = {mppotion,orb,points,poisdag,pois,ring,ringcure,ringfear,ringhealth,ringl33t,ringsight,ringtrain,ringwealth,robe}
local saveGame5 = {shield,shoes,skillretreat,skillrun,skillscan,speboost,special,speed,spellbolt,spellheal,spellstat,spellstun,spepotion}
local saveGame6 = {strboost,strength,strpotion,stun,sword,xp,armor}

var.store("savegame1", saveGame1)
var.store("savegame2", saveGame2)
var.store("savegame3", saveGame3)
var.store("savegame4", saveGame4)
var.store("savegame5", saveGame5)
var.store("savegame6", saveGame6)
--Scan is already a table, so its just saved as a table
var.store("savegame7", scan)
end
function loadgame()
gameload1 = var.recall("savegame1")
gameload2 = var.recall("savegame2")
gameload3 = var.recall("savegame3")
gameload4 = var.recall("savegame4")
gameload5 = var.recall("savegame5")
gameload6 = var.recall("savegame6")

if gameload1 == nil then
--Then there is no save game and it displays as such
else
race = gameload1[1]
armor = gameload6[7]
arrows = gameload1[2]
arrowtyp = gameload1[3]
bag = gameload1[4]
bankgold= gameload1[5]
bomb= gameload1[6]
bow= gameload1[7]
boss1= gameload1[8]
boss2= gameload1[9]
boss3= gameload1[10]
boss4= gameload1[11]
burn= gameload1[12]
day= gameload1[13]
defboost= gameload1[14]
defence= gameload2[1]
defpotion= gameload2[2]
dexboost= gameload2[3]
dexpotion= gameload2[4]
dexterity= gameload2[5]
distance= gameload2[6]
enburn= gameload2[7]
enlife= gameload2[8]
enpois= gameload2[9]
game= gameload2[10]
gold= gameload2[11]
gotboss1= gameload2[12]
gotboss2= gameload2[13]
gotboss3= gameload2[14]
gotboss4= gameload3[1]
helm= gameload3[2]
herb= gameload3[3]
hp= gameload3[4]
hpmax= gameload3[5]
hppotion= gameload3[6]
intboost= gameload3[7]
intelligence= gameload3[8]
intpotion= gameload3[9]
lamp= gameload3[10]
level= gameload3[11]
molotov= gameload3[12]
mp= gameload3[13]
mpmax= gameload3[14]
mppotion= gameload4[1]
orb= gameload4[2]
points= gameload4[3]
poisdag= gameload4[4]
pois= gameload4[5]
ring= gameload4[6]
ringcure= gameload4[7]
ringfear= gameload4[8]
ringhealth= gameload4[9]
ringl33t= gameload4[10]
ringsight= gameload4[11]
ringtrain= gameload4[12]
ringwealth= gameload4[13]
robe= gameload4[14]
scan= var.recall("savegame7")
shield= gameload5[1]
shoes= gameload5[2]
skillretreat= gameload5[3]
skillrun= gameload5[4]
skillscan= gameload5[5]
speboost= gameload5[6]
special= gameload5[7]
speed= gameload5[8]
spellbolt= gameload5[9]
spellheal= gameload5[10]
spellstat= gameload5[11]
spellstun= gameload5[12]
spepotion= gameload5[13]
strboost= gameload6[1]
strength= gameload6[2]
strpotion= gameload6[3]
stun= gameload6[4]
sword= gameload6[5]
xp= gameload6[6]
end
end
function world()
line1 = "The forest is close and filled with monsters,"
line2 = "but the Town is behind you circling a hill."
line3 = "On the hill is the Castle, overseeing everything."
line4 = "What would you like to do?"
line5 = "1) Into the forest."
line6 = "2) Enter the town."
line7 = "3) Go to the castle."
place = "world"
end
function charCreation()
--init = 0 for the time the enterkey and arrow keys modify just the race selection
if initChoice == 1 then
race = "Human"

hpmax = 13
mpmax = 5
strength = 2
dexterity = 1
intelligence = 1
defense = 1
speed = 1
points = 1
elseif initChoice == 2 then
race = "Elf"

hpmax = 10
mpmax = 7
strength = 1
dexterity = 1
intelligence = 2
defense = 1
speed = 2
points = 0
elseif initChoice == 3 then
race = "Halfling"

hpmax = 10
mpmax = 5
strength = 1
dexterity = 2
intelligence = 1
defense = 1
speed = 2
points = 3
elseif initChoice == 4 then
race = "Dwarf"

hpmax = 10
mpmax = 5
strength = 2
dexterity = 1
intelligence = 1
defense = 2
speed = 1
points = 1
end
--The rest is applied equally for ALL races
game = 1

hp = hpmax
mp = mpmax
xp = 0
bag = 2
gold = 0
bankgold = 0
level = 1
day = 1

hppotion = 0
mppotion = 0
strboost = 0
strpotion = 0
dexboost = 0
dexpotion = 0
intboost = 0
intpotion = 0
defboost = 0
defpotion = 0
speboost = 0
spepotion = 0
herb = 0

helm = 1
armor = 1
shoes = 1
shield = 1
robe = 1

sword = 1
bomb = 0
molotov = 0
bow = 1
arrows = 0
arrowtyp = "normal"

ring = 0
ringcure = 0
ringfear = 0
ringhealth = 0
ringl33t = 0
ringsight = 0
ringtrain = 0
ringwealth = 0
l33t = 7
lamp = 0
normal = 1
orb = 0

skillretreat = 0
skillrun = 0
skillscan = 0
fire = 2
fear = 9
burn = 0
ice = 4
light = 6
cure = 12
sight = 8
spellbolt = 1
spellheal = 0
spellstat = 0
spellstun = 0
poisdag = 0
pois = 0
poison = 3
stun = 0
train = 10
special = 1

scan = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

distance = 0
enburn = 0
enlife = 0
enpois = 0
boss1 = 0
boss2 = 0
boss3 = 0
boss4 = 0
gotboss1 = 0
gotboss2 = 0
gotboss3 = 0
gotboss4 = 0

init = 1
equipment()
world()
platform.window:invalidate()
end
function on.paint(gc)
--Define the height and width of the screen to be used the rest of on.paint
local h=platform.window:height()
local w=platform.window:width()
--Sets font and color
gc:setFont("sansserif", "b", 10)
gc:setColorRGB(0, 0, 0)
--shm and swm to be used when mainMenu ~= 1
local shm = gc:getStringHeight(line1)
local swm = gc:getStringWidth(line1)

if mainMenu == 1 then
---To draw the Banner into a variable once, and then uses what already was put into memory---
if mainbanner == nil then
imgSRC_Main = "*banner image code here*"
mainbanner = image.new(imgSRC_Main)
end
gc:drawImage(mainbanner, 60, 2)

---Setting up optiong for main menu---
gc:setFont("serif", "b", 10)
gc:setColorRGB(0, 0, 0)
local ng = "New Game"
local mmh = gc:getStringHeight(ng)
local mmw = gc:getStringWidth(ng)
local ngw = (w/2-(gc:getStringWidth(ng))/2)
gc:drawString(ng,ngw, 140)

--This calls to the savegame variable on the TInspire, if empty, then it makes load game italicized.
savetest = var.recall("savegame1")
if savetest == nil then
gc:setFont("serif", "i", 10)
gc:setColorRGB(50,50,50)
gc:drawString("Load Game",ngw, 160)
gc:setColorRGB(0,0,0)
gc:setFont("serif", "b", 10)
else
gc:drawString("Load Game",ngw, 160)
end

--This is the line at the bottom of the Main Menu screen
if lineMain == nil then
lineMain = " " --makes sure the next line has something to print, otherwise error of printing 'nil'
end
gc:drawString(lineMain, w/2-(gc:getStringWidth(lineMain))/2, 190)

--Defines the boxes that go around the choices for the Main Menu
local blah = 0
if mainChoice == 1 then
blah = 124
elseif mainChoice == 2 then
blah = 143
end
gc:drawArc(ngw- 7, blah, mmw+15, mmh+2,gameTime*18,105)
gc:drawArc(ngw- 7, blah, mmw+15, mmh+2,180 + gameTime*18,105)

    elseif mainMenu == 0 and init == 0 then

if initChoice == 1 then
blah = 72
gc:drawArc(blah, 22+4*shm, 50 , shm+2,gameTime*18,105)
gc:drawArc(blah, 22+4*shm, 50 , shm+2,180 + gameTime*18,105)
elseif initChoice == 2 then
blah = 122
gc:drawArc(blah, 22+4*shm, 28 , shm+2,gameTime*18,105)
gc:drawArc(blah, 22+4*shm, 28 , shm+2,180 + gameTime*18,105)
elseif initChoice == 3 then
blah = 149
gc:drawArc(blah, 22+4*shm, 56 , shm+2,gameTime*18,105)
gc:drawArc(blah, 22+4*shm, 56 , shm+2,180 + gameTime*18,105)
else
blah = 210
gc:drawArc(blah, 22+4*shm, 45 , shm+2,gameTime*18,105)
gc:drawArc(blah, 22+4*shm, 45 , shm+2,180 + gameTime*18,105)
end

gc:drawString(line1, (w-swm)/2 , 20)
gc:drawString(line2, (w-gc:getStringWidth(line2))/2, 20+shm)
gc:drawString(line3, (w-gc:getStringWidth(line3))/2, 20+2*shm)
gc:drawString(line4, (w-gc:getStringWidth(line4))/2, 20+3*shm)
gc:drawString(line5, (w-gc:getStringWidth(line5))/2, 20+4*shm)
gc:drawString(line6, (w-gc:getStringWidth(line6))/2, 20+5*shm)
gc:drawString(line7, (w-gc:getStringWidth(line7))/2, 20+6*shm)
gc:drawString(line8, (w-gc:getStringWidth(line8))/2, 20+7*shm)
gc:drawString(line9, (w-gc:getStringWidth(line9))/2, 20+8*shm)
gc:drawString(line10, (w-gc:getStringWidth(line10))/2, 20+9*shm)


else
gc:setFont("sansserif", "r", 9)
gc:setColorRGB(0, 0, 0)

--Setting up General layout of text
gc:drawString(line1, (w-62)/2-(gc:getStringWidth(line1))/2, 20)
gc:drawString(line2, (w-62)/2-(gc:getStringWidth(line2))/2, 20+shm)
gc:drawString(line3, (w-62)/2-(gc:getStringWidth(line3))/2, 20+2*shm)
gc:drawString(line4, (w-62)/2-(gc:getStringWidth(line4))/2, 20+3*shm)
gc:drawString(line5, (w-62)/2-(gc:getStringWidth(line5))/2, 20+4*shm)
gc:drawString(line6, (w-62)/2-(gc:getStringWidth(line6))/2, 20+5*shm)
gc:drawString(line7, (w-62)/2-(gc:getStringWidth(line7))/2, 20+6*shm)
gc:drawString(line8, (w-62)/2-(gc:getStringWidth(line8))/2, 20+7*shm)
gc:drawString(line9, (w-62)/2-(gc:getStringWidth(line9))/2, 20+8*shm)
gc:drawString(line10, (w-62)/2-(gc:getStringWidth(line10))/2, 20+9*shm)

gc:drawString("Days left - "..(100-day), (w-62)/2-(gc:getStringWidth("Days left - ##"))/2, 20+10*shm)

--[[ Placeholder for
if place == "world" then
if img == nil then
imgSRC = " *image source here* "
img = image.new(imgSRC)
end
gc:drawImage(img, 115, 80)
--end
]]

--setting up general layout of Stats, only after stats have been determined
gc:setFont("sansserif", "b", 8)
gc:setColorRGB(0, 0, 0)
local shs = gc:getStringHeight("HP")
local swrace = gc:getStringWidth(race)
gc:drawString(race, (w-32-round(swrace/2)), 20)
gc:drawString("HP  ", w-60, 20+shs)
gc:drawString("MP ", w-60, 20+2*shs)
gc:drawString("LVL ", w-60, 20+3*shs)
gc:drawString("STR ", w-60, 20+4*shs)
gc:drawString("DEX ", w-60, 20+5*shs)
gc:drawString("INT ", w-60, 20+6*shs)
gc:drawString("XP  ", w-60, 20+7*shs)
gc:drawString("Gold", w-60, 20+8*shs)
gc:drawString(hp.."/"..hpmax, w-35, 20+shs)
gc:drawString(mp.."/"..mpmax, w-35, 20+2*shs)
gc:drawString(level, w-35, 20+3*shs)
gc:drawString(strength, w-35, 20+4*shs)
gc:drawString(dexterity, w-35, 20+5*shs)
gc:drawString(intelligence, w-35, 20+6*shs)
local xplength = gc:getStringWidth(xp.."/"..(level^(2)+1))
gc:drawString(xp.."/"..(level^(2)+1), (w-24)-round(xplength/2), 20+7*shs)
gc:drawString(gold, w-35, 20+8*shs)
gc:drawRect(w-62, 20-shs, 60, 9*shs+5)
gc:drawString("E-Equip", w-60, 20+10*shs)
gc:drawString("I-Inventory", w-60, 20+11*shs)
gc:drawString("M-Magic", w-60, 20+12*shs)
gc:drawString("S-Status", w-60, 20+13*shs)

if escMenu == 1 then
gc:fillRect(w/2-100, h/2-75, 200, 150)
gc:setColorRGB(220,220,220)
gc:fillRect(w/2-98, h/2-73, 196, 146)
gc:setColorRGB(0,0,0)
local she = gc:getStringHeight("Test")
if escMsg == nil then
escMsg = ""
end
gc:setFont("serif", "b", 12)

gc:drawString("Game Menu", w/2-(gc:getStringWidth("Equipment"))/2,h/2-70+she)
gc:setFont("sansserif", "b", 8)
gc:drawString(escMsg, w/2-85, h/2-70+she*2)
gc:drawString("Press ESC again to resume game", w/2-85, h/2-70+she*3)
gc:drawString("S - Save Game", w/2-85, h/2-70+she*5)
gc:drawString("L - Load Game", w/2-85, h/2-70+she*7)
gc:drawString("Q - Quit to Main Menu", w/2-85, h/2-70+she*9)
end
if showEquip == 1 then
equipment()
gc:fillRect(w/2-100, h/2-75, 200, 150)
gc:setColorRGB(220,220,220)
gc:fillRect(w/2-98, h/2-73, 196, 146)
gc:setColorRGB(0,0,0)
local she = gc:getStringHeight("Test")

gc:setFont("serif", "b", 12)

gc:drawString("Equipment", w/2-(gc:getStringWidth("Equipment"))/2,h/2-70+she)
gc:setFont("sansserif", "b", 8)

gc:drawString("Sword", w/2-85, h/2-70+she*2)
gc:drawString("Shield", w/2-85, h/2-70+she*3)
gc:drawString("Helmet", w/2-85, h/2-70+she*4)
gc:drawString("Armor", w/2-85, h/2-70+she*5)
gc:drawString("Shoes", w/2-85, h/2-70+she*6)
gc:drawString("Robe", w/2-85, h/2-70+she*7)
gc:drawString("Ring", w/2-85, h/2-70+she*8)
gc:drawString("Bow", w/2-85, h/2-70+she*9)
gc:drawString("Arrows", w/2-85, h/2-70+she*10)

local swe = gc:getStringWidth("Helmet")
gc:drawString("- "..cursword, w/2-85 + swe, h/2-70+she*2)
gc:drawString("- "..curshield, w/2-85+swe, h/2-70+she*3)
gc:drawString("- "..curhelm, w/2-85+swe, h/2-70+she*4)
gc:drawString("- "..curarmor, w/2-85+swe, h/2-70+she*5)
gc:drawString("- "..curshoes, w/2-85+swe, h/2-70+she*6)
gc:drawString("- "..currobe, w/2-85+swe, h/2-70+she*7)
gc:drawString("- "..curring, w/2-85+swe, h/2-70+she*8)
gc:drawString("- "..curbow, w/2-85+swe, h/2-70+she*9)
gc:drawString("- "..curarrows, w/2-85+swe, h/2-70+she*10)
end
if showInventory == 1 then
gc:fillRect(w/2-100, h/2-75, 200, 150)
gc:setColorRGB(220,220,220)
gc:fillRect(w/2-98, h/2-73, 196, 146)
gc:setColorRGB(0,0,0)
local shi = gc:getStringHeight("L")
local swi = gc:getStringWidth("Intelligence")
gc:setFont("serif", "b", 12)

gc:drawString("Inventory", w/2-(gc:getStringWidth("Inventory"))/2,h/2-70+shi)
gc:setFont("sansserif", "b", 10)
gc:drawString("Items:", w/2-85, h/2-70+shi*2)
gc:setFont("sansserif", "b", 8)
gc:drawString("Lamps", w/2-85, h/2-70+shi*3)
gc:drawString("Molotovs", w/2-85, h/2-70+shi*4)
gc:drawString("Herbs", w/2-85, h/2-70+shi*5)
gc:drawString("Bombs", w/2-85, h/2-70+shi*6)
gc:drawString("Daggers", w/2-85, h/2-70+shi*7)
gc:drawString("Life Orbs", w/2-85, h/2-70+shi*8)

gc:setFont("serif", "b", 10)
gc:drawString("Potions:", w/2-85 + 2*swi, h/2-70+shi*2)
gc:setFont("sansserif", "b", 8)
gc:drawString("HP", w/2-85 + 2*swi, h/2-70+shi*3)
gc:drawString("MP", w/2-85 + 2*swi, h/2-70+shi*4)
gc:drawString("Strength", w/2-85 + 2*swi, h/2-70+shi*5)
gc:drawString("Dexterity", w/2-85 + 2*swi, h/2-70+shi*6)
gc:drawString("Intelligence", w/2-85 + 2*swi, h/2-70+shi*7)
gc:drawString("Defense", w/2-85 + 2*swi, h/2-70+shi*8)
gc:drawString("Speed", w/2-85 + 2*swi,h/2-70+shi*9)

gc:drawString("- "..lamp, w/2-85 + swi, h/2-70+shi*3)
gc:drawString("- "..molotov, w/2-85+swi, h/2-70+shi*4)
gc:drawString("- "..herb, w/2-85+swi, h/2-70+shi*5)
gc:drawString("- "..bomb,w/2-85+swi, h/2-70+shi*6)
gc:drawString("- "..poisdag, w/2-85+swi, h/2-70+shi*7)
gc:drawString("- "..orb, w/2-85+swi, h/2-70+shi*8)

gc:drawString("- "..hppotion, w/2-85 + 3*swi, h/2-70+shi*3)
gc:drawString("- "..mppotion, w/2-85+3*swi, h/2-70+shi*4)
gc:drawString("- "..strpotion, w/2-85+3*swi, h/2-70+shi*5)
gc:drawString("- "..dexpotion, w/2-85+3*swi, h/2-70+shi*6)
gc:drawString("- "..intpotion, w/2-85+3*swi, h/2-70+shi*7)
gc:drawString("- "..defpotion, w/2-85+3*swi, h/2-70+shi*8)
gc:drawString("- "..spepotion, w/2-85+3*swi, h/2-70+shi*9)
end
if showMagic == 1 then
gc:fillRect(w/2-100, h/2-75, 200, 150)
gc:setColorRGB(220,220,220)
gc:fillRect(w/2-98, h/2-73, 196, 146)
gc:setColorRGB(0,0,0)
local shsp = gc:getStringHeight("L")
local swsp = gc:getStringWidth("Magic Spells")

gc:setFont("serif", "b", 12)
gc:drawString("Magic Spells", w/2-(swsp)/2-15,h/2-70+shsp)

gc:setFont("sansserif", "b", 8)
gc:drawString("Intelligence: "..intelligence, w/2-85, h/2-70+shsp*2)
gc:drawString("Mana Power: "..mp.."/"..mpmax, w/2-85, h/2-70+shsp*3)
gc:drawString("Bolt Level "..spellbolt, w/2-85, h/2-70+shsp*5)
if spellheal == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*6)
else
gc:drawString("Heal Level "..spellheal, w/2-85, h/2-70+shsp*6)
end
if spellstat == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*7)
else
gc:drawString("Boost Level "..spellstat, w/2-85, h/2-70+shsp*7)
end
if spellstun == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*8)
else
gc:drawString("Stun Level "..spellstun, w/2-85, h/2-70+shsp*8)
end
end
if showStatus == 1 then

gc:fillRect(w/2-100, h/2-75, 200, 150)
gc:setColorRGB(220,220,220)
gc:fillRect(w/2-98, h/2-73, 196, 146)
gc:setColorRGB(0,0,0)
local shsp = gc:getStringHeight("L")
local swsp = gc:getStringWidth("Intelligence")

gc:setFont("serif", "b", 12)
gc:drawString("Spells", w/2-(swsp)/2,h/2-70+shsp)

gc:setFont("sansserif", "b", 8)
gc:drawString("Intelligence: "..intelligence, w/2-85, h/2-70+shsp*2)
gc:drawString("Mana Power: "..mp.."/"..mpmax, w/2-85, h/2-70+shsp*3)
gc:drawString("Bolt Level "..spellbolt, w/2-85, h/2-70+shsp*5)
if spellheal == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*6)
else
gc:drawString("Heal Level "..spellheal, w/2-85, h/2-70+shsp*6)
end
if spellstat == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*7)
else
gc:drawString("Boost Level "..spellstat, w/2-85, h/2-70+shsp*7)
end
if spellstun == 0 then
gc:drawString("-------", w/2-85, h/2-70+shsp*8)
else
gc:drawString("Stun Level "..spellstun, w/2-85, h/2-70+shsp*8)
end



end
end
end
function round(num, idp)
  local mult=10^(idp or 0)
  return math.floor(num*mult+0.5)/mult
end
function town()
line1 = "The town is bustling with people."
line2 = "There is a item shop to the left,"
line3 = "and a equipment store to the right."
line4 = "Townspeople are huddled in many"
line5 = "groups conversing."
line6 = "What would you like to do?"
line7 = "1) visit Item Shop"
line8 = "2) visit Equipment Store"
line9 = "3) Talk to random townspeople"
end
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Chockosta on November 06, 2011, 02:09:55 pm
Really impressive !
Maybe that you should add images...
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on November 06, 2011, 02:21:00 pm
Really impressive !
Maybe that you should add images...

Thanks! Images are in the works, As well as maybe some animated sprites but slowly animated so it doesn't kill the nspire.

Although the posted code doesn't reflect it, I also JUST finished changing the platform.window:invalidate's so they only refresh the parts of the screen that have changing attributes. I haven't really seen THAT much of a speed change compared to before, but as the program gets larger with more images I can imagine it being a bigger deal.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: DJ Omnimaga on November 06, 2011, 02:22:37 pm
Looking good so far. I'm glad it's possible to only refresh parts of the screen. Should be faster. In TI-83+ BASIC when you draw something, it refreshes everything, which can be incredibly slow at times.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on November 06, 2011, 02:36:21 pm
Yeah DJ, originally in the Main Menu it refreshed the screen ever 1/10th of a second, and it used to recompile the image over and over.

Then I made it to where it only loads the image once when the image variable is still nil,

Then I made it to where it only redraws below the image entirely.

Its a rough process of optimization :)
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: DJ Omnimaga on November 06, 2011, 02:54:19 pm
Cool to hear.

Also question: Is it your first Nspire project ever? If so, for now I would avoid venturing into scrolling yet and focus on the basics of the engine. It's best to start smaller then add more feature once you feel ready to. Also note that scrolling, unless the Nspire has actual scrolling commands, might slow things down.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on November 06, 2011, 04:35:33 pm
Considering I dont even know what you mean by scrolling, I'll just take your word for it. And Yes this is my first Nspire project. Which is also why I'm completely open for any and all opinions/recommendations about the code
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: DJ Omnimaga on November 19, 2011, 02:17:59 pm
Oh I meant when your character is walking around, but on the screen what you see moving around is the trees, buildings, roads, etc, instead of just your character. That's scrolling. Another example of scrolling is the text in movie credits that moves up.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Jonius7 on November 24, 2011, 02:49:11 pm
This is great, TI RPG is one of the best TI-nspire Basic games made and it's good to see it being ported to Lua.
Eventually you could make a graphical RPG
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on March 04, 2012, 02:31:06 am
So, I've been hard at work porting all the code to Lua.

I get to a semi-stopping point, and pasted the code into the student software (after using the TI scripting tools) And when I past into a new page, it completely crashes the student software dead.

I even tried just commenting out the entire code and pasting it and it crashes. I loaded up an earlier version of the code and it pastes fine. So something I added since the last version is crashing the software even if its commented out.


If someone can glance through the code and find something that is likely the culprit, please let me know. I have some suspicions and I'm working on it, but I added hundreds of lines of code and restructured the entire source code since I last checked it on the Nspire software. Brother.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: DJ Omnimaga on March 04, 2012, 02:33:09 am
Well the student software is unfortunately not very reliable for testing. A lot of Lua games do not run correctly in it. You would have to test on-calc.

I guess you can post the code here too, though, in case people can help. Preferably in the Lua programming sub-forum, though.

Nice to see you again btw!
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Jim Bauwens on March 04, 2012, 02:57:20 am
Yup, post your code like DJ_O said, and I (and others) will take a look at it.
You could try using nspire_emu too, since it runs the hand held OS.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on March 04, 2012, 03:01:48 am
I AM in the lua subforum?

Also, I posted the code in the main post. (its where I keep updating the code)

also also, I figured it out.

In the original TIRPG, he used UTF-8 symbols, and lua doesn't support them, so it immediately crashed.

I'll be updating the code in the original thread to be working for your testing pleasure.

Alsox3, Thank you for the prompt replies!
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: DJ Omnimaga on March 04, 2012, 03:04:36 am
Oh wait yeah the topic is in the Lua section. If I remember it used to be under project, though. I probably forgot it was moved around a while ago.

And glad you figured out the problem. :)
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra on March 04, 2012, 03:56:12 am
Now that I have the next week off and can just solely work on this project. I'll have a completely functioning RPG here probably by monday night to then begin tweaks and GUI customizations. There isn't much code thats left to be ported from the NspireBASIC code. When I have it to where combat at least works, I'll post the .tns file itself as I hit each version so I can also get some feedback on what works and what doesnt.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: cyanophycean314 on March 04, 2012, 09:50:51 pm
Nice job! Just saw this thread today. Looks great and can't wait to see more come out of this project! :D
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Jonius7 on March 05, 2012, 04:30:15 am
That looks like great progress you've made recently. Don't forget credits to Superbany, who created the original game.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: hellninjas on March 05, 2012, 12:06:19 pm
I love it :D
Really keeps me busy in SRT :)
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra 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.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: cyanophycean314 on March 05, 2012, 07:38:54 pm
You'll find that right here: http://www.inspired-lua.org/2011/12/how-to-have-a-nice-little-input-function-in-lua/ (http://www.inspired-lua.org/2011/12/how-to-have-a-nice-little-input-function-in-lua/)
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra 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
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: cyanophycean314 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.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Ghezra 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:
(http://i42.tinypic.com/2lsdz7d.jpg)
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Jonius7 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.
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Levak 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
Title: Re: Ti RPG 2 for the Nspire done in Lua
Post by: Jonius7 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.
Title: Re: Ti RPG 2 done in Lua (V0.04)
Post by: Ghezra 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!
Title: Re: Ti RPG 2 done in Lua (V0.04)
Post by: cyanophycean314 on March 06, 2012, 07:52:28 pm
Oh yeah... That is good way, forgot about alphabetical comparison of strings. :P
Title: Re: Ti RPG 2 done in Lua (V0.04)
Post by: Jonius7 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.
Title: Re: Ti RPG 2 done in Lua (V0.04)
Post by: Ghezra 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.
Title: Re: Ti RPG 2 done in Lua (V0.04)
Post by: Ghezra 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
Title: Re: Ti RPG 2 done in Lua (V0.04a)
Post by: someone 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
    ...
Title: Re: Ti RPG 2 done in Lua (V0.04a)
Post by: Ghezra 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!
Title: Re: Ti RPG 2 done in Lua (V0.04a)
Post by: Ghezra on March 07, 2012, 06:41:30 pm
Question on loadstring.. So its a function that runs a string as if it were an instruction line.. but I can't seem to get it to work right.

Here is a simple example of what I have:

This is what I think it should do, potpt("mp", "mpmax", "mppotion"), then goes into the potpt function,
the first loadstring should be

loadstring(potstr.." = "..potstr.." - 1")()

which string wise would be

loadstring("mppotion = mppotion - 1")()

so it should run the line:

mppotion = mppotion - 1

But it doesn't. Where am I going wrong with my use of loadstring? Any suggestions?

Code: [Select]
...
     potpt("mp", "mpmax", "mppotion")
...

function potpt(statstr,statmaxstr,potstr)
boostamt = 0
loadstring(potstr.."="..potstr.."-1")()
boostamt = math.random(1,dexterity)
loadstring(statstr.."="..statstr.."+boostamt")()
if loadstring("if "..statstr..">"..statmaxstr.." then return true")() then
loadstring(statstr.."="..statmaxstr)()
end
combatLine1 = "You drink an "..statstr.." potion... +"..boostamt.." "..statstr.."."
end
Title: Re: Ti RPG 2 done in Lua (V0.04a)
Post by: cyanophycean314 on March 07, 2012, 08:09:56 pm
Hmm. Never heard of loadString, but it sounds really nice. Will research.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Ghezra on March 08, 2012, 12:09:18 am
Potions completed, I just bypassed the use of 'loadstring' altogether even though it kept the code cleaner. If it don't work I can't use it! lol

Also added in a smattering of color (only three things) But for those of you with the CX's, it will be slightly cooler looking.

*Edit: PS: New source and TNS file put on main post, as always.


(http://i39.tinypic.com/iyzc5v.jpg)
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Jonius7 on March 08, 2012, 02:07:20 am
Great suggestion id have 2 say, someone!
@gherza it's good 2 see you respond so quickly and that you're making it look good in all colours!
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Jim Bauwens on March 08, 2012, 03:11:21 am
About the number case on the previous page, you can also do
if tonumber(char) then
  your code
end
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Jonius7 on March 08, 2012, 07:45:06 am
Good to see the source code attached as a .lua file. It was a bit of a hassle trying to copy the text from the code box as somehow pressing copy to clipboard didn't work and I had to select all, copy and paste it to view it manually.
And also yay! Health bars in the right sidebar makes it much better and more consistent.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Ghezra on March 08, 2012, 11:41:44 am
I added the ability to Run and to scan the enemy.

But some minor/major bugs cropped up so I'm going to wait till tonight to squash them a little bit before releasing a new version. I know the game won't be entirely playable until equipment/items get sorted. But as it stands right now Superbany programmed the equipment store in such a way that its almost entirely unusable in Lua. So I'll be redesigning it from scratch like I did with the level up screen.

I'll keep working on it everyday and make it better and better.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: someone on March 08, 2012, 01:49:52 pm
I see that you mention that the calculator has problems when you try to store +14 variable entries. I would suggest you sort the variables that belongs on the same category & store them together & don't group them like you currently do (though I guess is fine right now as to keep them in control)

BTW, you can also use arrays there. This is how the function savegame() could look
Code: [Select]
--------------------------------------------------------------------------------
function savegame()
--------------------------------------------------------------------------------
    --Current savegame process. Split up because the Nspire losses variables after 14 entries--
    local game_save = {}
    game_save[1] = {race,arrows,arrowtyp,bag,bankgold,bomb,bow,boss1,boss2,boss3,boss4,burn,day,defboost}
    game_save[2] = {defense,potion_def,dexboost,potion_dex,dexterity,distance,enburn,enlife,enpois,game,gold,gotboss1,gotboss2,gotboss3}
    game_save[3] = {gotboss4,helm,herb,hp,hpmax,potion_hp,intboost,intelligence,potion_int,lamp,level,molotov,mp,mpmax}
    game_save[4] = {potion_mp,orb,points,poisdag,pois,ring,ringcure,ringfear,ringhealth,ringl33t,ringsight,ringtrain,ringwealth,robe}
    game_save[5] = {shield,shoes,skillretreat,skillrun,skillscan,speboost,special,speed,spellbolt,spellheal,spellstat,spellstun,potion_spe}
    game_save[6] = {strboost,strength,potion_str,stun,sword,xp,armor}

    for i=1, 6 do
        var.store("save.game" .. i, game_save[i])
    end

    --Scan is already a table, so its just saved as a table
    var.store("save.game7", scan)
end

Note that I changed "savegame#" to "save.game#". These are called group variables, is just to keep similar variable together in a group called "save"
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Jim Bauwens on March 08, 2012, 02:07:17 pm
You can also save progress by returning a table in on.save().
The nspire will then give it as argument to on.restore when you open the program next time.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Ghezra on March 08, 2012, 02:38:14 pm
I made the array changes to the save and load functions. It all works without any problems.

As far as grouping goes.. I never thought to group the save because well, The only reason I need them grouped at all is just so they save correctly in groups of 14. The grouping they exhibit is never functionally used at all. So I think I'll leave them grouped as such as it doesn't particularly matter.

What I did notice however is how you have variables 'group' grouped.
ie: potion_hp potion_mp potion_dex potion_int etc etc
Why use _ instead of . here? Which is the better syntax wise? I'm all for changing. I'm going back now to see about doing the strings in arrays for the displays.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Adriweb on March 08, 2012, 02:47:17 pm
_ is indicating just a variable name (hello_world) is a variable,
hello.world is like : hello is a table and world an object of this table.
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Ghezra on March 08, 2012, 02:59:12 pm
Ahh thanks for the clarification. Also so far the arrays of strings are working nicely. Compacting code a bit. As can be seen by the new combatLineCycle()

I also am making everything agree with that naming convention. (which is pretty easy with "find 'dexpotion, replace all with 'potion_dex' lol)

Code: [Select]
function combatLineCycle()
for i=1,7 do
combatLine[9-i] = combatLine[8-i]
end
end
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Adriweb on March 08, 2012, 03:01:58 pm
Also, Ghezra, read this :

http://www.inspired-lua.org/2011/08/save-a-high-score-without-cheating-possibility/ (http://www.inspired-lua.org/2011/08/save-a-high-score-without-cheating-possibility/)

:D
Title: Re: Ti RPG 2 done in Lua (V0.04b)
Post by: Ghezra on March 08, 2012, 04:02:35 pm
Jim, don't think I didn't see what you said. It was great!! Now the save game is completely nested inside the Lua so no chance of cheating!! Great ideas everyone! This is so helpful, lol


EDIT: Adri! You snuck in right as I posted! Thanks for showing me that, Jim had mentioned it before, it was THAT website actually that I used as a guide for how I changed my code.

Code: [Select]
function on.save()
game_save = {}
game_save[1] = {race,arrows,arrowtyp,bag,bankgold,bomb,bow,boss1,boss2,boss3,boss4,burn,day,boost_def}
game_save[2] = {defense,potion_def,boost_dex,potion_dex,dexterity,distance,en_burn,en_life,en_pois,game,gold,gotboss1,gotboss2,gotboss3}
game_save[3] = {gotboss4,helm,herb,hp,hpmax,potion_hp,boost_int,intelligence,potion_int,lamp,level,molotov,mp,mpmax}
game_save[4] = {potion_mp,orb,points,poisdag,pois,ring,ring_cure,ring_fear,ring_health,ring_l33t,ring_sight,ring_train,ring_wealth,robe}
game_save[5] = {shield,shoes,skill_retreat,skill_run,skill_scan,boost_spe,special,speed,spell_bolt,spell_heal,spell_stat,spell_stun,potion_spe}
game_save[6] = {boost_str,strength,potion_str,stun,sword,xp,armor}
game_save[7] = scan
return game_save
end
function on.restore(save)

local game_load1 = save[1]
local game_load2 = save[2]
local game_load3 = save[3]
local game_load4 = save[4]
local game_load5 = save[5]
local game_load6 = save[6]

if game_load1 == nil then
--Then there is no save game and it displays as such
else
race = game_load1[1]
armor = game_load6[7]
arrows = game_load1[2]
...etc..
end
end
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: Ghezra on March 08, 2012, 05:47:14 pm
**And having been working on this relatively constant for the last 4-5 days, I'm going to take a day long breather. Step back from the code a bit. Keep the great suggestions coming!**


-----------------------
Update:
Newest version is runnable. 0.04c 3/8/2012.

Combat options like Run, Retreat, Scan now work as intended
But you'll have to wait until you get them through leveling up.
Run - lvl 5
Scan - lvl 10
Retreat - lvl 15
Huge revisions to the lua code, namely the Save and load games and incorporation of string arrays.


Next 3 on list to finish:
-Code modification/clarity
-Item store
-Armor store
-----------------------
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: Jonius7 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.
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: cyanophycean314 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!
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: someone 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 (http://lua-users.org/wiki/SwitchStatement), 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() (http://wiki.inspired-lua.org/on.resize) if you feel the screen size could change.
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: Jim Bauwens 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.
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: Ghezra 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!
Title: Re: Ti RPG 2 done in Lua (V0.04c)
Post by: Ghezra 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 :)


(http://i.picasion.com/pic50/2d0fb27e42f0246a58ce4bed1fe6f79d.gif) (http://picasion.com/)
Title: Re: Ti RPG 2 done in Lua (V0.04d)
Post by: Ghezra 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.
Title: Re: Ti RPG 2 done in Lua (V0.04d)
Post by: Ghezra 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.
Title: Re: Ti RPG 2 done in Lua (V0.05)
Post by: Ghezra 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
...
Title: Re: Ti RPG 2 done in Lua (V0.05)
Post by: Jonius7 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. ;)
Title: Re: Ti RPG 2 done in Lua (V0.05)
Post by: Jim Bauwens 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 :)
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Ghezra 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
-----------------------
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Augs 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.
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Jonius7 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?
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Superbany 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!
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: ElementCoder on October 28, 2012, 07:28:39 am
Superbany :D welcome to omni! you should http://www.omnimaga.org/index.php?board=10.0 (http://introduce yourself) and grab a bag of peanuts :P
Any plans on a TI RPG 3? ;)

On topic:
I really would be a shame if this project would die Ghezra we need you D:

P.S. Here are some peanus already
!peanuts
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: DJ Omnimaga on October 28, 2012, 07:30:15 am
Heya Superbany welcome to the forums. :D And yeah I wonder how this has been progressing. By the way Superbany do you plan any Lua development in the future?
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Superbany on October 28, 2012, 06:50:06 pm
TI RPG 3? Well that would be an interesting idea. I still would love to continue improvements on 2, doing stuff along the lines of the current upcoming update, but I may sometime go and make big enough changes to deserve a new game. And yes, I too would really love to see this conversion in its entirety. I really enjoy seeing all the things that would just not be possible with the Basic framework. I've done what I can with it, but in the end, its not exactly designed for programming games.

And no, probably not any time soon. That would require learning Lua, and I'm backed up as it is with Ti RPG 2, the flash game I'm working on, and Source Filmmaker, not to mention college applications.  :-\ But once all these things settle down, I certainly wouldn't consider it an impossibility.  ;)
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: ElementCoder on November 15, 2012, 04:00:27 am
So how are things going with porting this? Haven't seen a lot of activity lately :(
Title: Re: Ti RPG 2 done in Lua (V0.06)
Post by: Jonius7 on November 18, 2012, 06:08:33 pm
It was mainly Ghezra porting this. I haven't seen him active for months.
His last login was
Last Login: 09 June, 2012

I wonder if someone else can resume where Ghezra left off?