Thanks to POF for developing score board for 3 players in ssf2, which was the basic idea to develop this plugin.
Best Regards
archive: init.lua
Code: Select all
-- Score Board for SF2CE v1.0 - Nov-2019
-- Youtube channel: https://www.youtube.com/channel/UC-XTXmO-_bJ4M9yPfj1Xpvw
-- Thanks for 2013 Pau Oliva Fora for original idea and adapted by yacsha
local exports = {}
exports.name = 'ScoreBoard 1.0'
exports.version = '1.0'
exports.description = 'Score for SF2CE offline'
exports.license = 'The BSD 3-Clause License'
exports.author = { name = 'Yacsha' }
local scoreboard = exports
function scoreboard.startplugin()
local function draw_scores( space, screen)
local date = os.date("%d/%m/%Y")
screen:draw_box(5, 0, 130, 14, 0x80202020, 0)
screen:draw_box(150, 0, 250, 14, 0x80202020, 0)
screen:draw_box(290, 0, 340, 14, 0x80202020, 0)
screen:draw_text(10,3, "TEAM PERU Scoreboard - " .. date )
screen:draw_text(160,3, "Player1 (" .. p1_score .. ") VS Player2 (" .. p2_score ..")")
screen:draw_text(300,3, "by Yacsha" )
if not count_scores then
return
end
local winner = who_wins(space)
if (winner == 1) then
p1_score = p1_score + 1
elseif (winner == 2) then
p2_score = p2_score + 1
end
return
end
function who_wins( space )
prev_is_p1_human = is_p1_human
prev_is_p2_human = is_p2_human
is_p1_human = space:read_u8(0xFF864C)
is_p2_human = space:read_u8(0xFF894C)
prev_p1_sets_won = p1_sets_won
prev_p2_sets_won = p2_sets_won
p1_sets_won = space:read_u8(0xFF864E)
p2_sets_won = space:read_u8(0xFF894E)
if (((is_p1_human==1 and is_p2_human==0) or (is_p1_human==0 and is_p2_human==1) ) and (prev_is_p1_human==1 and prev_is_p2_human==1) ) then
if (prev_p1_sets_won > prev_p2_sets_won) then
return 1
end
if (prev_p2_sets_won > prev_p1_sets_won) then
return 2
end
end
return 0
end
function reset()
count_scores = 1
p1_sets_won = 0
p2_sets_won = 0
prev_p1_sets_won = 0
prev_p2_sets_won = 0
p1 = ""
p2 = ""
p1_char = 0
p2_char = 0
p1_color = 0
p2_color = 0
is_match_active = 0
prev_is_match_active = 0
p1_score = 0
p2_score = 0
is_p1_human = 0
prev_is_p1_human = 0
is_p2_human = 0
prev_is_p2_human = 0
end
emu.register_start(function ()
cpu = manager:machine().devices[":maincpu"]
end)
emu.register_frame_done(function()
space = cpu.spaces["program"]
screen = manager:machine().screens[":screen"]
draw_scores(space, screen)
end)
emu.register_stop(function()
reset()
end)
reset()
end
return exports
Code: Select all
{
"plugin": {
"name": "scoreboard",
"description": "ScoreBoard 1.0",
"version": "1.0",
"author": "Yacsha",
"type": "plugin",
"start": "false"
}
}