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

BadWolf
Member
 
Posts: 42
Joined: Thu Jun 27, 2013 17:27

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

by BadWolf » Mon Jul 15, 2013 05:47

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
Last edited by BadWolf on Mon Jul 15, 2013 06:02, edited 1 time in total.
 

User avatar
mauvebic
Member
 
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Mon Jul 15, 2013 06:28

there's no such global function as set. Either you define a set() function, or it's a member function, as in object:set().
"Fuck the hat." - Paulie Gualtieri
 

BadWolf
Member
 
Posts: 42
Joined: Thu Jun 27, 2013 17:27

by BadWolf » Mon Jul 15, 2013 06:37

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
 

BadWolf
Member
 
Posts: 42
Joined: Thu Jun 27, 2013 17:27

by BadWolf » Mon Jul 15, 2013 07:27

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.
 

User avatar
webdesigner97
Member
 
Posts: 1307
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97

by webdesigner97 » Mon Jul 15, 2013 07:58

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()
 

BadWolf
Member
 
Posts: 42
Joined: Thu Jun 27, 2013 17:27

by BadWolf » Mon Jul 15, 2013 08:08

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
Last edited by BadWolf on Mon Jul 15, 2013 08:13, edited 1 time in total.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 6 guests

cron