[Mod] LATE [late]

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

[Mod] LATE [late]

by Pyrollo » Post

L.A.T.E - Library Adding Temporary Effects to Minetest

Licenses : Code under LGPL v2.1 / Textures under CC-BY-SA

Dependancies : default, 3d_armor (optional)

LATE: Download | Browse code | API Documentation

Extra impacts: Download | Browse code

Demo mod: Download | Browse code


Introduction

LATE allows an easy creation of combinable, temporary effects on various targets:

Easy creation: Effects are easy to create. Most of the time, few more entries in item or node table definition will do the job.

Various targets: LATE effects can affect players and mobs, with the same API.

Combinable: All effects created by LATE can be combined to each other without conflicts. LATE takes in charge effect mixing to give a coherent result.

Temporary: LATE manages temporary effects, not instant effects. Effects lasts for a given time duration or as long as given condition are fulfilled (equiped with item, near node). Effect intensity can smoothly raise and fall.

Extensible: New effect impact types can be defined and registered, increasing variety of effects.

A quick example using LATE to create magic items:

Code: Select all

-- Speed boots (run three times faster)
minetest.register_tool("mymod:speed_boots", { 
    description = "Speed boots", 
	inventory_image = "mymod_boots.png",
    effect_equip = { impacts = { speed=3 } },
}) 

-- Invisibility potion (gives invisibility for 20 seconds)
minetest.register_tool("mymod:invisibility_potion", { 
    description = "Invisibility potion", 
	inventory_image = "mymod_potion.png",
    effect_use = { impacts = { texture = { opacity = 0 } }, duration = 20 },
})

-- Solar stone (always day 15 nodes around)
minetest.register_node("mymod:solar_stone", { 
    description = "Solar stone", 
    ...
    effect_near = { impacts = { daylight = 1 }, distance = 15, raise = 2, fall = 1},
})
Available impacts
On players:
  • Speed change
  • Jump height change
  • Gravity change
  • Daylight change
On both mobs and players:
  • Body color and opacity
  • Damage (or heal)
Short term improvements
  • Hud display of ongoing effects
  • Effect cancellation and antidote
  • Several effects on items and nodes
  • More impact types
Long term improvements
  • Effects on world itself (perceptible by all players)
  • Persistance of effects on mobs on server restart (now only player effects persist)
  • Conditions registration for adding custom conditions
  • Node effect intensity according to node distance
Similar mods

LATE is not the first mod dealing with temporary effect and effect mixing.

Player Effects by Wuzzy (forum/git) is very good mod to manage temporary effect and it was my main source of inspiration. It does not offer combinable effects but it can be used along with Player Monoids.

Player Monoids by Byakuren (forum/git) offers a way to combine impacts on players in various way. Used with Player Effects, it gives something close to LATE mod.

Why developing LATE then ? Because it adds a few more things:
  • Very simple way to create effects and associate them to items and nodes.
  • Effects on mobs.
  • Effect intensity variation in time.
  • Fully associative combination of effects (actually a restriction, but allows having same cumulated result regardless of order of the effects)
Two other noticable mods dealing with effect combination are Pova by TenPlus1 (git) and Physicsh by rdococ (forum/git).

Inspiration and thanks
I wanted to thanks the authors of these four mod and these aditional ones from which I took some inspiration too: LATE is still a work in progress and, I hope, the first brick of a bigger project I have in mind.

I hope being enough clear in my writtings. English is not my native language and some concepts may not easy to describe.
Last edited by Pyrollo on Wed Sep 05, 2018 19:11, edited 2 times in total.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: [Mod] LATE [late]

by aristotle » Post

Wow. Every time I browse the forum for new mods I get more and more astonished by what can be achieved!
Downloading it to study it and applying it in my experimental singleplayer's/local server worlds.
Thank you! :D
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
Krock
Developer
Posts: 4648
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: [Mod] LATE [late]

by Krock » Post

This library looks already very nice - especially the effort for the documentation. I hope it provides everything what a new mod would need, otherwise it's just yet another library. Obligatory xkcd.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] LATE [late]

by Byakuren » Post

Using this looks quick and easy, which is very nice. I think it would be useful for it to be compatible with player_monoids, since some modders may need its more flexible (but less convenient) interface.
Every time a mod API is left undocumented, a koala dies.

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

Byakuren wrote:I think it would be useful for it to be compatible with player_monoids, since some modders may need its more flexible (but less convenient) interface.
I should think about it even if I'm not sure if it can be fully achieved. At last do something to make both system cohabit.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

Created a demo mod for having an idea of what this library can do.

Mod is here : https://github.com/pyrollo/late_demo

Don't use it on servers! It has been written for demonstration purpose, absolutely not for production.

Here is a sheep hit by a tchernostick, it made it green glowing in the dark for a while...
Image
Attachments
A radioactive sheep
A radioactive sheep
screenshot_20180905_195739.png (409.26 KiB) Viewed 1371 times
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] LATE [late]

by Byakuren » Post

Pyrollo wrote:
Byakuren wrote:I think it would be useful for it to be compatible with player_monoids, since some modders may need its more flexible (but less convenient) interface.
I should think about it even if I'm not sure if it can be fully achieved. At last do something to make both system cohabit.
It could be achieved by soft depending on player_monoids and using its provided monoids instead of set_physics_override. Or if https://github.com/minetest/minetest/pull/7269 is merged, you would just need to switch to set_physics_modifier.
Every time a mod API is left undocumented, a koala dies.

User avatar
Lone_Wolf
Member
Posts: 2575
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] LATE [late]

by Lone_Wolf » Post

This looks awesome. I'll have to try it out.
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: [Mod] LATE [late]

by orwell » Post

Hello,
Nice that you put so much effort into this. I have a small request that will improve the potential of your mod greatly.
Allow it not only to place physics overrides and texture changes, but also temporary privileges, such as a temporary fly ability.
And custom HUDs possibly, like that spladder thing in MarioKart
Thanks
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

Hi Orwell, thanks for your interrest.

HUD is already in development and actually usable (I just need a few textures to play with it). The HUD syntax is :

Code: Select all

{
... effect definition...
hud = { color='colorstring', icon='icon.png', },
}
where colorstring is any colorstring for background hud (default white IIRC) and icon.png is a texture that will be displayed.

Fly privilege is easy to add but I'm not fully satisfied with it as it is an ON/OFF thing. I'm thinking about another way to perform flight, by attaching an invisible entity, but I haven' t done any work in that direction yet.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: [Mod] LATE [late]

by orwell » Post

There could be other uses for temporary privs, or revocation of certain privs. Examples:
- A teleport blocker effect that revokes teleport privs while in combat or in jail.
- Duct tape, when used on a player revokes his 'shout' priv ("sticking duct tape on mouth")
- Handcuffs, revoking interact
- Something temporarily granting protection_bypass
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: [Mod] LATE [late]

by PolySaken » Post

orwell wrote:...
- Something temporarily granting protection_bypass...
crowbar?
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

PolySaken wrote:
orwell wrote:...
- Something temporarily granting protection_bypass...
crowbar?
Ahaha :D
I had a plan to add a "vandal" mod using display_modpack for graffitis and allowing to break glass, in protected zones.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

gpcf
Member
Posts: 382
Joined: Fri May 27, 2016 10:48
GitHub: gpcf
In-game: gabriel

Re: [Mod] LATE [late]

by gpcf » Post

We need duct tape and handcuffs!

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

I just want to compliment Pyrollo for making this advanced and flexible yet quite simple to use library! Even in alpha it offers so many possibilities. I especially appreciate the HUD and the effects generated from nodes.

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

Thanks a lot ! Thats encouraging :)

And thanks a lot for filing issues, that's nice and this will put me back to LATE dev which I left for a while.

I hope some day we will have a simple and powerful framework for managing various effects.

I had fun with effects generated from nodes. I think it could add very interresting things to minetest worlds.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

I'm wondering, are there any downside of using this framework for longtime effects, even a whole player lifetime? (The T stands for "Temporary" after all)

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

@Pyrollo
Have a look at my HUD branch if you'd like. https://github.com/tacotexmex/late/tree/hud

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

texmex wrote:@Pyrollo
Have a look at my HUD branch if you'd like. https://github.com/tacotexmex/late/tree/hud
Thanks a lot ! I'll have a look as soon as possibile !
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

Implemented digestion effect with hbhunger support in like 30 minutes this morning. In the end I might just implement hunger with LATE only. This library is even more amazing than I first thought.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

Hey Pyrollo, another question for you. Is there no public function like late.remove_effect?

I wrote a super simple sprint mod. Sprinting itself it works of course, but how do I remove the effect when not pressing my sprint key?

Code: Select all

local timer = 0
minetest.register_globalstep(function(dtime)
	timer = timer + dtime
		if timer >= 1 then
			for _,player in ipairs(minetest.get_connected_players()) do
				local ctrl = player:get_player_control()
				local key_press = false
				key_press = ctrl.aux1 and ctrl.up
				if key_press then
					late.new_effect(player, {
						id = "sprint_"..player:get_player_name(),
						raise = 0, fall = 0,
						impacts = { speed = 2 },
						hud = { label = "Sprint brah", icon = "character.png^[sheet:8x4:1,1" },
						stop_on_death = true,
					})
				else
					-- WHAT TO DO HERE ???
				end
			end
		end
end)


User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

Hi Texmex,

Thanks for your feedbacks, they are precious :)

There is no remove_effect or cancel_effect yet. Cancel effect was put in middle term dev. I thought it would be used for poison antidotes.

Another way to do what you are doing would be to implement a new condition, on keys. I had also in my plan the idea to add ability to register conditions.

I think I have to develop this earlier than I thought :)
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

You’re very welcome. I intend to rely quite heavy on this library and so I’m keen on giving you all the feedback you need. I do need the conditions system you speak of, but until it’s included in LATE I will try to roll my own conditions checker.

I also figure that it’s a quite dynamic method to find, discuss and solve issues with the library by me developing the actual game and thus finding the most critical points for improvements. I’m only one dev with one game but my needs should be quite common for developing games.

Btw I love how easy I can reimplement hunger, sprint and other player stats with only LATE. I just let it keep track of player values for me!

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] LATE [late]

by Pyrollo » Post

I guess you can easily add a "key" condition in Effect:check_conditions() function, something similar to "equiped with" condition. If you do it so, don't forget target could be something else that a player. In that case, the "key pressed" condition check should return flase.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] LATE [late]

by texmex » Post

Yes, I should try that!

In the meantime I managed to hack together a stop function called late.stop_effect(target, id) . I just stole it from the register_on_dieplayer function. It's may not be perfect but it works!

Code: Select all

function late.stop_effect(target, id)
	local data = data(target)
	if data then
		for index, effect in pairs(data.effects) do
			if effect.id == id then
				effect:stop()
			end
		end
	end
end
Having already built one sprint mod, hbSprint, it's great to watch the simplicity of a sprint mod made for LATE:

Code: Select all

local timer = 0
minetest.register_globalstep(function(dtime)
	timer = timer + dtime
	if timer >= 0.2 then
		for _,player in ipairs(minetest.get_connected_players()) do
			local ctrl = player:get_player_control()
			local key_press = false
			key_press = ctrl.aux1 and ctrl.up
			if key_press then
				if not late.get_effect_by_id(player, "sprint") then
					late.new_effect(player, {
						id = "sprint",
						raise = 1, fall = 1,
						impacts = {
							speed = 2,
						},
						hud = { label = "Sprint brah", icon = "character.png^[sheet:8x4:1,1" },
						stop_on_death = true,
					})
				end
			else
				if late.get_effect_by_id(player, "sprint") then
					late.stop_effect(player, "sprint")
				end
			end
		end
	end
end)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 7 guests