[Mod] Xray [xray] - need some help

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

by cornernote » Tue Oct 09, 2012 00:59

does this work:
https://gist.github.com/3855913

I just removed "and XRAY_OFF ~= nil" and "and XRAY_ON ~= nil". They were undefined variables, and not used. I also changed on and off to strings (by putting quotes around them). Otherwise they will be interpreted as variables containing nil.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52

by InfinityProject » Tue Oct 09, 2012 01:24

The reason why the ~= nil was in there was because I was trying 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
if
 XRAY_MODE == off
then
 XRAY_ON = nil and
 XRAY_OFF ~= nil
elseif
 XRAY_MODE == on
then
 XRAY_OFF = nil and
 XRAY_ON ~= nil
end


local function xray_on(func)
 XRAY_ON = func
end

local function xray_off(func)
 XRAY_OFF = func
end
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52

by InfinityProject » Tue Oct 09, 2012 01:29

Also that doesn't work either Cornernote. /xray off doesn't work at all with that.
 

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

by cornernote » Tue Oct 09, 2012 01:52

I removed "if XRAY_MODE == 'off' then" from the elseif, and just made it an else.

If XRAY_MODE is not "on", then it has to run the off stuff now.

same gist link
Last edited by cornernote on Tue Oct 09, 2012 01:52, edited 1 time in total.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52

by InfinityProject » Tue Oct 09, 2012 20:55

cornernote wrote:I removed "if XRAY_MODE == 'off' then" from the elseif, and just made it an else.

If XRAY_MODE is not "on", then it has to run the off stuff now.

same gist link


That isn't working either. You need xray(off) defined in the abm.

I know what to do to fix this, but not how to do it.
I need to find a way to make xray(off) nil while xray(on) is activated and vice versa.
 

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

by cornernote » Wed Oct 10, 2012 00:32

can you make a youtube video of the issue? i'm having trouble understanding what isnt working.
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52

by InfinityProject » Wed Oct 10, 2012 23:04

Try it yourself (don't have any recording software)
https://dl.dropbox.com/u/82668184/xray%20test.zip
 

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

by cornernote » Thu Oct 11, 2012 01:14

This works:
https://gist.github.com/3869515

There was a few issues. The 1st revision is yours, the next is a working version, and the third I tidied up all the tabs and spacing in the file.

Ok, the issues:

1)
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
if param == 'on' then xray(on)


This will not work as expected. You are passing a variable (on) which is a NIL value (because you never set it to anything). What you want to do is pass the string "on". 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
if param == 'on' then xray("on")



2)
I have no idea what all that XRAY_ON and XRAY_OFF was for. You don't need it. It's either on or off. Its not ON=1 and OFF=0 or ON=0 and OFF=1. Kepp it simple like this....
XRAY_MODE = "on" or "off".


3)
In your ABM it seemed you had an END that was out of place. It was really hard to see because your indents and new lines a little messy. I'll try to explain:

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
        action = function(pos, node, active_object_count, active_object_count_wider)
       
          if XRAY_MODE == on and XRAY_OFF == nil then        <-- OPEN IF1
              if node.name == "default:stone" then               <-- OPEN IF2
                  minetest.env:add_node(pos,{name="xray:stone"})
              elseif node.name == "default:gravel" then            <-- ELSE IF2
                  minetest.env:add_node(pos,{name="xray:gravel"})
                                                                                              <-- I think you need to END here
          elseif XRAY_MODE == off and XRAY_ON == nil then    <-- ELSE IF2 -- i think you need an END before this
              if node.name == "xray:stone" then                       
                  minetest.env:add_node(pos,{name="default:stone"})
              elseif node.name == "xray:gravel" then
                  minetest.env:add_node(pos,{name="default:gravel"})
                end
            end                                                                              <-- i moved this END upto the place it should be
        end
    end
Last edited by cornernote on Thu Oct 11, 2012 01:15, edited 1 time in total.
 

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

by cornernote » Thu Oct 11, 2012 01:19

Here is the ABM in your code with the indents cleaned up. This should help you to see the issue:

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 = {"default:stone", "xray:stone", "default:gravel", "xray:gravel"},
    interval = 0,
    chance = 1,   
    action = function(pos, node, active_object_count, active_object_count_wider)
        if XRAY_MODE == on and XRAY_OFF == nil then
            if node.name == "default:stone" then
                minetest.env:add_node(pos,{name="xray:stone"})
            elseif node.name == "default:gravel" then
                minetest.env:add_node(pos,{name="xray:gravel"})
            elseif XRAY_MODE == off and XRAY_ON == nil then
                if node.name == "xray:stone" then
                    minetest.env:add_node(pos,{name="default:stone"})
                elseif node.name == "xray:gravel" then
                    minetest.env:add_node(pos,{name="default:gravel"})
                end
            end
        end
    end
})
 

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

by cornernote » Thu Oct 11, 2012 01:25

was just thinking about the reason for XRAY_ON and XRAY_OFF ...

Do you want a 3rd state where its neither on, nor off?

If so, set xray("inactive"), and then add a new condition to the ABM so that if its XRAY_MODE=="inactive" it does nothing.
 

madarexxx
Member
 
Posts: 144
Joined: Sat Aug 04, 2012 06:49

by madarexxx » Tue Nov 13, 2012 15:21

Need help. I turned xray on, look and tried to switch it off. Stone is still invisible, and my mine is unwalkable. Can i switch it off manually? For example with world edit (i don't know how to replace all nodes in some radius of selected point :( )
Sorry for my bad English, please help me learn it - correct my worst mistakes :)
 

User avatar
InfinityProject
Member
 
Posts: 1009
Joined: Sat Mar 17, 2012 00:52

by InfinityProject » Tue Nov 13, 2012 22:40

The mod was never finished. /off had never really worked. I think I found a way to finish it though.
 

madarexxx
Member
 
Posts: 144
Joined: Sat Aug 04, 2012 06:49

by madarexxx » Fri Nov 16, 2012 15:37

i've made it working. Sorry for no comments, but i'm tired, and want to sleep. May be i'll update it with comments tomorrow.
There are some changes:
1) It depends on worldedit now
2) /xray off and /xray on are affecting only 100*100*100 area
3) I've added new command - /xray globally_off, but IT IS FOR EXTREME TIMES! IT AFFECTS 1024*1024*1024 AREA!!!! IT IS F###ING SLOW!

https://www.dropbox.com/s/eor65i9t4t5w8g2/xray.tar.gz

P.S. Please test and comment!
Sorry for my bad English, please help me learn it - correct my worst mistakes :)
 

Previous

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 32 guests

cron