Copy these into the corresponding files.
Obviously, it's not finished. It's just a simple example of what can be done with DSB in a few tens of minutes of coding.
Code: Select all
---DSB ESB---
--[[ Autogenerated by ESB.
Trying to edit this file by hand may not give you
particularly good results.
]]
dsb_text2map(0, 32, 32, 100, 1, {
"10000000000000000000000000000000",
"10000000000000000000000000000000",
"11100000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000"} )
dsb_level_wallset(0, wallset.default)
dsb_add_champion(1, "TEST_1", "port_mophus", "TEST_1", "", 9000, 9000, 9000, 2550, 2550, 2550, 2550, 2550, 2550, 500, 15, 15, 15, 15)
ch_exvar = {
}
dsb_spawnburst_begin(7)
dsb_spawn(1, "doorframe", 0, 0, 0, 4)
dsb_spawn(2, "door_black", 0, 0, 0, 4)
dsb_spawn(7, "dialog_reply", 0, 3, 0, 4)
dsb_spawn(4, "event_dialog", 0, 2, 1, 4)
dsb_spawn(5, "dialog_reply", 0, 3, 1, 0)
dsb_spawn(3, "trigger", 0, 2, 2, 4)
dsb_spawn(6, "event_dialog", 0, 4, 2, 4)
exvar = {
[3] = { target = 4,
msg = 100000,
opby_party = true },
[4] = { silent = true,
msg = 100000,
text = "TEST ONE/MOPHUS SPEAKING",
target = { 5, 7 } },
[5] = { target = 6,
text = "TEST TWO - I'M A BURGER",
msg = 100000,
silent = true },
[6] = { text = "DIALOG 2" },
[7] = { text = "TEST THREE - EXIT / VERY LONG TEXT BLA BLA BILBOBIL" },
}
dsb_spawnburst_end()
EDITOR_FLAGS = 255
dsb_champion_toparty(0, 1)
dsb_party_place(0, 0, 1, 2)
Code: Select all
-- TEMP: Remove intro
function sys_game_intro()
return true
end
-- TEMP: Autoselect Enter
--function sys_game_start(savegames)
-- return nil
--end
function show_dialog(id,data)
if not exvar[id] then return
else
local options=exvar[id]
-----------------
-- Main bitmap --
-----------------
local sheet = dsb_new_bitmap(640, 480)
dsb_bitmap_clear(sheet, {0, 0, 150})
if options.sheet then
dsb_bitmap_draw(gfx[options.sheet], sheet, 0, 0, false)
end
local level, x, y, facing
level, x, y, facing = dsb_party_coords()
local x_size, y_size, light, xp_multiplier = dsb_level_getinfo(level)
local dview = dsb_dungeon_view(level, x, y, facing, light)
local y_text, x_text
x_text= 8
y_text= 8
if options.show_viewport==true then
dsb_bitmap_draw(dview, sheet, 0, 86, false)
end
--~ if options.show_party=true then
--~ for i=0,3
--~ local char = dsb_ppos_char(i)
--~ if (valid_and_alive(char)) then
--~ dsb_bitmap_draw(, sheet, 0, 0, false)
--~ else
--~ end
dsb_bitmap_rect(sheet, 450, 0, 639, 86, {240,240,40}, false)
if options.npc_portrait then
dsb_bitmap_draw(gfx[npc_portrait], sheet, 520, 12, false)
else
dsb_bitmap_draw(gfx["port_mophus"], sheet, 520, 12, false)
end
dsb_textformat(28, 12, 10)
--~ if (exvar[id] and exvar[id].text) then
--~ local lines, num_lines = dsb_linesplit(exvar[id].text, "/")
--~ local y_base = 72 - (num_lines*7) + (num_lines % 2)
--~ local i
--~
--~ for i=1,num_lines do
--~ dsb_bitmap_textout(sr, gfx.scroll_font, lines[i],
--~ 124, y_base+((i-1)*14), CENTER, scroll_color)
--~ end
--~ end
--~
local color = {240,240,240}
if options.color then color = options.color end
local text = "DIALOG"
if options.text then text = options.text end
local lines, num_lines = dsb_linesplit(text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
if y_text<=86 then y_text=86 end
dsb_bitmap_rect(sheet, 0, 0, 449, y_text, {240,240,40}, false)
y_text=y_text+5
local answer=0
clickzones={}
local target = options.target
if target then
local number = 0
if type(target)=="table" then
for k,el in pairs(target) do
if exvar[el] then
if exvar[el].text then
local lines, num_lines = dsb_linesplit(exvar[el].text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
--lines = dsb_bitmap_textout(sheet, sys_font, exvar[el].text, x_text, y_text, LEFT, {222,222,222})
dsb_bitmap_rect(sheet, 0, y_text-3-12*total_lines, 449, y_text, {240,240,40}, false)
local next_dialog = exvar[el].target
if next_dialog then
--dsb_msgzone(sheet, next_dialog, number, 0, y_text-3, 449, y_text+12*lines+2, M_ACTIVATE)
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, next_dialog }
else
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, nil }
end
y_text=y_text+5
end
end
end
else
if exvar[target] then
if exvar[target].text then
local lines, num_lines = dsb_linesplit(exvar[el].text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
dsb_bitmap_rect(sheet, 0, y_text-3-12*lines, 449, y_text+2, {240,240,240}, false)
local next_dialog = exvar[target].target
if next_dialog then
--dsb_msgzone(sheet, next_dialog, number, 0, y_text-3, 449, y_text+12*lines+2, M_ACTIVATE)
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, next_dialog }
else
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, nil }
end
y_text=y_text+5
end
else
lines = dsb_bitmap_textout(sheet, sys_font, "...", x_text, y_text, LEFT, {222,222,222})
dsb_bitmap_rect(sheet, 0, y_text-3, 449, y_text+12*lines+2, {240,240,240}, false)
y_text=y_text+5
end
end
end
local bitmap_or_func, click_func, update_func, mouse, fade
if answer==0 then
click_func=EXIT_ON_CLICK
else
function click_func(mouse_x,mouse_y,mouse_button)
for k,el in pairs(clickzones) do
if mouse_x <= el[3] and mouse_x >= el[1] and mouse_y <= el[4] and mouse_y >= el[2] then
if el[5]==nil then
return true
else
dsb_msg(1, el[5], M_ACTIVATE, 0)
return true
end
end
end
return false
end
end
update_func=nil
mouse = true
--if options.no_mouse then mouse = false end
fade = false
if options.fade then fade = true end
dsb_fullscreen(sheet, click_func, update_func, mouse, fade)
end
end
dialog_msg_handler = {
[M_ACTIVATE] = show_dialog
--[M_DEACTIVATE] = object_disable,
--[M_TOGGLE] = object_toggle,
--[M_CLEANUP] = clean_up_target_exvars,
--[M_RESET] = trigger_reset,
--[M_DESTROY] = self_destruct
}