Forum Replies Created
-
AuthorPosts
-
Might be a bug – can you post a runnable sample?
IMO, a web/cloud solution is best here, as a user *should* be able to wipe device data the way they can wipe apps if they want, so if you want data to be truly recoverable, it should probably be stored off device, perhaps even on an SD card?
Are there any android/ios APIs for accessing google drive or icloud?
I prefer ( ) because other langs use them.
Examples?
I’m especially interested in statically typed languages. I’m vaguely aware of how python does tuples, but that doesn’t really have type declarations.
pinch/zoom doesn’t quite work in 3d though does it? You want pinch/move which is a bit different, or do you keep pinching over and over to move?
And how would rotate work? Swipe left/right? Or hold and drag to look? Would be good to learn how swipe works anyway…
It was be nice to see an example! Any recommendations for android/ios?
ok, but I’m lloking for a complete dropin that does pan, tilt(rotation), zoom and rotation.
Util fly was a 5 minute hack designed to do 3 things: rotate left/right and move forward! So no, it doesn’t do gesture recognition etc.
I got 2d scale/drag/rotate going quite nicely I think – see touchtest banana – but I haven’t attempted 3d as yet. In fact, I don’t think I’ve even seen any examples – can you describe a bit more clearly what you’re after?
I have been thinking about tuples a bit lately, and I actually think adding tuples directly to the language itself would not be *that* tricky – well, the syntax side of things anyway.
Basically, anything in brackets would be a tuple, eg: (1), (10,”Hello”,arseBisuits) etc.
A single element tuple would be interchangeable with a simple value/expression.
Tuple types could be declared with brackets, eg: Local result:(Entity,bool), Function Find:(Object,bool)( blah:String ) etc.
Nested tuples would simply be collapsed/linearized, eg: (10,20,(30,40)) and (10,20,30,40) would have the sample type: (Int,Int,Int,Int).
Tuple initializers: Local (x,y,z):=(10,”Hello”,.5), Local (x:Int,y:String,z:Float)=(10,”Hello”,.5)
Tuple assignments: (x,y,z)=(1,2,3), (x,y,z)+=(10,20,30)
Tuple operators: (x,y,z)+(10,20,30)
These all seem quite intuitive to me and should be relatively easy to parse, although actual backend implementation etc would be challenging.
Definitely not gonna happen in the near future, but worth thinking about.
(Ok, type conflicts with function types (I think) – perhaps <> instead, eg: Local x:<Int,Float>?)
Fixed, thanks.
This is because Variant.Type only returns the static type of the variant. You’ll need to use InstanceType on the object contained in the variant instead of v.Type, eg:
Local type:=Cast<Object>( v ).InstanceType
…safer…
Monkey12345678Function DynamicType:Type( v:Variant )If v.Type.Kind="Class" or v.Type.Kind="Interface"Local inst:=Cast<Object>( v )If inst Return inst.InstanceTypeEndifReturn v.TypeEndI now think InstanceType should probably be renamed to DynamicType, and possibly the above DynamicType code added to Variant too which can do it more efficiently.
Anyway, quick fix for the above: change the Default block to:
Monkey12345678910Local newObj:= New JsonObjectLocal type:=Cast<Object>( v ).InstanceTypenewObj.SetString( "Class", type.Name )For Local decl:DeclInfo = Eachin type.GetDecls()If ( decl.Kind = "Property" And decl.Settable )' Or ( decl.Kind = "Field" )newObj.Serialize( decl.Name, decl.Get( v ) )EndNextSetObject( key, newObj.ToObject() )Same problem – Current is returning a *copy* of the iterator item. Modifying this copy has no effect.
Actually, if you just use Vec2’s ‘x’ and ‘y’ fields directly (not ‘X’ and ‘Y’ properties), eg: iter.Current.x=0, you will get a compile time error, because the compiler ‘knows’ you are trying to modify a copy. However, the compiler doesn’t know exactly what X or Y properties do – they may or may not actually modify Self – and I didn’t want to just disallow property/method calls in general on returned copies or subject people to the joys of ‘const correctness’, so it’s a bit of a half-assed check.
The solution is to get current item, modify it, and then set it back (aka read-modify-write), eg:
Monkey123456789101112131415161718192021222324252627282930313233343536#Import "<std>"Using std..Function Main()Local items := New List<Vec2f>For Local n := 0 Until 10items.Add(New Vec2f(Rnd(1,10), Rnd(1,10)))NextPrintItems(items)ResetItems(Varptr items)PrintItems(items)EndFunction ResetItems(items:List<Vec2f> Ptr)Local iter := items->All()While Not iter.AtEndLocal v:=iter.Currentv.X=0v.Y=0iter.Current=viter.Bump()EndEndFunction PrintItems(items:List<Vec2f>)Print("Items")For Local i := Eachin itemsPrint(i)NextEndSame applies to Stacks etc.
However, you don’t need to do this with plain arrays, eg: myarray[i].X=0 will work fine, as an array element is really just a special type of variable (which is why you can Varptr it).
This means you can in fact do a little hack with stacks where you can set elements directly:
mystack.Data[i].X=0
This is because the Data property of Stack returns the underlying array. You do need to be careful ‘i’ is in range though, as array may be longer than Stack!
I think you can touch left for rot left, right for rot right, center for move foward.
I recommend using a libc.char_t pointer if you need to provide a fixed sized string or string buffer. A CString may not work, as CStrings should not be modified and are subtly different.
For example, here’s roughly how monkey2 CurrentDir function wraps the libc getcwd call:
Monkey12345678910111213141516171819#Import "<libc>"externFunction getcwd:libc.char_t Ptr( buf:libc.char_t Ptr,size:Int )publicFunction CurrentDir:String()Local buf:=New char_t[PATH_MAX]getcwd( buf.Data,PATH_MAX )Local path:=String.FromCString( buf.Data )Return pathEndNot pretty, but that’s c/c++ strings for you. I recommend wrapping ‘messy’ calls like this instead of using them directly, as above.
I also recommend looking at the libc module and std filesystem for ideas on how to write C API wrappers.
Ok, erm, looks like tomorrow sorry!
I will be pushing the void ptr change (and removing handle_to_object etc) some time today.
this is code this is not this is this ain’t.
some more
Monkey12345678910111213141516171819202122232425262728293031323334353637#Import "<std>"Using std..Class CField x:IntField c:CMethod New()Local p:=Varptr( c )EndEndFunction Main()Local c:=New Cc.x=10GCSuspend()Local p:=Cast<Void Ptr>( c )Print Hex( ulong( p ) )c=Cast<C>( p )GCResume()Print c.xEndThank you!
-
AuthorPosts