ABM running only on blocks under Y=(some number here)?

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

ABM running only on blocks under Y=(some number here)?

by SegFault22 » Thu Oct 11, 2012 22:44

Hey all, I am working on another mod. This mod requires that an ABM running in it only affects blocks below Y=13. I have searched everywhere, and can find nothing about how to make this work.
Any ideas?
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 

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

by VanessaE » Thu Oct 11, 2012 23:02

Inside your ABM code, in the code where you take some action, add an explicit check there for pos.y < 14 just ahead of doing whatever action you had planned.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

by SegFault22 » Thu Oct 11, 2012 23:14

I don't mean to ask so many questions, but, what's an ''explicit check'' - and can you give an example to that dude who's working on the Minetest Online API, for future reference?
Thank you for your help.
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 

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

by VanessaE » Fri Oct 12, 2012 00:04

If you have some code inside your ABM that actually does something, for example adding a new node somewhere, like this:

minetest.env:add_node(pos, {name = "widgets:fooblock"})

...then you would wrap it in a simple check routine, so your ABM might look something like this:

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
minetest.register_abm({
     nodenames = { list of nodenames to operate on },
     ...
     ... other ABM settings here...
     ...
     action = function(pos, node, active_object_count, active_object_count_wider)
          if pos.y < 14 then
               minetest.env:add_node(pos, {name = "widgets:fooblock"})
          end
     end
})


The idea is to check the Y position of the node the ABM is about to operate on before you actually DO anything to that node. If Y < 14 then do whatever you were gonna do, otherwise do nothing.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

by SegFault22 » Fri Oct 12, 2012 00:24

Ah, thank you :D
Now I can finish the crab mod and release v1.0...
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron