This commit is contained in:
Rui914 2015-05-11 00:25:21 +09:00
parent cb1b0b4b25
commit 012dcbb0cf
16 changed files with 222 additions and 202 deletions

13
LICENSE.md Normal file
View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

65
api.lua Normal file
View File

@ -0,0 +1,65 @@
local form_def = "size[16,15;true]".."bgcolor[#00000000;true]"
local function return_form_image(mobname,face)
if face == nil then
face = "normal"
end
return "image[3,2;12.5,15.5;"..mobname.."_"..face..".png]"
end
local function return_form_text(mobname,text,pname)
local name
if pname == nil then
if mobname == "creeper" then
name = "Cupa"
else
name = "Unknown"
end
else
name = pname
end
if text == nil then
face = "MESSAGE IS NIL"
end
return "label[2,11;"..name.."]".."label[2,12;"..text.."]".."image[1.5,11.5;15,3;mobtalker_form.png]"
end
function mobtalker_form(mobname,text,face,pname)
return form_def..return_form_image(mobname,face)..return_form_text(mobname,text,pname)
end
-- Global
function mobtalker_mkdir()
local input = io.open(mobtalker.datadir,"r")
if input then
io.close(input)
else
os.execute("mkdir \""..mobtalker.datadir.."\"")
end
end
--[[ Save and Load
function mobtalker_save(mobname,love)
local output = io.open(mobtalker.datadir.."/"..mobname..".txt", "w")
for _,v in pairs(love) do
output:write(v.."\n")
end
io.close(output)
end
function mobtalker_load(mobname,love)
local input = io.open(mobtalker.datadir.."/"..mobname..".txt", "r")
if input then
repeat
local lv = input:read("*n")
if lv == nil then
break
end
local self = input:read("*l")
love[self] = lv
until input:read(0) == nil
io.close(input)
else
love = {}
end
end
]]--

View File

@ -1,11 +1,9 @@
local id = 1 -- Local
while true do local mobname = "creeper"
local file = io.open(minetest.get_modpath("mobtalker").."/creeper/"..id..".script") local route = {}
if (not file) then break end local pself = {}
file:close() local count = {}
dofile(minetest.get_modpath("mobtalker").."/creeper/"..id..".script") --local day = {}
id = id +1
end
-- intllib -- intllib
local S local S
@ -15,120 +13,69 @@ else
S = function(s) return s end S = function(s) return s end
end end
-- Save -- Form func
local function save() local function c_xform(type,text,def)
local output = io.open(minetest.get_worldpath() .. "/mobtalker_creeper", "w") local button
for i, v in pairs(creeper_love) do if def == nil then
output:write(v..i.."\n") def = {}
end end
io.close(output) if type == "proseed" or type.type == "proseed" or type == nil then
end button = "button_exit[5.5,11;5,0.5;creeper_proseed;"..S("Proseed").."]"
elseif type.choose3 then
-- Load button = "button_exit[5.5,9.6;5,0.5;creeper_choose1;"..type.choose1.."]"..
local function load() "button_exit[5.5,10.3;5,0.5;creeper_choose2;"..type.choose2.."]"..
local input = io.open(minetest.get_worldpath().."/mobtalker_creeper", "r") "button_exit[5.5,11;5,0.5;creeper_choose3;"..type.choose3.."]"
if input then elseif type.choose2 then
repeat button = "button_exit[5.5,10.3;5,0.5;creeper_choose1;"..type.choose1.."]"..
local love = input:read("*n") "button_exit[5.5,11;5,0.5;creeper_choose2;"..type.choose2.."]"
if love == nil then
break
end
local name = input:read("*l")
creeper_love[name] = love
until input:read(0) == nil
io.close(input)
else else
creeper_love = {} button = "button_exit[5.5,11;5,0.5;creeper_"..string.lower(type)..";"..type.."]"
end end
return mobtalker_form(mobname,text,def.face,def.pname)..button
end end
-- Return Formspec -- Return Form
function mobtalker_creeper_talk(player,love,Q) local function creeper_form(player,love,route)
if love == 0 and Q == 1 then if love == 0 and route == 0 and count[player] == 0 then
return "size[5,3;true]".. return c_xform("proseed",S("Hey."))
"label[0,0;"..SET_NAME.."\n"..S("Hey! Who are you?").."]".. elseif love == 1 and route == 0 and count[player] == 0 then
"button_exit[0,1.2;4.8,0.5;creeper_choose1;"..S("My name is %s."):format(player:get_player_name()).."]".. return c_xform("proseed",S("Hey."))
"button_exit[0,2;4.8,0.5;creeper_choose2;"..S("Your death!").."]"
elseif love > 0 and Q == 1 then
return "size[5,2;true]"..
"label[0,0;"..S("Hmm?").."]"..
"button_exit[0,1.4;4.8,0.5;creeper_bye;"..S("See you!").."]"
elseif love < 0 and Q == 1 then
return "size[5,2;true]"..
"label[0,0;"..S("Die!").."]"..
"button_exit[0,1.4;4.8,0.5;;"..S("F**k").."]"
elseif Q == "bye" then
return "size[5,2;true]"..
"label[0,0;"..S("Thanks!").."]"..
"button_exit[0,1.4;4.8,0.5;creeper_bye;"..S("See you!").."]"
elseif Q == "fuck" then
return "size[5,2;true]"..
"label[0,0;"..S("Yeah I don't like you either.").."]"..
"button_exit[0,1.4;4.8,0.5;creeper_boom;"..S("F**k").."]"
end
end
function mobtalker_creeper_image(love,Q)
if love == 0 and Q == 1 then
return "creeper_normal.png"
elseif love > 0 and Q == 1 then
return "creeper_happy.png"
elseif love < 0 and Q == 1 then
return "creeper_angry.png"
else else
return "creeper_normal.png" return c_xform("proseed",S("Exception handling error"))
end end
end end
-- Function -- Global
function mobtalker_creeper(self,clicker) function mobtalker_creeper(self,clicker)
self.object:setvelocity({x=0,y=0,z=0})
creeper_talk[self] = true creeper_talk[self] = true
creeper_talking[clicker:get_player_name()] = true pself[clicker] = self
minetest.show_formspec(clicker:get_player_name(),"creeper:talk",mobtalker_creeper_talk(clicker,creeper_love[clicker:get_player_name()],1)) self.object:setvelocity({x=0,y=0,z=0})
creeper_hud = clicker:hud_add({ minetest.show_formspec(clicker:get_player_name(),mobname..":form",creeper_form(clicker,creeper_love[self],route[clicker]))
hud_elem_type = "image",
position = {x=0.52, y=0.6},
offset = {x=-30, y=0},
scale = {x=0.8, y=0.8},
text = mobtalker_creeper_image(creeper_love[clicker:get_player_name()],1),
});
end end
-- Event -- Event
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.creeper_choose1 then local entity = pself[player]
minetest.after(0.05, function() print(creeper_love[entity])
minetest.show_formspec(player:get_player_name(),"creeper:talk",mobtalker_creeper_talk(player,creeper_love[player:get_player_name()],"bye")) if formname == mobname..":form" then
end) if fields.creeper_proseed then
elseif fields.creeper_choose2 then creeper_talk[entity] = false
minetest.after(0.05, function() if creeper_love[entity] == 0 then
minetest.show_formspec(player:get_player_name(),"creeper:talk",mobtalker_creeper_talk(player,creeper_love[player:get_player_name()],"fuck")) creeper_love[entity] = 1
end) end
elseif fields.creeper_bye then
creeper_talk = {}
creeper_love[player:get_player_name()] = creeper_love[player:get_player_name()] + 1
creeper_talking[player:get_player_name()] = false
player:hud_remove(creeper_hud)
save()
elseif fields.creeper_boom then
creeper_talk = {}
creeper_love[player:get_player_name()] = creeper_love[player:get_player_name()] - 1
creeper_talking[player:get_player_name()] = false
player:hud_remove(creeper_hud)
minetest.after(0.05, function()
creeper_boom(player:getpos())
end)
elseif fields["quit"] == "true" then elseif fields["quit"] == "true" then
creeper_talk = {} creeper_talk[entity] = false
creeper_talking[player:get_player_name()] = false end
player:hud_remove(creeper_hud)
end end
end) end)
-- Auto Load
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
creeper_love[player:get_player_name()] = 0 count[player] = 0
load() route[player] = 0
save() --mobtalker_load(mobname,creeper_love)
end)
minetest.register_on_shutdown(function(player)
local entity = pself[player]
--print(creeper_love[entity])
--mobtalker_save(mobname,creeper_love)
end) end)

