Page 1 of 1

set timer problem"lua error ... attempt to call global 'set' a nil..."

PostPosted: Mon Jul 15, 2013 05:47
by BadWolf
Hi, I'm working on a mod in lieu of a good mapping mod or 3rd person view. The goal of the mod is to give you a quick top down view of where you are currently at. How you would use it: place the lookout block, and right-click it, after 5 or 10 seconds or if you right click again your game will resume.

here's the WIP code:
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
--License "Bovvered" Like Wtfpl but with more catherine tate. JK i'll think of a license later


minetest.register_node("lookout:lookout_stone", {
    description = "a portable looking tool",
    tile_images = {"moreblocks_stonebrick.png"}, --place holder image
    is_ground_content = true,
    groups = {cracky=3},
    sounds = default.node_sound_stone_defaults(),
    driver = nil,

    on_timer = function(pos, elapsed)
            clicker = minetest.env.get_player_by_name(driver.get_player_name())           
            driver = nil
            clicker:set_physics_override(1, 1, 1)
            clicker:set_look_pitch(0)
            clicker:setpos(pos)
        end,   

    on_rightclick = function(pos, node, clicker)
            if not clicker:is_player() then
                return
            end
           
            if driver and clicker == driver then
                driver = nil
                clicker:set_physics_override(1, 1, 1)
                clicker:set_look_pitch(0)
                clicker:setpos(pos)
            elseif not driver then
                driver = clicker
                pos.y = pos.y + 5
                clicker:set_physics_override(0, 0, 0)
                clicker:set_look_pitch(math.pi*1)
                clicker:setpos(pos)
                set(5, 0)
            end
        end
})


in line 36, I have tried "set(5,0)" "node.set(5,0)" "self.set(5,0)" "node:set(5, 0)" "start(5)" etc...

and I'm still getting this error message: attempt to call global 'set' (a nil value)

when as I understand the documentation it should be calling the on_timer method



Minetest 0.4.7... Ubuntu 13.04 running LXDE desktop

PostPosted: Mon Jul 15, 2013 06:28
by mauvebic
there's no such global function as set. Either you define a set() function, or it's a member function, as in object:set().

PostPosted: Mon Jul 15, 2013 06:37
by BadWolf
Thank you for that quick reply Mauvebic. According to my understanding of this document: http://dev.minetest.net/NodeTimerRef

"set()" is a method of the node

PostPosted: Mon Jul 15, 2013 07:27
by BadWolf
Ignoring this possible bug. I have found a solution by converting it from a node into a tool, and just using the 'use' function with a toggle variable it works pretty nicely. It's not finished yet,I'd like to check for ceiling heighth and go to the closest possible point without clipping, and It'd be cool to put a player model on the ground beneath.

PostPosted: Mon Jul 15, 2013 07:58
by webdesigner97
BadWolf wrote:Thank you for that quick reply Mauvebic. According to my understanding of this document: http://dev.minetest.net/NodeTimerRef

"set()" is a method of the node

No. It's
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.get_node_time(pos):set()

PostPosted: Mon Jul 15, 2013 08:08
by BadWolf
oh, thanks, I guess I misread that page....


I wish the set_physics_override worked better. sometimes it seems like you're slowly falling when you set it gravity to 0, sometimes it stops your velocity of movements, sometimes that velocity carries over