Shard 0.4/dev
Moderators: hoijui, Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Go ahead, be a douche.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
sorry, i couldn't resist.
but as conclusion: imo at best: if you find a bug/problem with shard, make a report at https://github.com/Tarendai/Shard/issues and then AF or me will try to fix / apply... at best, make a pull request, but that isn't really needed to change a few lines.
but as conclusion: imo at best: if you find a bug/problem with shard, make a report at https://github.com/Tarendai/Shard/issues and then AF or me will try to fix / apply... at best, make a pull request, but that isn't really needed to change a few lines.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Abma, I was talking to AF, not you. Sorry for the confusion.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Should api.new_vectorFloat() work in Shard included with 94.1? It causes an error.
What I'm trying to do is this:
Result:
Why I'm trying this: Shard lacks an Attack(position) command for units. I tried using Attack(unit) to order bombers, but order is immediately canceled - looks like the engine resets it for units the team doesn't see (or maybe for some other reason). Attack gound would work in that case.
What I'm trying to do is this:
Code: Select all
function BomberBehaviour:BombPosition(position)
local CMD_ATTACK = 20
local floats = api.new_vectorFloat()
-- populate with x, y, z of the position
table.insert(floats, position.x)
table.insert(floats, position.y)
table.insert(floats, position.z)
self.unit:Internal():ExecuteCustomCommand(CMD_ATTACK, floats)
end
Code: Select all
attempt to call field 'new_vectorFloat' (a nil value)
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Referring here:
https://github.com/Tarendai/Shard/blob/ ... /API/api.i
The vector float isnt a part of the api module. Wether this means you should call new_vectorFloat instead of api.new_vectorFloat I don't know, you'd have to refer to the SWIG documentation. It was never quite clear to me what it should be....
Another thing to note is that the resulting object is not a lua table, but a C++ std::vector<float> object, and so table.insert probably won't work on it. You'll want to use push_back on that object instead
something along these lines:
https://github.com/Tarendai/Shard/blob/ ... /API/api.i
The vector float isnt a part of the api module. Wether this means you should call new_vectorFloat instead of api.new_vectorFloat I don't know, you'd have to refer to the SWIG documentation. It was never quite clear to me what it should be....
Another thing to note is that the resulting object is not a lua table, but a C++ std::vector<float> object, and so table.insert probably won't work on it. You'll want to use push_back on that object instead
something along these lines:
Code: Select all
floats:push_back( position.x )
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Doesn't initialize without api as well:
Would it be possible to add an Attack(Position) to IUnit object instead? It only has Attack(IUnit).
Code: Select all
attempt to call global 'new_vectorFloat' (a nil value)
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
It is indeed possible, though ironing out how to use custom commands would be handy too
try:
try:
Code: Select all
local floats = api.vectorFloat()
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Thanks, AF! That did it. Now my bombers work.
Working code is as follows:
This causes units to attack ground at the specified position. Of course I have some other code to stop them doing so when the target is dead :)
Working code is as follows:
Code: Select all
function BomberBehaviour:BombPosition(position)
local CMD_ATTACK = 20
local floats = api.vectorFloat()
-- populate with x, y, z of the position
floats:push_back(position.x)
floats:push_back(position.y)
floats:push_back(position.z)
self.unit:Internal():ExecuteCustomCommand(CMD_ATTACK, floats)
end
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
I'm wondering what people think of a more Backbone-esque style of object, so that this:
Would look more like this:
Thoughts? Is this a good direction to go in?
Code: Select all
LowEnergyBehaviour = class(Behaviour)
function LowEnergyBehaviour:Init()
self.active = false
self.underfire = false
end
function LowEnergyBehaviour:UnitIdle(unit)
if unit:Internal():ID() == self.unit:Internal():ID() then
if not self:IsActive() then
res = game:GetResourceByName("energy")
if res == nil then
game:SendToConsole("res == nil in LowEnergyBehaviour")
else
if res.reserves == 0 then
self.underfire = true
self.unit:ElectBehaviour()
end
end
else
self.underfire = false
self.unit:ElectBehaviour()
end
end
if unit:Internal():ID() == self.unit:Internal():ID() then
if self:IsActive() then
self.unit:ElectBehaviour()
end
end
end
function LowEnergyBehaviour:Activate()
self.underfire = false
local s = self.unit:Internal():Build("esolar2")
if s then
self.active = true
else
self.unit:ElectBehaviour()
end
end
function LowEnergyBehaviour:Deactivate()
self.active = false
self.underfire = false
end
function LowEnergyBehaviour:Priority()
if self.underfire == true then
return 110
end
return 0
end
Code: Select all
LowEnergyBehaviour = Shard.behavior.extend( {
init = function()
self.active = false
self.underfire = false
end,
unitidle = function( unit )
if unit:Internal():ID() == self.unit:Internal():ID() then
if not self:IsActive() then
res = game:GetResourceByName("energy")
if res == nil then
game:SendToConsole("res == nil in LowEnergyBehaviour")
else
if res.reserves == 0 then
self.underfire = true
self.unit:ElectBehaviour()
end
end
else
self.underfire = false
self.unit:ElectBehaviour()
end
end
if unit:Internal():ID() == self.unit:Internal():ID() then
if self:IsActive() then
self.unit:ElectBehaviour()
end
end
end,
activate = function()
self.underfire = false
local s = self.unit:Internal():Build("esolar2")
if s then
self.active = true
else
self.unit:ElectBehaviour()
end
end,
deactivate = function()
self.active = false
self.underfire = false
end,
priority = function()
if self.underfire == true then
return 110
end
return 0
end
})
Thoughts? Is this a good direction to go in?
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Hi AF, and others. Shard looks amazing.
I am trying to set it up so that I can play test a mod I am working on. It looks like it should be quite easy to set up with behavior for my mod which is awesome however I am a bit confused as to how to go about it.
https://github.com/Tarendai/Shard says:
"Writing AIs With Shard
If you have a prebuilt copy of Shard ( as comes with every install of the Spring Engine ), you don't need to build Shard to use it, you need only a text editor and knowledge of lua."
I am working on Mac Os.
I have a text editor and a basic understanding of Lua.
From what I have read, to get shard to work for my mod I basically need to set up the taskqueues and attackers files, in spring/ai/shard/mymodname/
In my spring/ai and all subfolders there is no shard directory and nothing to do with shard.
I assumed there would be shard subfolder inside spring/ai/skirmish however there is not.
When I play spring I can select shard as an AI.
I just played a single player game of EVO vs shard, so shard is installed on my computer?
Am i missing something?
I have spent about 6 hours last night and today trawling through the 29 pages of forums posts here, and the wiki and the nota shard forums topic but so now i ask for help...
I am trying to set it up so that I can play test a mod I am working on. It looks like it should be quite easy to set up with behavior for my mod which is awesome however I am a bit confused as to how to go about it.
https://github.com/Tarendai/Shard says:
"Writing AIs With Shard
If you have a prebuilt copy of Shard ( as comes with every install of the Spring Engine ), you don't need to build Shard to use it, you need only a text editor and knowledge of lua."
I am working on Mac Os.
I have a text editor and a basic understanding of Lua.
From what I have read, to get shard to work for my mod I basically need to set up the taskqueues and attackers files, in spring/ai/shard/mymodname/
In my spring/ai and all subfolders there is no shard directory and nothing to do with shard.
I assumed there would be shard subfolder inside spring/ai/skirmish however there is not.
When I play spring I can select shard as an AI.
I just played a single player game of EVO vs shard, so shard is installed on my computer?
Am i missing something?
I have spent about 6 hours last night and today trawling through the 29 pages of forums posts here, and the wiki and the nota shard forums topic but so now i ask for help...
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
I wasn't aware Spring ran on Mac OS 9, perhaps you mean OS X?
There is no reason I'm aware of that Shard cannot work on OS X but, I have little knowledge of the state of Spring for OS X, I dont know how recent the build is, what it comes with, and from the few experiences I've had, lobby support is pitiful, or relies on mechanisms that are broken for security reasons ( e.g. weblobby + java applets being messed up by Apple induced Java security changes ).
So I do not know if Shard was built and distributed with Springs OS X builds, I've never tried to build it with xcode either.
So currently, you actually know more about this than I do, and there really isn't much I can help you with. Perhaps the person doing the OS X builds would be able to help you, I don't know who that is.
Since you can select Shard, perhaps it's present inside the app bundle? In which case you'll want to copy it out and make a new copy of Shard, and rename it to something else, so that you can select the new copy of Shard and modify its files. Simply creating the folders for the lua files in the springrc folders and placing them in there will not work as Shard doesn't look at the Spring Virtual file system ( I don't know how to do this, I dont think anyone else does either )
There is no reason I'm aware of that Shard cannot work on OS X but, I have little knowledge of the state of Spring for OS X, I dont know how recent the build is, what it comes with, and from the few experiences I've had, lobby support is pitiful, or relies on mechanisms that are broken for security reasons ( e.g. weblobby + java applets being messed up by Apple induced Java security changes ).
So I do not know if Shard was built and distributed with Springs OS X builds, I've never tried to build it with xcode either.
So currently, you actually know more about this than I do, and there really isn't much I can help you with. Perhaps the person doing the OS X builds would be able to help you, I don't know who that is.
Since you can select Shard, perhaps it's present inside the app bundle? In which case you'll want to copy it out and make a new copy of Shard, and rename it to something else, so that you can select the new copy of Shard and modify its files. Simply creating the folders for the lua files in the springrc folders and placing them in there will not work as Shard doesn't look at the Spring Virtual file system ( I don't know how to do this, I dont think anyone else does either )
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
pnöpel uses Spring on OS X via weblobby. It downloads 91.0 and 94.1 and both work. Except for random bugs and some crashes I would say it is playable.I have little knowledge of the state of Spring for OS X
http://springrts.com/phpbb/viewtopic.php?f=11&t=30226
http://springrts.com/phpbb/viewtopic.php?f=11&t=30305
http://springrts.com/phpbb/viewtopic.php?f=11&t=30647
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Hi. Thanks for both of your responses.
I uses OSX 10.6.8
I should have been more clear.
I use web lobby, and it works well, sometimes does not load on chrome, but does not have a problem on firefox.
The does have a security warning dialoge box, but it works fine.
Yeah there a quite a few random bugs, but mostly spring plays fine on mac
Thanks AF I think your instructions have helped me solve the problem, I found shard inside the app bundle, and have copied it. I think this will work but I have not tested it yet I will update in a few days when I have time to test it properly.
Thanks.
Z
I uses OSX 10.6.8
I should have been more clear.
I use web lobby, and it works well, sometimes does not load on chrome, but does not have a problem on firefox.
The does have a security warning dialoge box, but it works fine.
Yeah there a quite a few random bugs, but mostly spring plays fine on mac
Thanks AF I think your instructions have helped me solve the problem, I found shard inside the app bundle, and have copied it. I think this will work but I have not tested it yet I will update in a few days when I have time to test it properly.
Thanks.
Z
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
I'm gonna try and use shard in my *A mod too.
Any pro tips?
Any pro tips?
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Spectate good players and steal their start builds for task queues, but add a little redundancy and lee way, so instead of 3 solars, tell it to make an extra one a little later.
Also SublimeText with the lua linting/checker is a big timesaver
Also SublimeText with the lua linting/checker is a big timesaver
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Posting in this thread so AF gets an email: http://springrts.com/phpbb/viewtopic.php?f=15&t=30692
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Hi AF.
I've got shard working and it is great.
I will have some more questions in a little while when I start to try and get some more complex behavior out of it.
It has helped me a huge amount in play testing and balancing my game.
Thanks for all the hard work.
I've got shard working and it is great.
I will have some more questions in a little while when I start to try and get some more complex behavior out of it.
It has helped me a huge amount in play testing and balancing my game.
Thanks for all the hard work.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
You have earnt a cookie!Zealot wrote:Hi AF.
I've got shard working and it is great.
I will have some more questions in a little while when I start to try and get some more complex behavior out of it.
It has helped me a huge amount in play testing and balancing my game.
Thanks for all the hard work.
Feel free to email or PM me, I dont get emails from posts in this thread, notify on reply hasnt been turned on for some reason
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Is it possible to have Shard re-calculate metal spot positions in runtime? Metal map can be changed on the fly, but Shard always sees the spots as they were on load time. This post describes the problem a bit more.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
In current Shard no, the spots are grabbed when the Map object is created and cached, and its the cached spots as you correctly surmised that get returned.
The two avenues for fixing this are:
Which is wasteful.
What do you think?
The two avenues for fixing this are:
- Remove caching on the C++ side and always calculate spots everytime its called, and rely on the lua side for any performance caching
- Add a method to recalculate spots and flush cache
Code: Select all
recalc spots()
get spots()
What do you think?