[Mod] Xray [xray] - need some help

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

[Mod] Xray [xray] - need some help

by InfinityProject » Wed Sep 26, 2012 01:08

Hey guys I have developed a mod that works a lot like the famous Minecraft mod. On activation all stone will become invisible, making it easy to see the important stuff like mese and iron.
V0.3 adds a xray priv to be able to use the commands.
/off is currently not working so the only way to change back to normal stone is to edit the abm. Only use on test worlds until noted.

Note: The transformation may take a while. This is a beta version and will be sped up hopefully without lag in the future.

Screenshot:

[img=xray]https://dl.dropbox.com/u/82668184/screenshot_788007.png[/img]

How to use:
/xray on
Turns stone invisible.

/xray off
Turns stone back to normal.

Depends: default
Download latest: https://dl.dropbox.com/u/82668184/xray%200.3.zip
Download V0.1: https://dl.dropbox.com/u/82668184/xray%200.1.zip
Download V0.2: https://dl.dropbox.com/u/82668184/xray%200.2.zip
Download V0.3: https://dl.dropbox.com/u/82668184/xray%200.3.zip
License: Code GPLv3 Textures WTFPL
Last edited by InfinityProject on Mon Oct 01, 2012 02:43, edited 1 time in total.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 01:24

nice idea what if a player is standing nearby without x-ray? will they still see the invisible nodes?
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Wed Sep 26, 2012 02:07

The way this works is the server replaces all stone nodes with my invisible stone through an abm. So yes, on a server anyone can see through stone when activated. Right now the priv needed is 'shout' but I may change it to 'server; so that server admins can use it on servers.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Wed Sep 26, 2012 03:53

Noticed an error in code. /xray off would never work. Fixed.
 

User avatar
Calinou
Moderator
 
Posts: 3156
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Wed Sep 26, 2012 05:38

Suggestions:
- require "xray" privilege
- make stone transform into a pointable, waklable node with "airlike" drawtype
- make /xray a toggle command for simplicity's sake, if possible?
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Wed Sep 26, 2012 14:24

Calinou wrote:Suggestions:
- require "xray" privilege
- make stone transform into a pointable, waklable node with "airlike" drawtype
- make /xray a toggle command for simplicity's sake, if possible?


I did 2 of the above. I'm trying to get it to work with one command.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Wed Sep 26, 2012 18:00

The xray off command isn't working. I know the abm is working because when xray is on and you place stone, it automatically turns into xray stone. When xray is off stone placed stays normal stone. Some help?
I divided it into 2 abms to see if it would work but it still didn't. Here's code.
Code: Select all
minetest.register_abm({
        nodenames = {"default:stone", "xray:stone"},
        interval = 0,
        chance = 1,   
       
        action = function(pos, node, active_object_count, active_object_count_wider)
          if XRAY_MODE == 1 then
              if node.name == "default:stone" then
                  minetest.env:add_node(pos,{name="xray:stone"})
                end
            end
        end
    end
})

minetest.register_abm({
        nodenames = {"xray:stone", "default:stone"},
        interval = 0,
        chance = 1,   
       
        action = function(pos, node, active_object_count, active_object_count_wider)
          if XRAY_MODE == 2 then
              if node.name == "xray:stone" then
                  minetest.env:add_node(pos,{name="default:stone"})
                end
            end
        end
    end
})
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 19:52

it works for me, i tidied the code a little, and added some output so i can see what its doing, but it worked as you pasted it (except for an extra "end" you have)

Code: Select all
minetest.register_abm({
    nodenames = {"default:stone"},
    interval = 0,
    chance = 1,   
    action = function(pos, node)
      if XRAY_MODE == 1 then
          if node.name == "default:stone" then
            print("turning default:stone to xray:stone at "..dump(pos))
              minetest.env:add_node(pos,{name="xray:stone"})
            end
        end
    end
})

minetest.register_abm({
    nodenames = {"xray:stone"},
    interval = 0,
    chance = 1,   
    action = function(pos, node)
      if XRAY_MODE == 2 then
          if node.name == "xray:stone" then
            print("turning xray:stone to default:stone at "..dump(pos))
              minetest.env:add_node(pos,{name="default:stone"})
            end
        end
    end
})
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 20:45

try this, it uses register_globalstep() instead of an ABM. this means it only effects the player who has xray, and it has a range that you can configure. the nodes change back to stone on their own once the player is out of range.

seems to work really nicely, very responsive, very little lag.

edit: got sick of repasting code here, pushed to github:
https://github.com/cornernote/minetest-xray
Last edited by cornernote on Wed Sep 26, 2012 21:17, edited 1 time in total.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Wed Sep 26, 2012 23:53

