Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (763)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (852)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java ScriptEngine-Like step by step execution  (Read 1825 times)
0 Members and 1 Guest are viewing this topic.
Offline MackValentine

Junior Newbie





« Posted 2017-04-25 19:00:25 »

Is there a way to execute a code like the ScriptEngine does, but step by step ?

For exemple :

1  
2  
3  
4  
5  
6  
    if (contact(player,self)){
       callCinematics("forest.png", "face1.png","SALUT!");
       teleport("test",0,5,5);
    } else {
       print("A");
    }


I want to execute this code step by step, when I call my function eval(), first, it will check the condition, and wait for the second call.
If the first call return true, the second call eval the "callCinematics(...);", or "print("A");" if the first call return false.
If the first call return false, the third call of eval will do nothing, until I call another function that restart all the call.

I don't know if i'm very understandable ^^'.
Offline cylab

JGO Kernel


Medals: 182



« Reply #1 - Posted 2017-04-26 05:43:41 »

No  Wink

The term you are probably searching for is “continuations“ or “coroutines“. You need a library to do that in java.

See for example http://www.java-gaming.org/topics/java-continuations-and-greenthreads/28337/view.html

Mathias - I Know What [you] Did Last Summer!
Offline MackValentine

Junior Newbie





« Reply #2 - Posted 2017-04-30 13:43:07 »

Exactly, i want to use coroutine Cheesy.

I found the Mathias Mann .jar fr making Coroutine, but it gives me error every time :
1  
2  
3  
4  
5  
Exception in thread "main" java.lang.Error: Calling function not instrumented
   at de.matthiasmann.continuations.Coroutine.yield(Coroutine.java:77)
   at MyCoroutine$1.coExecute(MyCoroutine.java:17)
   at de.matthiasmann.continuations.Coroutine.run(Coroutine.java:164)
   at MyCoroutine.main(MyCoroutine.java:23)


:/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
Administrator

« JGO Overlord »


Medals: 1342
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2017-04-30 15:59:41 »

Follow the instructions, or use my library that does the work for you.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline MackValentine

Junior Newbie





« Reply #4 - Posted 2017-04-30 16:12:12 »

I already try, and I get this error :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassWriter
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
   at java.lang.Class.getDeclaredMethod(Unknown Source)
   at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
   at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassWriter
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 5 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"


I'm using Eclipse, so in Run Configurations, I add -javaagent:continuations-agent.jar in VM Arguments.
But it doesn't work :/
Offline Riven
Administrator

« JGO Overlord »


Medals: 1342
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2017-04-30 19:05:37 »

Add ASM to the classpath.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline MackValentine

Junior Newbie





« Reply #6 - Posted 2017-05-01 09:18:15 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
[Continuations] ERROR: Unable to instrument
java.lang.IllegalArgumentException
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
   at de.matthiasmann.continuations.instrument.MethodDatabase.extractSuperClass(MethodDatabase.java:308)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getDirectSuperClass(MethodDatabase.java:350)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getSuperClasses(MethodDatabase.java:330)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getCommonSuperClass(MethodDatabase.java:225)
   at de.matthiasmann.continuations.instrument.DBClassWriter.getCommonSuperClass(DBClassWriter.java:50)
   at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1571)
   at org.objectweb.asm.Frame.merge(Frame.java:1424)
   at org.objectweb.asm.Frame.merge(Frame.java:1352)
   at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1303)
   at de.matthiasmann.continuations.instrument.InstrumentMethod.accept(InstrumentMethod.java:238)
   at de.matthiasmann.continuations.instrument.InstrumentClass.visitEnd(InstrumentClass.java:132)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:673)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
   at de.matthiasmann.continuations.instrument.JavaAgent.instrumentClass(JavaAgent.java:134)
   at de.matthiasmann.continuations.instrument.JavaAgent$Transformer.transform(JavaAgent.java:160)
   at sun.instrument.TransformerManager.transform(Unknown Source)
   at sun.instrument.InstrumentationImpl.transform(Unknown Source)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at MyCoroutine.main(MyCoroutine.java:22)
