Instantly share code, notes, and snippets.

Embed
What would you like to do?
Console++ example mod source code
#include Console/console++
-- GUIDS
deck_a_guid = 'b99779'
deck_b_guid = '3e5111'
deck_c_guid = '29c75c'
d4_guid = '2a263c'
d6_guid = '6f3619'
card_guids = {
'0aff36', '6e5c51', 'e84baf', '5715b4', '43c358',
'b0165c', 'eebc5d', '7d9bba', '03b474',
}
console.hide_globals('guids')
-- END OF GUIDS
update_cards = false
check_delay = 1.5
check_total = 0
next_check = 0
function onLoad()
decks = {}
decks.a = getObjectFromGUID(deck_a_guid)
decks.b = getObjectFromGUID(deck_b_guid)
decks.c = getObjectFromGUID(deck_c_guid)
dice = {}
dice.d4 = getObjectFromGUID(d4_guid)
dice.d6 = getObjectFromGUID(d6_guid)
cards = {nil} -- dummy first value so actual cards start at index 2
for _, guid in ipairs(card_guids) do
table.insert(cards, getObjectFromGUID(guid))
end
console.load()
end
function onUpdate()
console.update()
if update_cards and os.clock() >= next_check then
next_check = os.clock() + check_delay
local digit = dice_total()
for count = 2, 10 do
if is_face_up(cards[count]) ~= (digit==count) then
cards[count].flip()
end
end
end
end
function dice_total()
return dice.d4.getValue() + dice.d6.getValue()
end
function is_face_up(object)
if object then
local r = object.getRotation()
return r.z < 90 or r.z > 270
end
end
function near(object_a, object_b)
local threshold = 1
local a = object_a.getPosition()
local b = object_b.getPosition()
return math.abs(a.x - b.x) < threshold and math.abs(a.z - b.z) < threshold
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment