summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Carmona Varo <ferkiwi@gmail.com>2015-10-24 22:31:23 +0200
committerFernando Carmona Varo <ferkiwi@gmail.com>2015-10-24 22:55:59 +0200
commitebde4407511a7255e1e5b6d897f81188c4fe2eb3 (patch)
tree6427830f7ec41d86827a4b6aa07ec4a14f1e0f01
parent65f7603ae3aac553716c8d4e9141914251b430d5 (diff)
Some refactoring and organization, added api.lua
-rwxr-xr-xmyhighscore/api.lua9
-rw-r--r--myhighscore/init.lua65
-rwxr-xr-xmyhighscore/scoreboard.lua64
3 files changed, 76 insertions, 62 deletions
diff --git a/myhighscore/api.lua b/myhighscore/api.lua
new file mode 100755
index 0000000..bbad4d7
--- /dev/null
+++ b/myhighscore/api.lua
@@ -0,0 +1,9 @@
+
+myhighscore.registered_games = {}
+
+
+-- You can register a new arcade game using this function
+myhighscore.register_game(name, definition)
+ definition.description = definition.description or name
+ myhighscore.registered_games[name] = definition
+end
diff --git a/myhighscore/init.lua b/myhighscore/init.lua
index 0eab03c..854be70 100644
--- a/myhighscore/init.lua
+++ b/myhighscore/init.lua
@@ -1,64 +1,5 @@
+myhighscore = {}
-local button_form = "size[6,8;]"..
- "background[0,0;6,8;myhighscore_form_bg.png]"..
- "label[1,0.5;HIGH SCORES]"..
- "button[1,1;4,1;game;label]"..
- "button_exit[4,7;1,2;exit;Exit]"
-
---place holders
-local game_name = "the game"
-local game_player_name = "the player"
-local game_player_score = "648138"
-
-local game_form = "size[6,8;]"..
- "background[0,0;6,8;myhighscore_form_bg.png]"..
- "label[1,0.5;HIGH SCORES FOR "..game_name.."]"..
- "label[1,1.5;PLAYER]"..
- "label[3.5,1.5;SCORE]"..
- "label[0.5,2;"..game_player_name.."]"..
- "label[3,2;"..game_player_score.."]"..
- "button[2,7;1,2;back;Back]"..
- "button_exit[4,7;1,2;exit;Exit]"
-
-minetest.register_node("myhighscore:score_board", {
- description = "Score Board",
- tiles = {
- "myhighscore_top.png",
- "myhighscore_back.png",
- "myhighscore_side.png^[transformFX",
- "myhighscore_side.png",
- "myhighscore_back.png",
- "myhighscore_front.png",
- },
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- groups = {cracky = 1},
- node_box = {
- type = "fixed",
- fixed = {
- {-0.375, -0.5, -0.5, 0.375, -0.1875, 0.5},
- {-0.375, -0.5, 0.1875, 0.375, 0.5, 0.5},
- {-0.1875, -0.5, -0.3125, -0.125, 0, -0.25},
- {-0.375, -0.5, 0, -0.3125, 0.5, 0.5},
- {0.3125, -0.5, 0, 0.375, 0.5, 0.5},
- {-0.375, 0.4375, 0, 0.375, 0.5, 0.5},
- }
- },
-
-on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
- meta:set_string("formspec", button_form)
- meta:set_string("infotext", "High Scores")
-end,
-on_receive_fields = function(pos, formname, fields, sender)
- local meta = minetest.env:get_meta(pos)
- if fields['game'] then
- meta:set_string('formspec', game_form)
- elseif fields["back"] then
- meta:set_string('formspec', button_form)
- end
-end,
-
-})
+dofile(minetest.get_modpath("myhighscore").."/api.lua")
+dofile(minetest.get_modpath("myhighscore").."/scoreboard.lua")
diff --git a/myhighscore/scoreboard.lua b/myhighscore/scoreboard.lua
new file mode 100755
index 0000000..226e86a
--- /dev/null
+++ b/myhighscore/scoreboard.lua
@@ -0,0 +1,64 @@
+
+
+
+
+local button_form = "size[6,8;]"..
+ "background[0,0;6,8;myhighscore_form_bg.png]"..
+ "label[1,0.5;HIGH SCORES]"..
+ "button[1,1;4,1;game;label]"..
+ "button_exit[4,7;1,2;exit;Exit]"
+
+--place holders
+local game_name = "the game"
+local game_player_name = "the player"
+local game_player_score = "648138"
+
+local game_form = "size[6,8;]"..
+ "background[0,0;6,8;myhighscore_form_bg.png]"..
+ "label[1,0.5;HIGH SCORES FOR "..game_name.."]"..
+ "label[1,1.5;PLAYER]"..
+ "label[3.5,1.5;SCORE]"..
+ "label[0.5,2;"..game_player_name.."]"..
+ "label[3,2;"..game_player_score.."]"..
+ "button[2,7;1,2;back;Back]"..
+ "button_exit[4,7;1,2;exit;Exit]"
+
+minetest.register_node("myhighscore:score_board", {
+ description = "Score Board",
+ tiles = {
+ "myhighscore_top.png",
+ "myhighscore_back.png",
+ "myhighscore_side.png^[transformFX",
+ "myhighscore_side.png",y
+ "myhighscore_back.png",
+ "myhighscore_front.png",
+ },
+ drawtype = "nodebox",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {cracky = 1},
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.375, -0.5, -0.5, 0.375, -0.1875, 0.5},
+ {-0.375, -0.5, 0.1875, 0.375, 0.5, 0.5},
+ {-0.1875, -0.5, -0.3125, -0.125, 0, -0.25},
+ {-0.375, -0.5, 0, -0.3125, 0.5, 0.5},
+ {0.3125, -0.5, 0, 0.375, 0.5, 0.5},
+ {-0.375, 0.4375, 0, 0.375, 0.5, 0.5},
+ }
+ },
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_string("formspec", button_form)
+ meta:set_string("infotext", "High Scores")
+ end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ local meta = minetest.env:get_meta(pos)
+ if fields['game'] then
+ meta:set_string('formspec', game_form)
+ elseif fields["back"] then
+ meta:set_string('formspec', button_form)
+ end
+ end,
+})