Forum Replies Created
-
AuthorPosts
-
Use the ‘Parent’ property to change an entity’s parent, eg:
Monkey1234Local model1:=Model.Load( "blah..." )Local model2:=Model.Load( "blah..." )model1.Parent=model2 'make model1 a child of model2You can also set an entity’s parent to ‘null’, meaning the entity is in ‘world space’.
Monkey pointers are similar to C pointers, only they use ‘Ptr’ instead of ‘*’ and ‘Varptr’ instead of ‘&’, eg:
Monkey1234567Function Main()Local i:Int=10Local p:Int Ptr=Varptr ip[0]*=10Print iEndAlso, you need to use ‘[]’ to dereference a pointer, so ‘p[0]’ is the same as ‘(*p)’ in C.
‘CString’ is a built-in type that should only appear in extern blocks and basically means ‘const char *’. It can be used as if it were a normal monkey2 string. So whenever you see ‘CString’ in a monkey2 extern block, just think ‘const char*’.
Note there is an error in the sdl-mixer file: ‘Function Mix_LoadMUS:Mix_Music Ptr( file:CString Ptr )’ is wrong as ‘CString Ptr’ is actually a ‘const char **’! This should just be ‘file:CString’. I have just pushed a fix for this to the develop branch at github. However, you can always just fix this yourself and update modules if you want.
I have not actually tried the sdl-mixer module myself as it has a dependancy on a shared library for decoding music etc that I wasn’t sure how to build/use. There is however a vsynth demo in bananas that using the module just for playing audio.
January 22, 2018 at 10:21 pm in reply to: derived class as argument for base class and other rules for inheritance #13170Cheers, I thought that was probably it but for the sake of clarity and to minimize confusion it’s always nice to be as clear as possible.
Same answer though, Cast wont be throwing an exception any time soon. Even if it did, I’d still like something ‘castish’ which is faster than “If i instanceOf T then t:=Cast<T>( i )” which effectively needs to do 2 downcasts.
Yes you will have to wrap it natively.
January 22, 2018 at 5:10 am in reply to: derived class as argument for base class and other rules for inheritance #13160var b = (B)a; // <– This won’t happen…
> // System.InvalidCastException has been thrownI’m not too keen on making Cast throw an exception or runtime error, as cast currently doubles as an ‘intanceOf’ style operation, eg: you can go…
If Cast<B>( a ) Print "A as a B!"
Changing this behaviour would break a ton of my own code and would mean I would have to add ‘InstanceOf’ or similar to the language. I’m quite happy with current behaviour.
January 21, 2018 at 9:29 pm in reply to: derived class as argument for base class and other rules for inheritance #13157This one seems to have a link to an object instance somewhere in memory, but the displayed value is Null.
Please post runnable examples including Main() – how am I meant to know what goes before that etc?
January 20, 2018 at 8:37 pm in reply to: derived class as argument for base class and other rules for inheritance #13116Can you post output of console? You can copy and paste from console by clicking in console, then using edit menu to select-all/copy (Yes, this should be smoother, my fault really).
[edit]Ok, can reproduce, seems to be a mingw thing. Under msvc x64 I get:
ob is Null
-now trying to invoke the doMore() method on ‘ob’ Null intance-Attempt to invoke method on null instance
ie: it should die before the ‘yo!’ Will check it out…
For the record, I’m currently using the following versions of everything and can build OK:
android studio 3.0.1
android sdk platform-tools 27.0.1
android sdk tools 26.1.1
NDK 16.1.4479499Make sure you have build tools 26.0.2 installed too. One of the build.gradle files (called ‘build.gradle (Module:app) in the android project) references ‘buildToolsVersion “26.0.2”‘ so you could also try editing this to any version you have installed.
Finally, you might want to check you have all ‘SDK Update Sites’ enabled.
Have you updated your SDK tools etc?
That gradle thing is a real pain – it’s a version control tool apparently, but it has serious version problems itself!
January 20, 2018 at 8:39 am in reply to: derived class as argument for base class and other rules for inheritance #13056I thought invoking a method on a Null instance was giving an error..
It was and it should. In debug mode I get the following error…
Attempt to invoke method on null instance
…on line 29, ob3.doMore()
This is 100% correct behaviour – you can’t invoke a method on a Null instance. You could a while back but haven’t been able to for some time now.
sudo apt–get install g++–multilib libopenal–dev libpulse–dev libsdl2–dev
Cleanest I’ve seen yet, will probably do a clean install myself soon and give this a whirl.
My plan is to produce a guide for Linux Mint 18.3 – MATE “Sylvia” as a starting point for users wanting to install Linux and setup up dependencies for Monkey
This would be great. Even if we can’t cover alllinuxes, one at least would give newbies some idea of where to start.
Good luck with emscripten! How long does that take to build on a decent machine (about 6 hours on my el ‘cheapo linux box)?
January 19, 2018 at 10:05 pm in reply to: derived class as argument for base class and other rules for inheritance #13043Look all right to me. Pulling out the noise, code is:
Monkey123456789101112131415Class AEndClass B Extends AEndFunction Main()Local a:=New ALocal b:=Cast<B>( a ) 'cast fails (ie: returns null) as 'a' is not of type BAssert( b )EndShouldn’t the downcasting on line 26 be an error?
Don’t think so. B is a subclass of A, so Cast<B>( a ) is semantically correct (ie: compilable) if ‘a’ is of class A (or any other superclass of B). In general, the compiler can’t know at compile time what the true class of ‘a’ is though.
Is that Monkey logo the new official Monkey2 logo?
Almost…I am 93% sure it will be, just need a few more days to decide for sure. I didn’t actually like it that much at first, but it has grown on me and I’m really more concerned if users are comfortable with it anyway, and everyone seems to be.
Also, Diffrenzy posted a logo image which I accidentally deleted using my clumsy god like admin powers (‘delete’ button is right next to ‘download’) so here’s hoping he will post it again.
Fixes coming soon…
Hold crap this is great! Huge thanks to Diffrenzy for doing this…
Have fixed the operator overloading example on the front page (which needs more work), and please feel free to mention anything no matter how minor.
but still the issue with the method
Oops, forgot to hit ‘update’ on the post – fixed now?!?
-
AuthorPosts