How to define 'pieces' in scripts/

How to define 'pieces' in scripts/

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Smeg
Posts: 5
Joined: 16 Aug 2012, 22:11

How to define 'pieces' in scripts/

Post 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.
Attachments
cyardscript.lua
construction script. (first attempt).
(2.48 KiB) Downloaded 7 times
Constr1.rar
construction yard model.
(9.29 KiB) Downloaded 12 times
Last edited by Smeg on 18 Aug 2012, 15:55, edited 3 times in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How to define 'pieces' in scripts/

Post by FLOZi »

Can you attach the model and full script?

(Not to be condescending but does the model have a piece named exactly "garage"?)
User avatar
Smeg
Posts: 5
Joined: 16 Aug 2012, 22:11

Re: How to define 'pieces' in scripts/

Post 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
User avatar
Smeg
Posts: 5
Joined: 16 Aug 2012, 22:11

Re: How to define 'pieces' in scripts/

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How to define 'pieces' in scripts/

Post 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)
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: How to define 'pieces' in scripts/

Post by PicassoCT »

i should read threads to the end, before opening case-sensitive garage doors ;)
Post Reply

Return to “Lua Scripts”