Module: Gamefic::Scriptable::Queries

Includes:
Proxy
Included in:
Narrative, Gamefic::Scriptable, Actions
Defined in:
lib/gamefic/scriptable/queries.rb

Overview

Scriptable methods related to creating action queries.

Instance Method Summary collapse

Methods included from Proxy

#proxy, #unproxy

Instance Method Details

#anywhere(*args, ambiguous: false) ⇒ Query::General

Define a query that searches the entire plot’s entities.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



14
15
16
# File 'lib/gamefic/scriptable/queries.rb', line 14

def anywhere *args, ambiguous: false
  Query::General.new -> { entities }, *unproxy(args), ambiguous: ambiguous
end

#available(*args, ambiguous: false) ⇒ Query::Scoped Also known as: family

Define a query that searches an actor’s family of entities. The results include the parent, siblings, children, and accessible descendants of siblings and children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



24
25
26
# File 'lib/gamefic/scriptable/queries.rb', line 24

def available *args, ambiguous: false
  Query::Scoped.new Scope::Family, *unproxy(args), ambiguous: ambiguous
end

#children(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that searches an actor’s children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



41
42
43
# File 'lib/gamefic/scriptable/queries.rb', line 41

def children *args, ambiguous: false
  Query::Scoped.new Scope::Children, *unproxy(args), ambiguous: ambiguous
end

#myself(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that returns the actor itself.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



57
58
59
# File 'lib/gamefic/scriptable/queries.rb', line 57

def myself *args, ambiguous: false
  Query::Scoped.new Scope::Myself, *unproxy(args), ambiguous: ambiguous
end

#parent(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that returns the actor’s parent.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



33
34
35
# File 'lib/gamefic/scriptable/queries.rb', line 33

def parent *args, ambiguous: false
  Query::Scoped.new Scope::Parent, *unproxy(args), ambiguous: ambiguous
end

#plaintext(arg = nil) ⇒ Query::Text

Define a query that performs a plaintext search. It can take a String or a RegExp as an argument. If no argument is provided, it will match any text it finds in the command. A successful query returns the corresponding text instead of an entity.

Parameters:

  • arg (String, Regrxp) (defaults to: nil)

    The string or regular expression to match

Returns:



68
69
70
# File 'lib/gamefic/scriptable/queries.rb', line 68

def plaintext arg = nil
  Query::Text.new arg
end

#siblings(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that searches an actor’s siblings.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



49
50
51
# File 'lib/gamefic/scriptable/queries.rb', line 49

def siblings *args, ambiguous: false
  Query::Scoped.new Scope::Siblings, *unproxy(args), ambiguous: ambiguous
end