Skip to content

Instantly share code, notes, and snippets.

require 'active_record'
class Quote < ActiveRecord::Base
def Quote.setup(db_file, adapter='sqlite3')
establish_connection(:database => db_file, :adapter => adapter)
end
def Quote.get_random(term="")
if term.empty?
#sort_links
%a{:href => "/"} Home
|
%a{:href => "random"} Get Random
|
%a{:href => "stats"} Stats
|
Sort By:
- [:nick, :timestamp, :quote].each do |sort|
%a{:href => sort}= sort.to_s.titlecase()
def replace_in_plot(plot)
terms = @terms.dup()
plot.gsub!(/(:\w+)/) do |match|
key = match.sub(/:/, "").downcase.to_sym()
if terms.has_key?(key)
case terms[key]
when String
# The gsub prevents recursive calls.
module ActiveRecord
class Base
def Base.options(field)
return find(:all).inject([]) do |arr, record|
arr.push([record.send(field), record.id])
end
end
end
end
<!-- Get our parameters from the passed data -->
[h: AttackBonus = json.get(macro.args, "AttackBonus")]
[h: DamageDice = json.get(macro.args, "DamageDice")]
[h: CritNumber = json.get(macro.args, "CritNumber")]
[h: CritMultiplier = json.get(macro.args, "CritMultiplier")]
<!-- Do the attack roll, and if >= CritNumber, roll a crit confirmation roll. -->
<b>Attack Roll:</b>
[h: tohit = 1d20]
[t: tohit + AttackBonus]
[h: status = input(
"AttackBonus | 0 | Attack Bonus",
"damageLabel | Don't forget any damage bonuses on Damage Dice || LABEL",
"DamageDice | 1d6 | Damage Dice",
"CritNumber | 20 | Critical Hit Number",
"critLabel | Don't put the 'x' on the Critical Damage Multipler || LABEL",
"CritMultiplier | 2 | Critical Damage Multiplier"
)]
[h: abort(status)]
[h: SaveBonus = json.get(macro.args, "SaveBonus")]
[h: SaveName = json.get(macro.args, "SaveName")]
[h: SaveModifier = json.get(macro.args, "SaveModifier")]
[h, if(SaveName == ""), code: {
[SaveName = "Saving Throw"]
};
{
[SaveName = SaveName + " Saving Throw"]
}
<!--
This macro requires you to impersonate a token or otherwise have the token focused.
-->
[h: status = input(
"SaveName | Fortitude,Reflex,Will | Saving Throw Type | RADIO | VALUE=STRING",
"SaveModifier | 0 | Saving Throw Modifier"
)]
[h: abort(status)]
[h, switch(SaveName), code:
<!--
This macro requires you to impersonate a token or otherwise have the token focused.
-->
[h: status = input(
"SkillName | Skill Name | Name of Skill",
"Attribute | Strength,Dexterity,Constitution,Intelligence,Wisdom,Charisma | Attribute To User | LIST | VALUE=STRING",
"Ranks | 0 | Skill Ranks",
"Modifier | 0 | Misc Modifier"
)]
[h: abort(status)]
Magical
----
Light : 4.5#eeeeee 8.5#c4b366
Personal
----
BullsEyeLatern : cone 12.5#fbe891 cone 24.5#c4b366
Candle : 1.5#c4b366
Torch : 4.5#fbe891 8.5#c4b366
HoodedLatern : 6.5#fbe891 12.5#c4b366