Mythruna

Modder's Workbench => Scripting => Topic started by: randomprofile on November 29, 2011, 08:10:51 AM



Title: [Groovy Script Issue]Error handling event:EntityEvent
Post by: randomprofile on November 29, 2011, 08:10:51 AM
I'm trying to write a test script in Groovy and I'm getting some problems with this script.

Code:
import mythruna.*;
import mythruna.es.*;
import mythruna.script.*;

import java.util.Random;

on( [playerJoined] ) {
    type, event ->

     showPrompt( """\
                Ender's Script Test :D
                """
                ) {
        option( text:"KTHXBYE" );                
    }
}    

I think I just failed at the syntax or didn't include a needed library..., and if at all possible paul could you PM the whole Help code (The one used in game where players press F1 for help) it would be very much appreciated.

~~~~[EDIT]~~~~
Forgot to include error log :P

Code:
2011-11-29 06:43:40,974 ERROR [mythruna.event.EventDispatcher] Error handling event:EntityEvent[mythruna.event.PlayerContext@125ee71] for type:PlayerJoined  in handler:Script1$2@13cb2c6
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.showPrompt() is applicable for argument types: (java.lang.String, Script5$_run_closure1_closure2) values: [                Ender's Script Test :D
                , Script5$_run_closure1_closure2@da6d09]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:389)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.access$000(GroovyScriptEngineImpl.java:72)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$2.invokeMethod(GroovyScriptEngineImpl.java:301)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$2.invokeMethod(GroovyScriptEngineImpl.java:290)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at groovy.lang.Script.invokeMethod(Script.java:78)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:407)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:346)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
at Script5$_run_closure1.doCall(Script5.groovy:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script1$2.newEvent(Script1.groovy:75)
at mythruna.event.EventDispatcher.publishEvent(EventDispatcher.java:58)
at mythruna.net.LocalGameClient.start(LocalGameClient.java:148)
at mythruna.MainMenuState.startSinglePlayer(MainMenuState.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at de.lessvoid.nifty.NiftyMethodInvoker.callMethod(NiftyMethodInvoker.java:145)
at de.lessvoid.nifty.NiftyMethodInvoker.performInvoke(NiftyMethodInvoker.java:104)
at de.lessvoid.nifty.Nifty$DelayedMethodInvoke.perform(Nifty.java:1169)
at de.lessvoid.nifty.Nifty.invokeMethods(Nifty.java:1147)
at de.lessvoid.nifty.Nifty.handleDynamicElements(Nifty.java:305)
at de.lessvoid.nifty.Nifty.access$1400(Nifty.java:73)
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(Nifty.java:1364)
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(Nifty.java:1322)
at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:123)
at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:192)
at de.lessvoid.nifty.Nifty.update(Nifty.java:241)
at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:92)
at com.jme3.input.InputManager.processQueue(InputManager.java:778)
at com.jme3.input.InputManager.update(InputManager.java:842)
at com.jme3.app.Application.update(Application.java:596)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)
at java.lang.Thread.run(Unknown Source)


Title: Re: [Groovy Script Issue]Error handling event:EntityEvent
Post by: pspeed on November 29, 2011, 10:04:13 AM
The dialog scripts and the other scripts are a separate "format" sort of.  The dialog scripts have special APIs available to them that makes it easier to construct the dialog objects.

Usually, you would have a foo.dlg.groovy file in mods/dialog and then in your regular event script you'd call:

dialogs.startDialog( player, "foo" );

Note: I haven't tested that starting a dialog during player join will actually work but in theory it should.

Other than that, your dialog definition looks ok... if it were in a dlg.groovy file.

Here is a reduced version of the help dialog for reference:
Code:
// Predefines an option that can be easily referred to with an option()
defOption( id:"map", text:"How do I see the map?" ) {

    showPrompt( """\
                The in game overland map can be accessed using one of the
                following methods:<br>
                - press TAB and click 'Map'<br>
                - press 'm'
                """
                ) {
        option( text:"Done" );               
    }
}

// Initiates the main prompt for this dialog file
showPrompt( """\
Welcome to Mythruna's in game help.
Please select a help option from below.
"""
) {
    option( "map" )
    option( text:"Never mind" )
}


Hope that helps.