Need help scripting maps

Information and discussion for custom maps and mods.
Post Reply
libbmaster
Posts: 9
Joined: Wed Mar 30, 2016 1:40 am

Need help scripting maps

Post by libbmaster »

I've been trying to set up some simple missions in an attempt to get familiar with OpenRA, and I'm having a really frustrating time. The tutorial on the github wiki hasn't been very helpful either.

Basically, I'm trying to make the simplest map possible:
  • A humvee ("jeep") assigned to team creeps spawns in, and follows a four waypoint patrol.
  • Remove fog of war/shroud so I can easily see what's happening.
So far I've been entirely unable to get this to work. I've included a zipped version of the map folder in this post. Any help would be appreciated!
Attachments
test.zip
(13.43 KiB) Downloaded 208 times

User avatar
Sleipnir
Posts: 878
Joined: Wed Apr 10, 2002 11:52 pm
Contact:

Post by Sleipnir »

The fog of war and explored map configuration are defined on the Shroud trait on the Player actor. Use the following yaml to disable them:

Code: Select all

Player:
	Shroud:
		FogEnabled: False
		ExploredMapEnabled: True
The best resource for figuring out what properties are available used to be the traits documentation page, but unfortunately that page has recently grown too large for the GitHub wiki, and we have been forced to remove information (deleting the traits at the end of the list, including Shroud) in order for it to render the page at all.

User avatar
Sleipnir
Posts: 878
Joined: Wed Apr 10, 2002 11:52 pm
Contact:

Post by Sleipnir »

You define your SendPatrol function, but never call it from anywhere! The game interacts with your script through the WorldLoaded function, which is called once at game start, the Tick function, which is called once per game tick, and through any callbacks that you bind to triggers.

Adding something like the following to your lua file would be a good starting point (but note that I haven't tested anything, so you may still have other problems lurking)

Code: Select all

WorldLoaded = function()
	SendPatrol()
end

libbmaster
Posts: 9
Joined: Wed Mar 30, 2016 1:40 am

Post by libbmaster »

Sleipnir wrote: You define your SendPatrol function, but never call it from anywhere! The game interacts with your script through the WorldLoaded function, which is called once at game start, the Tick function, which is called once per game tick, and through any callbacks that you bind to triggers.

Adding something like the following to your lua file would be a good starting point (but note that I haven't tested anything, so you may still have other problems lurking)

Code: Select all

WorldLoaded = function()
	SendPatrol()
end
Wow that was fast!

Thanks for the help, I'll give this a try.

libbmaster
Posts: 9
Joined: Wed Mar 30, 2016 1:40 am

Post by libbmaster »

Okay, tried again and got a crash.

Here's my lua file:

Code: Select all

Patrol = { "jeep" }
PatrolPath = { Patrol1.Location, Patrol2.Location, Patrol3.Location, Patrol4.Location }

SendPatrol = function()
    Reinforcements.Reinforce(Creeps, Patrol, PatrolPath, 15, function(vehicle) vehicle.Patrol(PatrolPath, true, 5) end)
end

WorldLoaded = function()
   SendPatrol
end
And my error log is attached below.

Note that I was getting a different, far more complex error before this, but I fixed it by deleting the () after my sendPatrol function call - a decision I made after seeing that the wiki example did the same thing.

Also, the shroud code goes in the "map.yaml" file, right? Should I put it before "Actors", or does it not matter?
Attachments
lua.txt
(1.96 KiB) Downloaded 211 times

User avatar
Materianer
Posts: 199
Joined: Mon Jul 04, 2016 8:27 am

Post by Materianer »

Hi
the () is definitly needed for the function call in world loaded
You also need to define what creeps is with
Creeps = Player.GetPlayer("Creeps")

the waypoints are right in the yaml?

Code: Select all

	Patrol1: waypoint
		Owner: Neutral
		Location: 30,23
You are welcome here if you need help http://www.sleipnirstuff.com/forum/view ... 83&t=20361
I hope i will get some people in there for improving coding skills.

libbmaster
Posts: 9
Joined: Wed Mar 30, 2016 1:40 am

Post by libbmaster »

Materianer wrote: Hi
the () is definitly needed for the function call in world loaded
You also need to define what creeps is with
Creeps = Player.GetPlayer("Creeps")

the waypoints are right in the yaml?

You are welcome here if you need help http://www.sleipnirstuff.com/forum/view ... 83&t=20361
I hope i will get some people in there for improving coding skills.
Alright, I got the patrol working! Just two problems left:
  • The Jeep is my team color, and I cannot target it!
  • Map is still shrouded.
Updated files attached. Thank you for all the help, and I'll be sure to stop by that thread!
Attachments
test.zip
(13.47 KiB) Downloaded 204 times

User avatar
Materianer
Posts: 199
Joined: Mon Jul 04, 2016 8:27 am

Post by Materianer »

libbmaster wrote:
Materianer wrote: Hi
the () is definitly needed for the function call in world loaded
You also need to define what creeps is with
Creeps = Player.GetPlayer("Creeps")

the waypoints are right in the yaml?

You are welcome here if you need help http://www.sleipnirstuff.com/forum/view ... 83&t=20361
I hope i will get some people in there for improving coding skills.
Alright, I got the patrol working! Just two problems left:
  • The Jeep is my team color, and I cannot target it!
  • Map is still shrouded.
Updated files attached. Thank you for all the help, and I'll be sure to stop by that thread!
You need to define enemys in the map.yaml

Code: Select all

	PlayerReference@Creeps:
		Name: Creeps
		NonCombatant: True
		Faction: Random
		Enemies: GDI
	PlayerReference@GDI:
		Name: GDI
		AllowBots: False
		Playable: True
		Required: True
		LockFaction: True
		Faction: gdi
		LockColor: True
		Color: F5D378
		LockSpawn: True
		LockTeam: True
		Allies: GDI
		Enemies: Creeps
Then you can attack the unit

the color is because you load cnc|rules/campaign-palettes.yaml
Maybe its better if you test with a nod enemy, creeps are supposed to be noncombatants

and the shroud remove didnt work because

Code: Select all

Player: 
	Shroud: 
		FogEnabled: False 
		ExploredMapEnabled: True
must be in the rules.yaml
A while ago dont know how long maybe 2 years it was there in the map.yaml but that changed.
Seems like the tutorial on the github page is outdated.
Maybe the best is if you look in the mission mapfiles how it is working now.

libbmaster
Posts: 9
Joined: Wed Mar 30, 2016 1:40 am

Post by libbmaster »

Materianer wrote:
You need to define enemys in the map.yaml
Then you can attack the unit
D'oh! Of course I missed that. Heh...
Materianer wrote: the color is because you load cnc|rules/campaign-palettes.yaml
Maybe its better if you test with a nod enemy, creeps are supposed to be noncombatants

and the shroud remove didnt work because

Code: Select all

Player: 
	Shroud: 
		FogEnabled: False 
		ExploredMapEnabled: True
must be in the rules.yaml
A while ago dont know how long maybe 2 years it was there in the map.yaml but that changed.
Seems like the tutorial on the github page is outdated.
Maybe the best is if you look in the mission mapfiles how it is working now.
Roger that! I'll go try this now.

EDIT: It worked like a charm! Now that I know the basics I'll start downloading some maps and trying stuff. Thanks guys!

Post Reply