Page 1 of 1

How to define 'pieces' in scripts/

Posted: 18 Aug 2012, 15:08
by Smeg
Hi all,

First off I'm new here (Hello) and just dipping my toes in to see how it goes.

I've created a unit (a construction yard) and i can see it on the map.
Now i want to write a script for it. In example posted around here we declare local pieces at the start of these scripts. like so.

Code: Select all

local garage = piece "garage"
local door = piece "door"
I have done this and written/copied some code that should allow the construction yard to build a factory. But it does not, and when i check the infolog.txt i find this faulty line.

Code: Select all

[f=0000000] Error: LuaRules::RunCallIn: error = 2, UnitCreated, [string "scripts/cyardscript.lua"]:1: piece not found: garage
stack traceback:
	[C]: in function 'sp_CallAsUnit'
	[string "LuaGadgets/Gadgets/unit_script.lua"]:307: in function 'CallAsUnitNoReturn'
	[string "LuaGadgets/Gadgets/unit_script.lua"]:703: in function 'UnitCreated'
	[string "LuaGadgets/gadgets.lua"]:1309: in function <[string "LuaGadgets/gadgets.lua"]:1307>
	(tail call): ?
	[C]: in function 'CreateUnit'
	[string "LuaRules/Gadgets/game_spawn.lua"]:68: in function 'SpawnStartUnit'
	[string "LuaRules/Gadgets/game_spawn.lua"]:110: in function 'GameStart'
	[string "LuaGadgets/gadgets.lua"]:927: in function <[string "LuaGadgets/gadgets.lua"]:925>
	(tail call): ?
I'm guessing it doesn't know what the garage is in relation to my construction yard.

My question.

How do i define my pieces for this script to work? (Somewhere else?)

I read most guides and i can't seem to find anything that seems to explain this.

Let me know if you need a further explanation.

Thanks in advance.

Smeg.

Re: How to define 'pieces' in scripts/

Posted: 18 Aug 2012, 15:17
by FLOZi
Can you attach the model and full script?

(Not to be condescending but does the model have a piece named exactly "garage"?)

Re: How to define 'pieces' in scripts/

Posted: 18 Aug 2012, 15:53
by Smeg
Hi Flozi,

It would allow me to upload a s£o file, so i just rar'd it.

This came from my fried who's looking after the models. He says it's in there.

I guess i should download the open source program to check for myself.

Also i noticed this line above the others

Code: Select all

[f=0000000] [Texture] Warning: [LoadS3OTextureNow] could not load texture "Spring unit" from model "objects3d/constr1.s3o"
We haven't added any textures yet so i have ignored that line, but let me know if i should be worried about it. I've included it in case it's relevant to the above.

Thanks for your time.

Smeg

EDIT: Added cyardscript.lua

Re: How to define 'pieces' in scripts/

Posted: 18 Aug 2012, 16:04
by Smeg
Just to let you know, i downloaded uprising and took alook my self, the answer was the capitalization on the pieces, so they were different.

Thanks for making me double check.

Re: How to define 'pieces' in scripts/

Posted: 18 Aug 2012, 16:35
by FLOZi
No worries. Good luck with your project, feel free to join #moddev and #lua on the lobby, that is where the cool kids hang out. 8)

Re: How to define 'pieces' in scripts/

Posted: 19 Aug 2012, 23:52
by PicassoCT
i should read threads to the end, before opening case-sensitive garage doors ;)