Skip to content

Instantly share code, notes, and snippets.

@zephjc
Last active December 21, 2015 19:58
Show Gist options
  • Save zephjc/6357499 to your computer and use it in GitHub Desktop.
Save zephjc/6357499 to your computer and use it in GitHub Desktop.
cross-location property access

Overview:

Add cross-location property access with a wrapper around the "setfocus" function with new global function "realmfocus", which takes two arguments: the other location's key, and the key for the text property to setfocus.

This is a handy way of being able to compartmentalize descriptions by effectively namespacing them.

The actual copied value is set as a player attribute to avoid multiple users overwriting each others' current setfocus string.

Usage:

In 'loc_0' location:

desc - Text

[Look at the sky|realmfocus('env', 'sky')] [Look at the ground|realmfocusm('env.ground')]

In 'env' location:

sky - Text

The sky is blue and pretty. [Go west|loc_west].

ground - Text

The ground is brown with some rocks and junk.

Global properties

realmfocus - Code with args

args: ns, key=None

if '.' in ns and key is None:
  ns, key = ns.split('.')
player.realmfocus_temp = location(ns)[key]
setfocus("realmfocus_temp")

realmfocus_temp - Code

return print(text(player.realmfocus_temp))

Player properties

realmfocus_temp - Text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment