Porting Java-based mods to Lua
#2
In an attempt to test if this theory is indeed possible, I wrote the following short plugin to do one thing: Create a JavaVM and print "Hello, world!" to the screen.

Note: lua5.1.dll has been replaced with jnlua5.1.dll and renamed to access the jnlua functions.

function Initialize(Plugin)
	Plugin:SetName("JavaVM")
	Plugin:SetVersion(1)
	
	-- Hooks
	cPluginManager.AddHook(cPluginManager.HOOK_WORLD_STARTED, initiatejavavm)
  
  function initiatejavavm(javavm)
    javavm = require("javavm")
    javavm.create("-Djava.class.path=jnlua-0.9.6.jar")
    System = java.require("java.lang.System")
    System.out:println("Hello, world!")
    javavm.destroy()
    end
  
	PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
	
	-- Command Bindings

	LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
	return true
end

function OnDisable()
	LOG(PLUGIN:GetName() .. " is shutting down...")
end

This plugin gives the following error:

Warn [22:40:00] cPluginManager:AddHook(): bad parameters. Expected
HOOK_TYPE and CallbackFunction, got number, nil, no value. Hook not added.
Warn [22:40:00] Stack trace:
Warn [22:40:00] [C](-1): AddHook
Warn [22:40:00] Plugins/JavaVM/main.lua(8): (no name)
Warn [22:40:00] Stack trace end
[22:40:00] Initialised JavaVM v.1

Since I am lost as to why the AddHook call is not recognizing the CallbackFunction, can someone please point it out to me?
Reply
Thanks given by:


Messages In This Thread
Porting Java-based mods to Lua - by Atro - 01-13-2015, 01:22 PM
RE: Porting Java-based mods to Lua - by Atro - 01-13-2015, 02:46 PM
RE: Porting Java-based mods to Lua - by Atro - 01-13-2015, 02:59 PM
RE: Porting Java-based mods to Lua - by Howaner - 01-13-2015, 04:14 PM
RE: Porting Java-based mods to Lua - by xoft - 01-13-2015, 05:05 PM
RE: Porting Java-based mods to Lua - by Atro - 01-13-2015, 05:13 PM
RE: Porting Java-based mods to Lua - by xoft - 01-13-2015, 06:14 PM
RE: Porting Java-based mods to Lua - by Defkil - 02-20-2015, 03:03 AM
RE: Porting Java-based mods to Lua - by LO1ZB - 02-20-2015, 03:10 AM
RE: Porting Java-based mods to Lua - by worktycho - 02-20-2015, 03:57 AM



Users browsing this thread: 1 Guest(s)