I honestly don't like the idea of it changing back in forth when in and out of range. But I do love the idea of using it for a single person using xray.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Sep 27, 2012 00:21

no worries, take what you like from the code, look forward to seeing the end result
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Sep 27, 2012 13:14

i edited the xray:stone to be a nodebox (still fill size), but it ment that it actually turned invisible, instead of being an invisible "portal" that can see through to the sky on the other side.

when you set the range to 5-10, its actually really responsive. (i left the auto-convert back to stone in mine)
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Fri Sep 28, 2012 00:03

Looks good. Need help. I fixed /xray off for me but now the two commands counteract each other. If both commands have been activated before the stone will flash back and forth between normal and invisible. I know I need to use nil, but I am still new to coding and don't know how to use it. Can someone help?
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Fri Sep 28, 2012 00:50

If both commands are activated, what would you like to happen?
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Fri Sep 28, 2012 00:51

I want only one to work at a time, like when xray(off) is activated xray(on) is deactivated.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Fri Sep 28, 2012 01:07

Can you shoe me your current code? Or are you using 0.3 version?
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Fri Sep 28, 2012 01:08

The only thing I've changed is xray(1) to xray(on) and xray(2) to xray(off).
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Fri Sep 28, 2012 01:45

I cant see how it's running both things if you have this:

Code: Select all
minetest.register_abm({
        nodenames = {"default:stone", "xray:stone"},
        interval = 0,
        chance = 4,   
        action = function(pos, node, active_object_count, active_object_count_wider)
          if XRAY_MODE == 1 then                                                        --<< means it should only do this...
              if node.name == "default:stone" then
                  minetest.env:add_node(pos,{name="xray:stone"})
          elseif XRAY_MODE == 2 then                                                   --<< OR this
              if node.name == "xray:stone" then
                  minetest.env:add_node(pos,{name="xray:stone"})
   
                end
            end
        end
    end
})


Also, you should use minetest.register_globalstep() instead of an abm. it fixes the lag issue.

If you don't want them to change back on their own, then remove the call to xray.restore(), and use an ABM to restore the nodes when the xray is off.
 

User avatar
MasterGollum
Member
 
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Fri Sep 28, 2012 14:42

I was developing a stone layer generator and this mod was just cool to find the layers I was creating, but it didn't work fine to me. Even if the stones are transparent, many nodes are not visible until the invisible stone is removed. When I turned the xray off the invisible stones, kept being invisibles, so I messed up a huge area of my map :) luckily it was a world I was using for test purposes ;)
 

irksomeduck
Member
 
Posts: 224
Joined: Tue Aug 28, 2012 21:45
Location: Littleroot town, Hoenn region

by irksomeduck » Fri Sep 28, 2012 18:46

Thankyou so much
I love exploring minetest worlds :D
If you have a good seed let me know
--------------------------------------------------
My world/house pack- http://minetest.net/forum/viewtopic.php?id=3066
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Sat Sep 29, 2012 00:50

MasterGollum wrote:I was developing a stone layer generator and this mod was just cool to find the layers I was creating, but it didn't work fine to me. Even if the stones are transparent, many nodes are not visible until the invisible stone is removed. When I turned the xray off the invisible stones, kept being invisibles, so I messed up a huge area of my map :) luckily it was a world I was using for test purposes ;)



My version fixes that:
https://github.com/cornernote/minetest-xray

Try that until InfinityProject releases his next version.
 

User avatar
MasterGollum
Member
 
Posts: 79
Joined: Thu Sep 27, 2012 14:48

by MasterGollum » Sat Sep 29, 2012 01:03

cornernote wrote:My version fixes that:
https://github.com/cornernote/minetest-xray

Try that until InfinityProject releases his next version.


Wow cool, thank you so much
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Sat Sep 29, 2012 16:55

You were obviously using an older version for the not able to see through stone glitch. The /off is glitchy and I'm working on a way to fix it.
 

irksomeduck
Member
 
Posts: 224
Joined: Tue Aug 28, 2012 21:45
Location: Littleroot town, Hoenn region

by irksomeduck » Sat Sep 29, 2012 19:19

Doesn't work... I mean it runs and loads it, understands the commands, but just doesn't work. Nothing goes invisible.
I love exploring minetest worlds :D
If you have a good seed let me know
--------------------------------------------------
My world/house pack- http://minetest.net/forum/viewtopic.php?id=3066
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Sun Sep 30, 2012 14:53

irksomeduck wrote:Doesn't work... I mean it runs and loads it, understands the commands, but just doesn't work. Nothing goes invisible.


Are you using mine or cornernote's version? The only problem with mine is the /off. His doesn't work for me; it just creates lag.
 

Next

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 24 guests