Mythruna
December 07, 2021, 08:06:03 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / General Discussion / Re: Looking for Server-Development team. on: May 20, 2013, 08:20:24 AM
What is the overall concept of the server? Will it be Fantasy? And what kind of stuff do you want to program for it?
2  Modder's Workbench / Scripting / Re: Battle Mod v0.1 on: April 20, 2013, 12:58:56 PM
Sorry that I'm ontopic... Cheesy
Nice mod, makes me think about doing some scripting myself again... Wink
Just one little thing about your code:
Code:
if(hp > 0) {
hp = hp-takeaway;

if(hp == 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}

}
is probably better done this way if anyone is going to use and extend this:
Code:
hp = hp-takeaway;

if(hp <= 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}
Else you could come to a point wher the hp are below zero, but never get noticed as won.
3  General Category / General Discussion / Re: Happy Birthday Mythruna ! on: February 02, 2012, 02:07:12 PM
Happy Birthday Mythruna!
I just can say what already has been said:
Pretty nice work! I really can't wait for the final game to release. It is already so nice, but what is going to come are so much more nice things - Even while it is great yet, it will be much greater! Wink

And, one point to the map generating:
I think it would be nice, if the map's were a bit more... bigger. I don't mean the actual size of the map (it is unlimited, isn't it?), but the size of the structure of the landscape.
If the islands were bigger, then there could be more difference between different landscapes. The way it is, it is just all green landscape with some hills and trees everywhere.
But it would be more interesting (I think), if there were different types of landscape, so for example desert, wood, strand, mountains, meadows...

So the islands should be in my opinion more like continents. Or at least some of them, small islands are nice, too.
4  Modder's Workbench / Scripting / Re: [Groovy Error] Dialogs->File not Found on: January 23, 2012, 02:49:49 PM
Now it works.
The problem was that I thought that the directory should be ./dialogS.
Thanks for the fast help!
5  Modder's Workbench / Scripting / [Groovy Error] Dialogs->File not Found on: January 23, 2012, 02:31:36 PM
I'm just trying to build up a little dialog, but I get an error when I invoke it.
I start it with
Code:
dialogs.startDialog( player, "foo" );
The dialog file is located at ./dialogs/foo.dlg.groovy
I run the game as server.

The errormessage:
Code:
(com.jme3.network.HostedConnection,mythruna.net.msg.ConsoleMessage)
at mythruna.server.AbstractMessageDelegator.messageReceived(AbstractMessageDelegator.java:195)
at com.jme3.network.base.MessageListenerRegistry.messageReceived(MessageListenerRegistry.java:74)
at com.jme3.network.base.DefaultServer.dispatch(DefaultServer.java:284)
at com.jme3.network.base.DefaultServer$Redispatch.messageReceived(DefaultServer.java:565)
at com.jme3.network.base.DefaultServer$Redispatch.messageReceived(DefaultServer.java:561)
at com.jme3.network.base.KernelAdapter.dispatch(KernelAdapter.java:179)
at com.jme3.network.base.KernelAdapter.createAndDispatch(KernelAdapter.java:233)
at com.jme3.network.base.KernelAdapter.run(KernelAdapter.java:276)
Caused by: java.lang.RuntimeException: File not found for:foo.dlg.groovy
at mythruna.script.DialogManager.readScript(DialogManager.java:110)
at mythruna.script.DialogManager.startDialog(DialogManager.java:148)
at mythruna.script.DialogManager$startDialog.call(Unknown Source)
at Script8$_run_closure4_closure7.doCall(Script8.groovy:81)
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 groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.call(Closure.java:418)
at mythruna.script.ShellScript.execute(ShellScript.java:38)
at org.progeeks.tool.console.ShellCommandProcessor.execute(ShellCommandProcessor.java:86)
at org.progeeks.tool.console.Shell.executeCommand(Shell.java:251)
at org.progeeks.tool.console.Shell.execute(Shell.java:232)
at mythruna.server.GameServer$LoggedInMessageHandler.console(GameServer.java:933)
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 mythruna.server.AbstractMessageDelegator.messageReceived(AbstractMessageDelegator.java:187)
... 7 more

Do you know what's the problem, paul?
I already tried putting the dialog-file to the main or the scripts directory, but it doesn't work...
6  Modder's Workbench / Scripting / extended_teleport.init.groovy on: January 23, 2012, 01:37:29 PM
I've written another script.
(I didn't want to make a new thread, so i just changed topic   Wink)It allows you to easily teleport to defined points and to define these points.
It has no privilege management in it, so anyone could add points. With a big server and many points it would be probably useful to manage the points a bit better, the way it is now it can just show you all points.
Usage:
~addTP New Point - adds a Point with the name "New Point"
~teleports - listens all existing points
~teleport 1 - teleports you to the point with this number.

The points are saved in an extern file, named "teleport.data" in the following format:
id,name,x,y,z

If you decide to edit this file(to delete points for example, that's not (yet?) possible in game), you should pay attention that the id of the last entry is the highest id. The ID's are only in this way managed, that the next ID is the last ID + 1. So if the last id is 2 but you already have a entry with ID 3, and you add a Point, there will be two entrys with ID 3. And this could make it quite difficult to teleport to the second entry with this ID^^

So, here is the script:
Code:
import com.jme3.math.*;

import mythruna.Coordinates;
import mythruna.db.*;
class port {
int x = 0;
int y = 0;
int z = 0;
int id = 0;
String name = "";
}
int nxtId = 3
ports = []


f = new File('teleport.data')
if(f.exists()){
f.eachLine { line ->
  data = line.split(',')
  newPort = new port();
  newPort.id = data[0].toInteger();
  newPort.name = data[1]
  newPort.x = data[2].toInteger();
  newPort.y = data[3].toInteger();
  newPort.z = data[4].toInteger();
  ports.add([id:data[0], name:data[1], x:data[2], y:data[3], z:data[4]])
  nxtId = data[0].toInteger() + 1
}    
}else{
  ports = [
            [id:'1', name:'Spawn',x:'512', y:'512', z:'80']
  ]    
  ports.each {  
    def row = [it.id, it.name, it.x, it.y, it.z]
    f.append(row.join(','))  
    f.append('\n')    
}
}

  
println("Existing Teleport-ports:")
ports.each {  
    def row = [it.id, it.name, it.x, it.y, it.z]
    println(row.join(','))  
}
on( [playerConnected] ) {
    type, event ->
        
    conn = connection;
    p = conn.getAttribute( "player" );

    addShellCommand( shell, "addTP", "Adds a Teleport-Point", null ) {
        String[] parms = it.split( " " );
        if( parms.length > 0 ) {
        pos = getLocation( conn );
            ports.add([id:nxtId, name:it, x:pos.x.toInteger(), y:pos.y.toInteger(), z:pos.z.toInteger()])
            def row = [nxtId, it, pos.x.toInteger(), pos.y.toInteger(), pos.z.toInteger()]
            f.append('\n' + row.join(','))
            console.echo("Added Port. ID: " + nxtId)
            nxtId++
        }else{
            console.echo("Wrong number of params. Usage: ~addTP [name of port]")
        }    
    }
    
    
    addShellCommand( shell, "teleport", "Teleports to a predefined Point(list all points with ~teleports)", null ) {
        String[] parms = it.split( " " );
        if( parms.length == 1 ) {
        

        int num = parms[0].toInteger() - 1
            warp(conn, ports[num].x.toInteger(), ports[num].y.toInteger(),ports[num].z.toInteger() + 1)
            console.echo("Teleporting to: " + ports[num].name)  
        }else{
            console.echo("Wrong number of params. Usage: ~teleport [port(number)]")
        }    
    }
    addShellCommand( shell, "teleports", "Shows all Teleport-Points", null ) {
            ports.each {  
               def row = [it.id, it.name, it.x, it.y, it.z]
               console.echo(row.join(','))    
            }
            
    }
}

//Edit:
I copied the imports from other scripts. Which ones do I actually need?
7  Modder's Workbench / Scripting / Re: Ex #2: Basic "Build-mode" Custom Tool Example on: January 09, 2012, 07:59:01 PM
Hey, that`s great!
Thanks for writing this tutorials!
8  Modder's Workbench / Scripting / Re: Scripting API Wish List on: January 03, 2012, 02:50:08 PM
I don't know if there's already a feature like this, but I would like it if it was possible to get a list with all players near to some point. I thought about scripting a "real-world" chat-script, which would make conversation somewhat more realistic, and, if many people are on the server, also more useful probably. The change would be that you could only read what was "said" near to you. And probably there are many other uses of such a function.

Beside this:
Probably it would help everyone if you could document the existing API, paul Wink
9  Modder's Workbench / Scripting / My Scripts on: January 03, 2012, 10:20:22 AM
Hi there!
I've written a little script for building or removing bigger things with one click.
I wrote it fast and copy&pasted a bit, so it doesn't look nice and probably it could have been done better. But I did this mainly for my fun and to practice Groovy and the (known) Mythruna-API. But if you have suggestions to improve the script, I would be happy.

The problem at the moment is that i have no environment to test it with multiple people online. I'm not sure, but I think the size-variables are global, so each player has the same.
Is this right? And if yes, how could I fix this?
Thanks, Toboi
Code:
import mythruna.*;
import mythruna.db.tree.*;
import mythruna.es.*;
import mythruna.script.*;
int size_xl = 0;
int size_yl = 0;
int size_zl = 0;
int size_xh = 0;
int size_yh = 0;
int size_zh = 0;
int type_block = 0;
int size_remove_cubel = 0;
int size_remove_cubeh = 0;
action( group:"Remove", name:"Remove cube3", type:ActionType.Block ) {

    loc = it.getBlock();
for (i in (-1..<2)) {
for (j in (-1..<2)) {
for (k in (-1..<2)) {

    setCellType(loc.x + i, loc.y + j, loc.z + k, 0);

}}
}
}
action( group:"Remove", name:"Remove cube5", type:ActionType.Block ) {

    loc = it.getBlock();
for (i in (-2..<3)) {
for (j in (-2..<3)) {
for (k in (-2..<3)) {

    setCellType(loc.x + i, loc.y + j, loc.z + k, 0);

}}
}
}


action( group:"Remove", name:"Remove cube7", type:ActionType.Block ) {

    loc = it.getBlock();
for (i in (-3..<4)) {
for (j in (-3..<4)) {
for (k in (-3..<4)) {

    setCellType(loc.x + i, loc.y + j, loc.z + k, 0);

}}
}
}
action( group:"Remove", name:"Remove cube with own size", type:ActionType.Block ) {

    loc = it.getBlock();
for (i in (-size_remove_cubel..<size_remove_cubeh)) {
for (j in (-size_remove_cubel..<size_remove_cubeh)) {
for (k in (-size_remove_cubel..<size_remove_cubeh)) {

    setCellType(loc.x + i, loc.y + j, loc.z + k, 0);

}}
}
}
action( group:"Big", name:"Water3x3x3", type:ActionType.Block ) {

loc = it.getBlock();
for (i in (-1..<2)) {
for (j in (-1..<2)) {
for (k in (-1..<2)) {
if(getCellType(loc.x + i, loc.y + j, loc.z + k) == 0){
     setCellType(loc.x + i, loc.y + j, loc.z + k, 7);
}
}
}
}
}
action( group:"Big", name:"Water5x5x5", type:ActionType.Block ) {

loc = it.getBlock();
for (i in (-2..<3)) {
for (j in (-2..<3)) {
for (k in (-2..<3)) {
if(getCellType(loc.x + i, loc.y + j, loc.z + k) == 0){
     setCellType(loc.x + i, loc.y + j, loc.z + k, 7);
}
}
}
}
}
action( group:"Big", name:"Water7x7x7", type:ActionType.Block ) {

loc = it.getBlock();
for (i in (-3..<4)) {
for (j in (-3..<4)) {
for (k in (-3..<4)) {
if(getCellType(loc.x + i, loc.y + j, loc.z + k) == 0){
     setCellType(loc.x + i, loc.y + j, loc.z + k, 7);
}
}
}
}
}
action( group:"Big", name:"Own", type:ActionType.Block ) {

loc = it.getBlock();
for (i in (-size_xl..<size_xh)) {
for (j in (-size_yl..<size_yh)) {
for (k in (-size_zl..<size_zh)) {
     setCellType(loc.x + i, loc.y + j, loc.z + k, type_block);
}
}
}
}
action( group:"Big", name:"Own if free", type:ActionType.Block ) {

loc = it.getBlock();
for (i in (-size_xl..<size_xh)) {
for (j in (-size_yl..<size_yh)) {
for (k in (-size_zl..<size_zh)) {
if(getCellType(loc.x + i, loc.y + j, loc.z + k) == 0){
     setCellType(loc.x + i, loc.y + j, loc.z + k, type_block);
}
}
}
}
}
on( [playerJoined] ) {
    type, event ->
    conn = connection;
    p = conn.getAttribute( "player" );

    println( "Adding removing tools to player:" + player );

    refs = []

    ToolActions existing = player[ToolActions.class];
 
    if( playerData != null ) {          
            refs += actions.getRef( "Remove", "Remove cube3" );
            refs += actions.getRef( "Remove", "Remove cube5" );
            refs += actions.getRef( "Remove", "Remove cube7" );
            refs += actions.getRef( "Remove", "Remove cube with own size" );
            refs += actions.getRef( "Big", "Own big block" );
            refs += actions.getRef( "Big", "Own big block if free" );
            refs += actions.getRef( "Big", "Water3x3x3" );
            refs += actions.getRef( "Big", "Water5x5x5" );
            refs += actions.getRef( "Big", "Water7x7x7" );
        
    }            
    
    println "Refs:" + refs;
    player << new ToolActions(refs, existing)
p.set( "big.size", 2 );
addShellCommand( shell, "insertsize", "Sets the size of the mass-insert block.", null ) {
          
        String[] parms = it.split( " " );
        if( it.length() == 0 || !parms.length == 4 ) {
            console.echo( "Usage: ~insertsize x y z blocktype / Build with Blocktype 'Own' to override or 'Own if free' to fill out" );
        }else{
size_xl = (parms[0].toInteger()) / 2;
size_yl = (parms[1].toInteger()) / 2;
size_zl = (parms[2].toInteger()) / 2;
size_xh = (parms[0].toInteger() + 1) / 2;
size_yh = (parms[1].toInteger() + 1) / 2;
size_zh = (parms[2].toInteger() + 1) / 2;
type_block = parms[3].toInteger();
}
    }
addShellCommand( shell, "removesize", "Sets the size of the mass-removal block.", null ) {
          
        String[] parms = it.split( " " );
        if( it.length() == 0 || !parms.length == 1 ) {
            console.echo( "Usage: ~removesize size / Remove with Blocktype 'Remove cube with own size'" );
        }else{
size_remove_cubel = (parms[0].toInteger()) / 2;
size_remove_cubeh = (parms[0].toInteger() + 1) / 2;
}
    }}

Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!