76
dm.lua Normal file
View File

@ -0,0 +1,76 @@
-- Local
local mobname = "dungeon_master"
local day = {}
local route = {}
local pself = {}
local count = {}
-- intllib
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
-- All
local function c_xform(type,text,def)
local button
if def == nil then
def = {}
end
if type == "proseed" or type.type == "proseed" or type == nil then
button = "button_exit[5.5,11;5,0.5;dm_proseed;"..S("Proseed").."]"
elseif type.choose3 then
button = "button_exit[5.5,9.6;5,0.5;dm_choose1;"..type.choose1.."]"..
"button_exit[5.5,10.3;5,0.5;dm_choose2;"..type.choose2.."]"..
"button_exit[5.5,11;5,0.5;dm_choose3;"..type.choose3.."]"
elseif type.choose2 then
button = "button_exit[5.5,10.3;5,0.5;dm_choose1;"..type.choose1.."]"..
"button_exit[5.5,11;5,0.5;dm_choose2;"..type.choose2.."]"
else
button = "button_exit[5.5,11;5,0.5;dm_"..string.lower(type)..";"..type.."]"
end
return mobtalker_form(mobname,text,def.face,def.pname)..button
end
-- Function
local function dm_form(player,love,route)
if love == 0 and route == 0 and count[player] == 0 then
return c_xform("proseed",S("Hey."))
else
return c_xform("proseed",S("Exception handling error"))
end
end
function mobtalker_dm(self,clicker)
pself[clicker] = self
self.object:setvelocity({x=0,y=0,z=0})
minetest.show_formspec(clicker:get_player_name(),mobname..":form",dm_form(clicker,dm_love[self],route[clicker]))
end
-- Event
minetest.register_on_player_receive_fields(function(player, formname, fields)
local entity = pself[player]
if formname == mobname..":form" then
if fields.dm_proseed then
dm_talk[entity] = false
if dm_love[entity] == 0 then
dm_love[entity] = 1
end
elseif fields["quit"] == "true" then
dm_talk[entity] = false
end
end
end)
minetest.register_on_joinplayer(function(player)
count[player] = 0
route[player] = 0
--mobtalker_load(mobname,creeper_love)
end)
minetest.register_on_shutdown(function(player)
local entity = pself[player]
--print(creeper_love[entity])
--mobtalker_save(mobname,creeper_love)
end)

View File

@ -1,19 +1,11 @@
mobtalker = {} mobtalker = {}
mobtalker.datadir = minetest.get_worldpath().."/mobtalker"
minetest.register_tool("mobtalker:mobtalker", { dofile(minetest.get_modpath("mobtalker").."/api.lua")
description = "Mob Talker", dofile(minetest.get_modpath("mobtalker").."/item.lua")
inventory_image = "mobtalker.png",
})
minetest.register_craft({
output = 'mobtalker:mobtalker',
recipe = {
{'default:meselamp'},
{'group:stick'},
}
})
if minetest.get_modpath("creeper") then if minetest.get_modpath("creeper") then
dofile(minetest.get_modpath("mobtalker").."/creeper.lua") dofile(minetest.get_modpath("mobtalker").."/creeper.lua")
end end
if minetest.get_modpath("mobs") then if minetest.get_modpath("mobs") then
dofile(minetest.get_modpath("mobtalker").."/mobs.lua") --dofile(minetest.get_modpath("mobtalker").."/dm.lua")
end end
mobtalker_mkdir()

