RPG project
Re: RPG project + random programming questions
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?
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: RPG project + random programming questions
I'm interested in this question too, but also for functions.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'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
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
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: RPG project + random programming questions
_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
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:bartbes wrote:_G is the global table. This won't work for locals, but otherwise it should do the trick.
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: RPG project + random programming questions
Please don't use debugging functions in games you want to publish, because SELÖVE forbids it, because it breaks the sandbox.miko wrote:For locals, debug.getlocal() or debug.getenv() would work.
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: RPG project + random programming questions
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
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
- SoggyWaffles
- Citizen
- Posts: 72
- Joined: Sun Jan 02, 2011 3:27 am
- Location: Wyoming, USA
Re: RPG project + random programming questions
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!
"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
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: RPG project + random programming questions
Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
Re: RPG project + random programming questions
Death to the heretic!Jasoco wrote:Those are the best kinds of RPG. None of this newfangled Final Fantasy XIII/Oblivion crap.
Who is online
Users browsing this forum: Google [Bot] and 1 guest