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

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 = {}
minetest.register_tool("mobtalker:mobtalker", {
description = "Mob Talker",
inventory_image = "mobtalker.png",
})
minetest.register_craft({
output = 'mobtalker:mobtalker',
recipe = {
{'default:meselamp'},
{'group:stick'},
}
})
mobtalker.datadir = minetest.get_worldpath().."/mobtalker"
dofile(minetest.get_modpath("mobtalker").."/api.lua")
dofile(minetest.get_modpath("mobtalker").."/item.lua")
if minetest.get_modpath("creeper") then
dofile(minetest.get_modpath("mobtalker").."/creeper.lua")
end
if minetest.get_modpath("mobs") then
dofile(minetest.get_modpath("mobtalker").."/mobs.lua")
--dofile(minetest.get_modpath("mobtalker").."/dm.lua")
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