Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
10-14-2013, 06:28 AM
(This post was last modified: 10-14-2013, 06:29 AM by xoft.)
Depends, mostly on what the function params and return values are. If they're simple, like strings, numbers or class objects, then it's simple; if it's objects that Lua expresses as tables or callbacks, then it's a nightmare
For the simple case, have a look at BlockID.h / .cpp, function BlockStringToType() . It is declared in the header inside a // tolua_begin and //tolua_end comment blocks, so the tolua parser will export it automagically. Then the function body is simply in BlockID.cpp as normal code. That's all there is - just wrapping the declaration in the tolua_* comments.
For the difficult case, you need to implement your functions and then write something colossal like there is in ManualBindings.cpp - those are the bindings for the difficult functions. You can try doing that, or simply ask, if it's good enough an idea, someone else here might write it for you
Posts: 1,469
Threads: 57
Joined: Jul 2012
Thanks: 66
Given 127 thank(s) in 108 post(s)
It seems quite easy, thanks for the instructions!
Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
10-16-2013, 06:37 AM
(This post was last modified: 10-16-2013, 06:37 AM by tigerw.)
Bit of an emergency, could someone merge this code in please (can't do it myself *cough* xoft *cough*)
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Cow.h"
#include "../Entities/Player.h"
cCow::cCow(void) :
super("Cow", 92, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
{
}
void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
}
void cCow::OnRightClicked(cPlayer & a_Player)
{
if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BUCKET)
{
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
a_Player.GetInventory().AddItem(E_ITEM_MILK);
}
}
}
Tonibm19 forgot a semicolon and an include, so now it doesn't compile.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
I ain't touching the C++ code until all the hooks are documented. There aren't that many left, you know...
Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
10-16-2013, 08:00 AM
(This post was last modified: 10-16-2013, 08:21 AM by tigerw.)
(10-16-2013, 06:47 AM)xoft Wrote: I ain't touching the C++ code until all the hooks are documented. There aren't that many left, you know...
Can I work on APIDump CSS + indentation? The current generated HTML is nigh on unreadable
Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
10-16-2013, 09:42 AM
(This post was last modified: 10-16-2013, 09:42 AM by tigerw.)
I found a loophole in your statement!
Can you please review mah APIDump PR?
Posts: 1,162
Threads: 68
Joined: Mar 2013
Thanks: 245
Given 125 thank(s) in 100 post(s)
10-16-2013, 03:05 PM
(This post was last modified: 10-16-2013, 03:09 PM by tonibm19.)
And also take a look/merge mob spawning and my PR .
Hope you finish all hooks today.
(10-16-2013, 06:37 AM)tigerw Wrote: Tonibm19 forgot a semicolon and an include, so now it doesn't compile. Oh sorry I don't saw that. I'm not starting well to help MCServer .
Then, why bearbin server compiled my PR well?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
The generated HTML doesn't need to be readable, and the indentation makes it larger (bad when served online), but whatever, it's in.
Posts: 1,162
Threads: 68
Joined: Mar 2013
Thanks: 245
Given 125 thank(s) in 100 post(s)
Oh now I saw. Compile fails, but when I send PR it said Good to merge.
Posts: 1,469
Threads: 57
Joined: Jul 2012
Thanks: 66
Given 127 thank(s) in 108 post(s)
I will try and fix the buildserver being derpy
|