City.spawnCar firsts argument is a Draft according to the docs, but it isn't

Do you have any issues? Don't hesitate to tell us about it.
User avatar
FranchuFranchu
Inhabitant of a Country
Reactions:
Posts: 798
Joined: Sun May 28, 2017 0:07
Location: Freezing in Argentina
Plugins: Show
Version: Beta

Platform

Plugin Creator

City.spawnCar firsts argument is a Draft according to the docs, but it isn't

#1

Post by FranchuFranchu »

Take a look at the attachment, and place the new building next to a road. The Lua code leaves an error in log.txt
samplebug.zip
(751 Bytes) Downloaded 17 times

Code: Select all

2020/01/05 20:11:18: Lua
org.luaj.vm2.LuaError: /storage/emulated/0/TheoTown/plugins/samplebug/test.lua:12 vm error: java.lang.ClassCastException: org.luaj.vm2.LuaTable cannot be cast to info.flowersoft.theotown.draft.CarDraft
org.luaj.vm2.LuaError: /storage/emulated/0/TheoTown/plugins/samplebug/test.lua:12 vm error: java.lang.ClassCastException: org.luaj.vm2.LuaTable cannot be cast to info.flowersoft.theotown.draft.CarDraft
	at org.luaj.vm2.LuaClosure.execute(Unknown Source)
	at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
	at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
	at org.luaj.vm2.LuaValue.invoke(Unknown Source)
	at info.flowersoft.theotown.scripting.MethodCluster.invoke(MethodCluster.java:75)
	at info.flowersoft.theotown.scripting.MethodCluster.invoke(MethodCluster.java:121)
	at info.flowersoft.theotown.map.modifier.CityModifier.callEventMethod(CityModifier.java:900)
	at info.flowersoft.theotown.map.modifier.CityModifier.build(CityModifier.java:831)
	at info.flowersoft.theotown.tools.BuildingTool.finallyBuild(BuildingTool.java:595)
	at info.flowersoft.theotown.tools.BuildingTool.onBuild(BuildingTool.java:557)
	at info.flowersoft.theotown.tools.BuildingTool$1.onClick(BuildingTool.java:94)
	at info.flowersoft.theotown.stages.gameuibuilder.OverlayBuilder$6.onClick(OverlayBuilder.java:190)
	at io.blueflower.stapel2d.gui.Gadget.performOnClick(Gadget.java:452)
	at io.blueflower.stapel2d.gui.SensitiveGadget.updateTouchInput(SensitiveGadget.java:77)
	at io.blueflower.stapel2d.gui.Gadget.updateTouchInput(Gadget.java:417)
	at info.flowersoft.theotown.stages.BaseStage.update(BaseStage.java:187)
	at io.blueflower.stapel2d.gamestack.GameStack.update(GameStack.java:135)
	at info.flowersoft.theotown.MyGdxGame.render(MyGdxGame.java:119)
	at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:494)
	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
Caused by: java.lang.ClassCastException: org.luaj.vm2.LuaTable cannot be cast to info.flowersoft.theotown.draft.CarDraft
	at info.flowersoft.theotown.scripting.libraries.CityLibrary$8.invoke(CityLibrary.java:216)
	... 21 more
It seems that the first argument should be a Java object, but of course you can't make Java objects in Lua.

@Lobby?

...pretty sure this doesnt belong to plugin errors
Did you know you can't blink while smiling :) ?

User avatar
Lobby
Developer
Reactions:
Posts: 3593
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

Platform

Re: City.spawnCar firsts argument is a Draft according to the docs, but it isn't

#2

Post by Lobby »

Thank you, I did an implementation mistake on the Java side of things. The documentation is correct, but the current implementation expects an actual draft object as it can be obtained by draft.orig (that is some sort of Lua representation for Java objects).

So in your example using

Code: Select all

City.spawnCar(h.orig, ...)
should solve the issue. I'll make that code compatible with a future bugfix.
=^._.^= ∫

Post Reply Previous topicNext topic

Return to “Problems and Errors (bugs)”