Presentation and help request

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

Presentation and help request

by OmniStudent » Sat Nov 03, 2012 06:51

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
 

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

by cornernote » Sat Nov 03, 2012 07:54

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.
 

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

by cornernote » Sat Nov 03, 2012 07:56

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. =)
 

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

by OmniStudent » Sat Nov 03, 2012 15:23

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!
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Sat Nov 03, 2012 17:06

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.
A list of my mods can be found here.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Sun Nov 04, 2012 12:58

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
 

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

by OmniStudent » Sun Nov 04, 2012 18:50

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


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 2 guests

cron