Page 1 of 1

Presentation and help request

PostPosted: Sat Nov 03, 2012 06:51
by OmniStudent
Hello everyone!

I'll be messing around with the code as my christmas project, but haven't done any c programming in ten years. I'll probably be completely useless for any development, but at least you guys who actually do something have admirers in the likes of me.

For a nice quick start, I want to insert a new key press command and have the server react to it.
Can anyone give me some hints of where in the code to insert this?

Best Regards,

OmniStudent

PostPosted: Sat Nov 03, 2012 07:54
by cornernote
I don't know how to do it, but I would start like this...

look in minetest.conf.example and find the keymapping strings:
https://github.com/celeron55/minetest/blob/master/minetest.conf.example

I'll use keymap_chat because that causes a popup (as opposed to keymap_forward which moves the player).

Download the src, and search for "keymap_chat". You will find it here:
https://github.com/celeron55/minetest/blob/master/src/game.cpp#L1544

From here you are on your own to make it do whatever it is you want it to do. Main thing is, look at other source code. Most of what you want to achieve is already coded, you just have to copy/paste/tweak it to work how you like.

PostPosted: Sat Nov 03, 2012 07:56
by cornernote
While you are in there doing c++ stuff, if you can manage to write some code that allows Lua mods to force open a formspec/inventory, would be a very welcomed addition. =)

PostPosted: Sat Nov 03, 2012 15:23
by OmniStudent
cornernote wrote:I don't know how to do it, but I would start like this...

look in minetest.conf.example and find the keymapping strings:
https://github.com/celeron55/minetest/blob/master/minetest.conf.example

I'll use keymap_chat because that causes a popup (as opposed to keymap_forward which moves the player).

Download the src, and search for "keymap_chat". You will find it here:
https://github.com/celeron55/minetest/blob/master/src/game.cpp#L1544

From here you are on your own to make it do whatever it is you want it to do. Main thing is, look at other source code. Most of what you want to achieve is already coded, you just have to copy/paste/tweak it to work how you like.


Thankyou!

PostPosted: Sat Nov 03, 2012 17:06
by Sokomine
cornernote wrote:While you are in there doing c++ stuff, if you can manage to write some code that allows Lua mods to force open a formspec/inventory, would be a very welcomed addition. =)

Yes, that would be great. I wanted to present diffrent "Menus" to players depending on weather they are the owner or an authorised user of a specific object (chest, door, sign, ...) and was a bit disappointed when I found out that there is no lua hook to react to a player right-clicking on a (fixed) node. Thus, I have to present the same interface to all players.

PostPosted: Sun Nov 04, 2012 12:58
by rubenwardy
Find the class that extends irr:IEventHandler. I think it is cGame.

Find the onEvent() function.

In the event function, find the bit of code that handles key presses

PostPosted: Sun Nov 04, 2012 18:50
by OmniStudent
Thanks, I think I've got this down now.
Anyone know what the main loop for the world is (the one that times stuff happening inside the game world)?