Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ghezra

Pages: 1 [2]
16
Lua / Re: Ti RPG 2 done in Lua (V0.04)
« 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.

17
Lua / Re: Ti RPG 2 done in Lua (V0.04)
« 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!

18
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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:


19
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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

20
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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.

21
Lua / Re: Getting started with Lua on Nspire
« on: March 04, 2012, 12:17:13 pm »
At certain times I had large imgSRCs loading on the screen, what I found is that you can cut down the time it takes to refresh the screen dramatically if you have it to where it draws the image, and then only refresh sections of the screen that are changing with the functions.

Check out http://wiki.inspired-lua.org/platform.window:invalidate

22
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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.

23
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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!

24
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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.

25
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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

26
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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 :)

27
Lua / Re: Ti RPG 2 for the Nspire done in Lua
« 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.

28
Lua / Re: RPG for Nspire done in Lua
« 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:


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

29
Lua / Re: RPG for Nspire done in Lua
« 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!

30
Lua / Ti RPG 2 done in Lua (V0.06)
« 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):




Pages: 1 [2]