11
item.lua Normal file
View File

@ -0,0 +1,11 @@
minetest.register_tool("mobtalker:mobtalker", {
description = "Mob Talker",
inventory_image = "mobtalker.png",
})
minetest.register_craft({
output = 'mobtalker:mobtalker',
recipe = {
{'default:meselamp'},
{'group:stick'},
}
})

0
locale/ja.txt Normal file
View File

View File

@ -1,84 +0,0 @@
-- intllib
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
-- Hud Number
local hudnumber
if minetest.setting_getbool("enable_damage") then
hudnumber = 1
else
hudnumber = 0
end
--[[
function mobtalker_mobs(self,clicker)
self.object:setvelocity({x=0,y=0,z=0})
talk[self] = true
talking[clicker:get_player_name()] = true
local hud1 = clicker:hud_add({
hud_elem_type = "image",
position = {x=0.55, y=0.6},
offset = {x=-30, y=0},
scale = {x=0.5, y=0.5},
text = "test.png",
});
minetest.show_formspec(clicker:get_player_name(),"mobs:talk",mobtalker_mobs_talk(clicker,mobs_love[clicker:get_player_name()],1))
end
-- Return Formspec
function mobtalker_mobs_talk(player,love,Q)
if love == 0 and Q == 1 then
return "size[5,2;true]"..
"label[0,0;"..S("Hey who are you?").."]"..
"button_exit[0,0.6;4.8,0.5;choose1;"..S("My name is %s."):format(player:get_player_name()).."]"..
"button_exit[0,1.4;4.8,0.5;choose2;"..S("Your death!").."]"
elseif love > 0 and Q == 1 then
return "size[5,2;true]"..
"label[0,0;"..S("Hmm?").."]"..
"button_exit[0,1.4;4.8,0.5;bye;"..S("See you!").."]"
elseif love < 0 and Q == 1 then
return "size[5,2;true]"..
"label[0,0;"..S("Die!").."]"..
"button_exit[0,1.4;4.8,0.5;bye;"..S("F**k").."]"
elseif Q == "bye" then
return "size[5,2;true]"..
"label[0,0;"..S("Thanks!").."]"..
"button_exit[0,1.4;4.8,0.5;bye;"..S("See you!").."]"
elseif Q == "fuck" then
return "size[5,2;true]"..
"label[0,0;"..S("Yeah I don't like you either.").."]"..
"button_exit[0,1.4;4.8,0.5;boom;"..S("F**k").."]"
end
end
-- Event
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.choose1 then
minetest.after(0.2, function()
minetest.show_formspec(player:get_player_name(),"mobs:talk",mobtalker_mobs_talk(player,mobs_love[player:get_player_name()],"bye"))
end)
elseif fields.choose2 then
minetest.after(0.2, function()
minetest.show_formspec(player:get_player_name(),"mobs:talk",mobtalker_mobs_talk(player,mobs_love[player:get_player_name()],"fuck"))
end)
elseif fields.bye then
talk = {}
mobs_love[player:get_player_name()] = mobs_love[player:get_player_name()] + 1
talking[player:get_player_name()] = false
player:hud_remove(hudnumber)
elseif fields.boom then
talk = {}
mobs_love[player:get_player_name()] = mobs_love[player:get_player_name()] - 1
talking[player:get_player_name()] = false
player:hud_remove(hudnumber)
mobs_boom(player:getpos())
elseif fields["quit"] == "true" then
talk = {}
talking[player:get_player_name()] = false
player:hud_remove(hudnumber)
end
end)
]]--

BIN
textures/creeper_angry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

BIN
textures/creeper_happy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
textures/creeper_normal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
textures/creeper_sad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
textures/creeper_scared.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
textures/creeper_shy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
textures/creeper_tired.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
textures/mobtalker_form.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB