Brett Witty <brettwi...@brettwitty.net> writes:

This is close to what you want I think.

#+TBLNAME: stats
| STR | 13 |
| DEX | 12 |
| CON | 11 |


#+BEGIN_SRC python :results value :var data=stats
d = dict(data)
return d['DEX'] + d['CON']
#+END_SRC

#+RESULTS:
: 23


> Hi,
>
> I'm trying to write my RPG adventures in org-mode and would like to
> bring character sheets into that fold. Is there a way in Babel to have
> a vast number of named variables that I can feed into source blocks?
> Are macros the way to achieve this?
>
> As an example, I'd like something like a big (hidden) table:
> #+NAME: stats
> | STR | 13 |
> | DEX | 12 |
> | CON | 11 |
>
> and then later I can use that like:
> #+NAME: AC
> #+begin_src python :var dex=table[DEX] :var armour=table[ARMOUR]
> return dex + armour
> #+end_src
>
> I know I can make explicit cell references, but it'd be neat to just
> use keys for values.
>
> Cheers,
>
> BrettW
>

-- 
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

Reply via email to