RPG project

Show off your games, demos and other (playable) creations.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: RPG project + random programming questions

Post by Tesselode »

OK, I'm not sure if I'll need this now, but for future reference, is there any way to refer to a variable using a string?
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: RPG project + random programming questions

Post by josefnpat »

Tesselode wrote:OK, I'm not sure if I'll need this now, but for future reference, is there any way to refer to a variable using a string?
I'm interested in this question too, but also for functions.

I've been getting around this issue by pushing stuff into tables.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: RPG project + random programming questions

Post by bartbes »

_G is the global table. This won't work for locals, but otherwise it should do the trick.

Code: Select all

cake = false
have_cake = "cake"
_G[have_cake] = true
if cake and have_cake then
    print("Still have the cake, and ate it too.")
end
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: RPG project + random programming questions

Post by miko »

bartbes wrote:_G is the global table. This won't work for locals, but otherwise it should do the trick.
For locals, debug.getlocal() or debug.getenv() would work. But usually this is not necessary if you use OO approach, or at least a table for you object:

Code: Select all

player={name="John", age=20}
variable="name"
print(player[variable])
-- OO style:
player=Player.new("John", 20)
function player:onHello()
  local parameter="name"
  print("Hello, my name is "..self[parameter])
end
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: RPG project + random programming questions

Post by Robin »

miko wrote:For locals, debug.getlocal() or debug.getenv() would work.
Please don't use debugging functions in games you want to publish, because SELÖVE forbids it, because it breaks the sandbox.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: RPG project + random programming questions

Post by bartbes »

And because the lua devs say so themselves, the debug library is not to be used in production code unless unavoidable.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: RPG project + random programming questions

Post by Tesselode »

Here's a little preliminary demo of the battle system. The enemy attacks every 5 seconds; try to avoid it by jumping by pressing space.
Attachments
battle demo.love
(12 KiB) Downloaded 146 times
User avatar
SoggyWaffles
Citizen
Posts: 72
Joined: Sun Jan 02, 2011 3:27 am
Location: Wyoming, USA

Re: RPG project + random programming questions

Post by SoggyWaffles »

Fun. I've always hated RPG where you just sit there and pick things for the characters to do (isn't that most of them?) and then watch them get killed and can't do anything about it. I'm always like "Its a stupid level 1 slime blob! Just walk away! DAMNIT! DODGE IT! sigh..." and my character dies cause he was too stupid dodge a slime blob. BUT my character CAN dodge a slime blob. THANK YOU Tesselode! :P
"Beneath the clouds lives the Earth-Mother from whom is derived the Water of Life, who at her bosom feeds plants, animals and men." ~Larousse
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: RPG project + random programming questions

Post by Jasoco »

Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: RPG project + random programming questions

Post by Kadoba »

Jasoco wrote:Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
Death to the heretic!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest