[MOD] Effects

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

[MOD] Effects

by BrandonReese » Sun Jan 19, 2014 03:14

Effects

License: WTFPL
Depends: whoison ( https://github.com/bremaweb/whoison )
Download: https://github.com/Bremaweb/affects/archive/master.zip
Github: https://github.com/bremaweb/affects

This mod depends on my whoison mod because it times how long a player is online, the length of an affect stage is based on the player's time online.


This mod adds an API that makes it easy to affect players in various ways. These effects can be anything from adjusting their physics, giving temporary permissions, and even simulating poisons or diseases.

This is only an API, it doesn't have any predefined effects that are setup by default. There is a affect_examples.lua file which includes a few examples, but this file isn't loaded when the mod runs.

Functions

affects.registerAffect( {affect definition} )
affects.affectPlayer(name,affectid)
affects.removeAffect(name,affectid)

Effect Definition

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
affect = {
            affectid = <unique string id for this affect>,
            name = <string name for this affect>,
            stages = { {stage definition}, {stage definition}, .. },
            onremove = function(name,player,affectid) -- optional function that is ran when the affect is removed
}


Stage Definition
This is where the magic happens. You can define as many stages for an effect as you want. This can be used to gradually decrease the effect or make the effect change over time. The sky is the limit

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
{
    time = <number of seconds this stage lasts>,
   
    physics = { ... },
    -- optional this is a table as used by set_physics_override  ( https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1787 ) to change the physics for a player during this stage
   
    emote = { chance = <Number 1-100>, action = <string> }
    -- optional chance is the chance out of 100 that action will be displayed in chat as if the affected player had used /me <action>
   
    place = { chance = <number 1-100>, node = <string node that will be placed> },
    -- optional, chance is the chance out of 100 the player with place the node defined at their current position, node would be a string like "default:dirt"
   
    damage = { chance = <number 1-100>, amount = <number> }
    -- optional, chance the player will be dealt the amount defined in damage, this could be a negative number and actually result in healing instead of damage
   
    custom { func = function(name, player, affectid), chance = <number 1-100>, runonce = <true/false> }
    -- optional, a function that you can write to do whatever you want. runonce tells whether this function should only be ran once or not
   
}
   


When a player is affected they start at the first stage. The function to apply the effects runs every 30 seconds. Each time it runs it uses what you defined as a chance to determine if it should execute the items in the stage, excluding physics. Physics are re-applied every run to ensure the physics changes are applied even after the player logs off and logs back on.

The custom function has a runonce variable, if true the custom function will only run one time for the whole time that stage is in affect. After the player has been online longer than the time in your stage definition they are moved to the next stage, and the effect is applied. After they pass the last stage of the affect the onremove function is called, the physics are reset, and the affect is removed.
Last edited by BrandonReese on Thu Jan 30, 2014 15:00, edited 1 time in total.
 

RohitM
Member
 
Posts: 45
Joined: Tue Jul 02, 2013 22:16

by RohitM » Sun Jan 19, 2014 04:31

Wow! Can you maybe do something similar to the Potions API mod with this, except with commands like minecraft /effect. Maybe also adding potions like the API does that run the effect command when used.
Last edited by RohitM on Sun Jan 19, 2014 04:31, edited 1 time in total.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Sun Jan 19, 2014 04:46

RohitM wrote:Wow! Can you maybe do something similar to the Potions API mod with this, except with commands like minecraft /effect. Maybe also adding potions like the API does that run the effect command when used.


There are chat commands I didn't go over:

/affectplayer <name> <affectid>
/removeaffect <name> <affectid>

You could setup potions. You would set up the affect and register the affect with the affects.registerAffect() function. Then create your potion item, and with the on_use function or whatever you just have to have affects.affectPlayer(<name>,<affectid>)

I am going to make a potions mod for my server and as a better example of how to use this.
 

RohitM
Member
 
Posts: 45
Joined: Tue Jul 02, 2013 22:16

by RohitM » Mon Jan 27, 2014 15:00

Ummmm, the only problem is, I don't know how to do that. The mods I edit I use preset lines of code(Like API) to register crafts. You would have to preset a code for registering potions for me to understand. PS. We want more potions on the server. Flying isn't enough :) Maybe regen, poison, instant health/air, maybe add the hud and hunger mod and make instant food or no food loss. Please add the hud mod though :)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Jan 27, 2014 18:03

Looks nice.


Common issue, even for native English speakers, the affects/effects split. Be aware of this.

Affect

This is a verb.

By killing Bob, I have affected their quality of life.

Effect

This is a noun. I added a special effect to my film.

The effects of completing the murder of Bob were:

^ I can delete this to make this topic tidy.

Also [Mod] :P
Last edited by rubenwardy on Mon Jan 27, 2014 18:11, edited 1 time in total.
 

RohitM
Member
 
Posts: 45
Joined: Tue Jul 02, 2013 22:16

by RohitM » Wed Jan 29, 2014 16:51

Ummmm download?
 

User avatar
Pitriss
Member
 
Posts: 253
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss

by Pitriss » Wed Jan 29, 2014 20:12

I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Thu Jan 30, 2014 15:01

rubenwardy wrote:Looks nice.


Common issue, even for native English speakers, the affects/effects split. Be aware of this.

Affect

This is a verb.

By killing Bob, I have affected their quality of life.

Effect

This is a noun. I added a special effect to my film.

The effects of completing the murder of Bob were:

^ I can delete this to make this topic tidy.

Also [Mod] :P


I went and read about affect and effect. I changed it in the topic but I'm not going to change it in the code :) Needless to say grammar wasn't a strong subject for me in school.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Thu Jan 30, 2014 15:02



Thanks, I can't believe I forgot the download link. It's in the first post now.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Thu Jan 30, 2014 15:17

Except that "effect" can also be used as a verb - this week's nasty weather has me snowed-in, which has effected a change in my usual monthly routine.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Thu Jan 30, 2014 15:28

VanessaE wrote:Except that "effect" can also be used as a verb - this week's nasty weather has me snowed-in, which has effected a change in my usual monthly routine.


Affect can also be a noun. The article I read said to sum it up, you could be an author/editor for your entire life and probably never come across a case where affect needs to be used in it's noun form. Stupid words.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu Jan 30, 2014 16:40

VanessaE wrote:Except that "effect" can also be used as a verb - this week's nasty weather has me snowed-in, which has effected a change in my usual monthly routine.


Affected would be better in that example. They actually made a word to deal with this: impact.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Thu Jan 30, 2014 22:54

BrandonReese wrote:Affect can also be a noun. The article I read said to sum it up, you could be an author/editor for your entire life and probably never come across a case where affect needs to be used in it's noun form. Stupid words.

Language is sometimes very strange. In German, "im Affekt (handeln)" means "(to act) in the heat of the moment", and it's common when trying to decide if someone can be hold fully responsible for his actions or not. The meaning of the german word seems to be similar to the noun in English, although we don't use the noun alone in normal speach either.
A list of my mods can be found here.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 14 guests

cron