moai / moai-dev

This is the development repo of Moai SDK.
http://getmoai.com
944 stars 313 forks source link

Filestream bug, resulting in unusable MOAIParticlePexPlugin #586

Open Sylph opened 12 years ago

Sylph commented 12 years ago

Using the following code

local stream = MOAIFileStream.new()
stream:open ( "TestFile.txt", MOAIFileStream.READ_WRITE_NEW )
stream:write ( "TEST" )
stream:close()
local plugin = MOAIParticlePexPlugin.load("deathBlossomCharge.pex")
print (plugin:getMaxParticles(), plugin:getSize())

results in the last line printing 81202816 0 or other similarly invalid numbers, rather than 40 9 that it should have printed.

This happens on the latest source (debug, release build), and released SDKs (build 98, and build 119).

robertwahler commented 12 years ago

This one is pretty hard to avoid because you don't even have to write to the stream. Opening and directly closing the stream will break the plugin on the current master.

bobby-oster commented 12 years ago

I'm also having issues with this. Was looking to use pex for our particles.

TheGribble commented 12 years ago

This also happens if you use a "require()" statement anywhere before loading the plugin. Irritating.

Edit - I've just noticed that the error I'm getting only occurs when running through ZeroBrane Studio, If I just run it from the command line then everything's fine. Can you other guys confirm whether you were using ZBS too?

pkulchenko commented 11 years ago

(cross-posting from pkulchenko/ZeroBraneStudio#87)

@TheGribble, this doesn't seem to be a ZBS problem. The problem appears to be with Moai corrupting something internally when it does path search (not sure about cpath). For example, the following code works (assuming you have dummy.lua in the current folder):

package.path = "./?.lua"
require('dummy')
print(MOAIParticlePexPlugin.load('deathBlossomCharge.pex'):getMaxParticles())

but this one doesn't (it returns 32182168 instead of 40, but your number may be different):

package.path = "foo/?.lua;./?.lua" -- foo/ folder doesn't exist
require('dummy')
print(MOAIParticlePexPlugin.load('deathBlossomCharge.pex'):getMaxParticles())
perroboc commented 11 years ago

I'm experiencing a similar problem using ZBS and the XML sample in MOAI (pkulchenko/ZeroBraneStudio#96)

Sylph commented 11 years ago

I use IntelliJ IDEA, TheGribble. I'm probably switching to cocos2d-x for my next game, but i'll keep watch on this because MoaiSDK is a pretty wonderful tool as well.