Page 2 of 4
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 3:53 am
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?
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 6:25 am
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.
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 7:03 am
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
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 9:22 am
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
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 3:47 pm
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.
Re: RPG project + random programming questions
Posted: Mon Nov 28, 2011 6:21 pm
by bartbes
And because the lua devs say so themselves, the debug library is not to be used in production code unless unavoidable.
Re: RPG project + random programming questions
Posted: Mon Dec 05, 2011 1:32 am
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.
Re: RPG project + random programming questions
Posted: Mon Dec 05, 2011 1:50 am
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!
Re: RPG project + random programming questions
Posted: Mon Dec 05, 2011 8:44 pm
by Jasoco
Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
Re: RPG project + random programming questions
Posted: Mon Dec 05, 2011 10:35 pm
by Kadoba
Jasoco wrote:Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
Death to the heretic!