Initial Commit

master
Majozoe 2022-08-07 23:10:26 -04:00 committed by GitHub
parent 69068dcde2
commit 33155c500c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 148 additions and 0 deletions

64
README.md Normal file
View File

@ -0,0 +1,64 @@
The Grue - A mod for Minetest
< - - - >
Version: 1.0.0
License: CC0 (https://creativecommons.org/publicdomain/zero/1.0/)
< - - - >
- What is this mod? -
The 'Grue' mod is a mod for Minetest that implements a nefarious creature lurking in the dark. As long as you stay in well lit areas, you will be perfectly safe, but stray too far into the dark caves, and you may get eaten.
- That's cool and all, but how does it work? -
As of right now, the game is constantly checking your light level. If it falls below a light level of 2 (0 is the lowest), then a timer startsticking down. This timer is reset if you retreat back to a brighter area.
After 5 seconds, you'll get a warning, and after an additional 5 seconds, you will die.
- Can I see the Grue? -
Nope. The Grue hates light so will stay in pitch black darkness at all times.
That's the lore reason anyway. Technically speaking, there is visible Grue. It's really just a couple of audio files and a timer counting to your doom. :)
- Does this work in multiplayer? -
According to my own testing, yes it does!
- Are you going to add..? -
Me adding anything to this mod is INCREDIBLY unlikely. Really the only point of this mod was to just add the one thing, and I did it! I might still listen to requests, but do be prepared to be let down, especially since I'm a newbie at this at the time of writing.
- Does this mod need anything else installed? -
Nope!
- How do I install this mod? -
Please see http://wiki.minetest.com/wiki/Installing_Mods for the recommended methods of installing
If you are downloading this from Github, then make sure the folder is named "grue" (all lowercaps) and then move it to the mods directory (the above link has details on that too.)
- Heeeelp! I have an issue! -
Don't worry! In the event of something crazy happening, just refer to the forum post located here (link TBD) or create an issue on the Github.
Be sure to include a description of what is going on, what you were doing, whether or not you were on singleplayer, what other mods or even what game you were using, as well as any other info you might think is necessary such as a crash log or a screenshot, etc.
If you do not include enough information, then I'm afraid I am incapable of helping you unless I ask for more info.

78
init.lua Normal file
View File

@ -0,0 +1,78 @@
-- Declaring variables
local warntime = 5 -- tname.timer before you are warned about getting eaten by a Grue
local deathtime = 5 -- tname.timer after getting warned before you are eaten by a Grue
local health = 0
local position = {x=0, y=0, z=0}
local lightlevel = 0
grue = {players = {}}
minetest.register_on_joinplayer(function(player) -- Adds connected players to the table.
local name = player:get_player_name()
local tname = grue.players[name]
if not tname then
grue.players[name] = { timer = 0, warned = false } -- This ties the timer and the "warned" flag to individual players, instead of to the server itself.
end
end)
minetest.register_on_leaveplayer(function(player) -- Removes disconnected players from the table. No need to hang on to that info.
local name = player:get_player_name()
grue.players[name] = nil
end)
-- Main function, checking every tick.
minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local tname = grue.players[name]
local health = player:get_hp()
local position = player:get_pos()
local node = minetest.get_node(position)
if node.name == 'ignore' then -- Ensures people don't die due to loading issues
tname.timer = 0
tname.warned = false
break
end
if health > 0 then -- Making sure the player isn't dead. The Grue is only interested in live prey.
local lightlevel = minetest.get_node_light(position,nil)
if lightlevel <= 1 then -- Checking to see if the local light level is low enough
tname.timer = tname.timer + dtime
if tname.warned == false then -- Checking to see if the player has already been warned.
if tname.timer >= warntime then
minetest.chat_send_player(name, "You are likely to be eaten by a Grue.")
minetest.sound_play("grue_warning", {pos = position, gain = 1.0, max_hear_distance = 8,})
tname.warned = true
tname.timer = 0
end
else
if tname.timer >= deathtime then --This is the part where you die
player:set_hp(0, set_hp)
minetest.chat_send_player(name, "You have been eaten by a Grue.")
minetest.sound_play("grue_attack", {pos = position, gain = 1.0, max_hear_distance = 8,})
tname.warned = false
tname.timer = 0
end
end
else -- Resetting variables now that the player is in a better lit area.
tname.timer = 0
tname.warned = false
end
else -- Resetting variables in the event the player died to other circumstances
tname.timer = 0
tname.warned = false
end
end
end)

6
mod.conf Normal file
View File

@ -0,0 +1,6 @@
name = grue
description = It is pitch black. You are likely to be eaten by a Grue...
depends = default
release = 1.0.0
author = Majozoe
title = Grue

BIN
sounds/grue_attack.ogg Normal file

Binary file not shown.

BIN
sounds/grue_warning.ogg Normal file

Binary file not shown.