Thanks
I donāt think, that Iām able to write an own module, but my game donāt need gravity.
loadstring() doesnāt work!
@aurumcoder2624 - that is plainly not true, it is widely used.
Please donāt make sweeping statements without providing proof - rather post the specific details of what is not working. It is highly likely you are not using it correctly.
Code I am using:
a = 1
loadstring("print(a)")
@aurumcoder2624 loadstring("print(a)")()
Thanks.
@aurumcoder - you are using it wrong.
From the documentation (try reading it when something doesnāt work)
āParses the string and returns the compiled chunk as a function. Does not execute it.ā
Got that? āDoes not execute itā. So you have to assign it to a variable and then run it. This is how you use it
a=1
f=loadstring("print(a)")
f()
Well?
Oh. Thanks
BTW @JakAttak ur code didnāt work I got:
error: [string "-- Loadstring..."]:7: attempt to call a nil value
@aurumcoder2624, sorry I fixed it didnāt mean to have the function() part.
Hello,
I have a question.
I want to make something like LoveCodea to port my game to a lua framework wich supports Android. My problem is, that I donāt know how to do something like this.
It would be great if someone could help me.
i dont know either, but i wish you good luck. Are you aware of the huge effort it would be? It is probavly easier to program your game directly in android langage (javascript + html5?).
I am old school I suppose. Codea is a prototyping language. Use it to quickly test and design games on the go. When you are ready to go professional you will need to use the native language for your game. Xcode for macs for example or I think it is java for android. When you try to convert three systems over, Mac, PC, and then android, there will be so many bugs and problems youāll waste a lot of time.
The codea runtime works because it is basically the codea app without the editor. Being written in obj-C means it can just use the runtime made by till for codea as everything already works. Sorry that probably made no sense.
I donāt want to code in Java. In my opinion itās too much work.
I coding in lua or Python is much easier.
There are frameworks wich are using lua and can export to Android and iOS, but I like Codea more. Itās more fun to code on a tablet.
And it is possible to write a runtime.
There are LoveCodea and the Moai runtime
@Ignatz, and @JakAttak, I really appreciate ur help, but why is loadstring any different from function? Parses the code means that it saves into a global var, right?
Furthermore, the synthax is not so different, either.
loadstring("a=1")()
And
f = loadstring("Hello")
f()
Doesnāt seem so different against
(function()a=1 end)()
. To top it all off, loadstring apparently parses the code and pastes it into a local var, which probably takes up more space than
function. The only thing different about these two things is that loadstring created functions don't take parameters, which... 1. Rejects the possibility that it may be a python copy of lambda, and 2. In my eyes, functions that don't take parameters are pretty much useless, except for setup and draw. My point is, what is the point of loadstring? Correct me if I'm wrong, but what, just what are the point of loadstrings?
Others will tell you why loadstring can be useful, but it should always be a last resort, and usually there are better alternatives.
Lua doesnāt need a python copy of lambda because you can already define anonymous functions very easily.
Variables donāt store function code, only the address where the code can be found, so using loadstring makes no difference to stack space, afaik.
@aurumcoder - bumping posts after 12 minutes and saying āWell?ā or āHuh?ā is plain rude and/or immature.
First, people on the forum donāt have any obligation to respond to your posts. Many of them have jobs and lives to lead.
Second, we come from all around the world, mostly Europe, and right now, Europe is sleeping.
So please stop being petulant and learn to be patient and less aggressive. Your question is not necessarily the most important thing on this forum.
Europe? And please stop expecting me to be like @Dave1707 or @Coder or @JakAttak, Iām still relatively new here and Iām still learning the ropes! Do u expect me to know rocket science as soon as Iām in the field?
Ok, this might be an issue for āsimple mannersā, but Iām still new to the concept of ābumpingā in Codea? Again, Iām still kind of a noob in Codea, so donāt push me!