[Continuations] ERROR: Unable to instrument
java.lang.IllegalArgumentException
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
   at de.matthiasmann.continuations.instrument.MethodDatabase.extractSuperClass(MethodDatabase.java:308)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getDirectSuperClass(MethodDatabase.java:350)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getSuperClasses(MethodDatabase.java:330)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getCommonSuperClass(MethodDatabase.java:225)
   at de.matthiasmann.continuations.instrument.DBClassWriter.getCommonSuperClass(DBClassWriter.java:50)
   at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1571)
   at org.objectweb.asm.Frame.merge(Frame.java:1424)
   at org.objectweb.asm.Frame.merge(Frame.java:1352)
   at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1303)
   at de.matthiasmann.continuations.instrument.InstrumentMethod.accept(InstrumentMethod.java:238)
   at de.matthiasmann.continuations.instrument.InstrumentClass.visitEnd(InstrumentClass.java:132)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:673)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
   at de.matthiasmann.continuations.instrument.JavaAgent.instrumentClass(JavaAgent.java:134)
   at de.matthiasmann.continuations.instrument.JavaAgent$Transformer.transform(JavaAgent.java:160)
   at sun.instrument.TransformerManager.transform(Unknown Source)
   at sun.instrument.InstrumentationImpl.transform(Unknown Source)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at MyCoroutine.main(MyCoroutine.java:22)
[Continuations] ERROR: Unable to instrument
java.lang.IllegalArgumentException
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
   at org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
   at de.matthiasmann.continuations.instrument.MethodDatabase.extractSuperClass(MethodDatabase.java:308)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getDirectSuperClass(MethodDatabase.java:350)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getSuperClasses(MethodDatabase.java:330)
   at de.matthiasmann.continuations.instrument.MethodDatabase.getCommonSuperClass(MethodDatabase.java:225)
   at de.matthiasmann.continuations.instrument.DBClassWriter.getCommonSuperClass(DBClassWriter.java:50)
   at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1571)
   at org.objectweb.asm.Frame.merge(Frame.java:1424)
   at org.objectweb.asm.Frame.merge(Frame.java:1352)
   at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1303)
   at de.matthiasmann.continuations.instrument.InstrumentMethod.accept(InstrumentMethod.java:238)
   at de.matthiasmann.continuations.instrument.InstrumentClass.visitEnd(InstrumentClass.java:132)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:673)
   at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
   at de.matthiasmann.continuations.instrument.JavaAgent.instrumentClass(JavaAgent.java:134)
   at de.matthiasmann.continuations.instrument.JavaAgent$Transformer.transform(JavaAgent.java:160)
   at sun.instrument.TransformerManager.transform(Unknown Source)
   at sun.instrument.InstrumentationImpl.transform(Unknown Source)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at de.matthiasmann.continuations.CoIterator.<init>(CoIterator.java:51)
   at MyCoroutine$YieldReturn.<init>(MyCoroutine.java:7)
   at MyCoroutine.main(MyCoroutine.java:22)
Exception in thread "main" java.lang.Error: Calling function not instrumented
   at de.matthiasmann.continuations.Coroutine.yield(Coroutine.java:77)
   at de.matthiasmann.continuations.CoIterator.produce(CoIterator.java:91)
   at MyCoroutine$YieldReturn.run(MyCoroutine.java:11)
   at de.matthiasmann.continuations.CoIterator$DelegateExecute.coExecute(CoIterator.java:114)
   at de.matthiasmann.continuations.Coroutine.run(Coroutine.java:164)
   at de.matthiasmann.continuations.CoIterator.hasNext(CoIterator.java:56)
   at MyCoroutine.main(MyCoroutine.java:23)


:/
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (543 views)
2018-06-10 19:43:48

EgonOlsen (647 views)
2018-06-10 19:43:44

EgonOlsen (444 views)
2018-06-10 19:43:20

DesertCoockie (789 views)
2018-05-13 18:23:11

nelsongames (1022 views)
2018-04-24 18:15:36

nelsongames (1055 views)
2018-04-24 18:14:32

ivj94 (1636 views)
2018-03-24 14:47:39

ivj94 (561 views)
2018-03-24 14:46:31

ivj94 (1442 views)
2018-03-24 14:43:53

Solater (566 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!