This occurred on Stock Mygeeto GCW conquest, using stock sides. I haven't tried any other maps.
Re: Custom FC Command Crashes Game
Posted: Sat Mar 28, 2015 10:27 pm
by razac920
Some context would be nice. Are you calling this fc command midgame? Because I don't think ReadDataFile works midgame. If you had previously loaded the other skins that you wanted, then maybe your command would work. Why don't you try removing the ReadDataFile line from your command and instead just mix up the stock skins already loaded, and see if that works?
Re: Custom FC Command Crashes Game
Posted: Sat Mar 28, 2015 10:36 pm
by Nedarb7
ReadDataFile works perfectly fine ingame. Though it may require a little bit of time before you try using the contents from the level file.
Re: Custom FC Command Crashes Game
Posted: Sat Mar 28, 2015 10:45 pm
by commanderawesome
I used the command right at the beginning of the level. I've had similar commands work perfectly fine in the past, like this one: http://pastebin.com/47WagWDB
These are all added though a global 1.3 patch user script.
Re: Custom FC Command Crashes Game
Posted: Sat Mar 28, 2015 11:59 pm
by Maveritchell
A couple quick observations:
1) Your "command description" is a nonsensical string - it's looking for a localization string, just like the example given in the comment.
2) Where are the variables all_inf_etc. defined? It looks like you could have mistakenly placed those as variables instead of strings, but they'd return nil that way as well.
And further, I'm not 100% sure whether you can properly read in from a side .lvl file after the script is loaded. It'd be better if you read in the optional units in ScriptInit and then made your custom command simply call for them.
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 12:45 pm
by commanderawesome
Maveritchell wrote:A couple quick observations:
1) Your "command description" is a nonsensical string - it's looking for a localization string, just like the example given in the comment.
The command description shows up in game, that isn't a problem.
Maveritchell wrote:2) Where are the variables all_inf_etc. defined? It looks like you could have mistakenly placed those as variables instead of strings, but they'd return nil that way as well.
I'm trying to get it to check if each class exists. It still crashed even before I added those.
Maveritchell wrote:And further, I'm not 100% sure whether you can properly read in from a side .lvl file after the script is loaded. It'd be better if you read in the optional units in ScriptInit and then made your custom command simply call for them.
As I said in my previous post, I've done it before, and it has worked.
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 1:54 pm
by Nedarb7
commanderawesome wrote:
Maveritchell wrote:2) Where are the variables all_inf_etc. defined? It looks like you could have mistakenly placed those as variables instead of strings, but they'd return nil that way as well.
I'm trying to get it to check if each class exists. It still crashed even before I added those.
Means nothing if the variable hasn't been set elsewhere. Because of that, you are changing every single class that is in your code, even if it isn't present in the game. My guess is that that is what is causing the game to crash.
all_inf_rifleman = true
...
if all_inf_rifleman == true then
SetClassProperty(...)
end
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 1:57 pm
by Maveritchell
commanderawesome wrote:I'm trying to get it to check if each class exists. It still crashed even before I added those.
That's the wrong way to go about it, then, because (for example) all_inf_rifleman will never exist (unless you make it a variable. Edit: Nedarb, you're making the same mistake. "All_inf_rifleman" as a reference is a string, not a variable.). You're trying to check to see (assuming you're working with SetupTeams) what class is assigned to the soldier table, and to do that you'd want to do something like:
if soldier[1] == "all_inf_rifleman" then
SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_snowtrooper")
end
I don't know offhand if that's local to the SetupTeams .lua, but you should be able to check and verify that.
And if everything in the code you showed us worked (or had already stopped working before you added it), why are you showing us this? You need to be able to show where something crashed - it's hard to make a judgment when you post something you've already modified post-crash. In other words, work back until you have something that works, and then add things until it doesn't. We can help you understand better what the problem is then.
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 2:03 pm
by Nedarb7
Maveritchell wrote:Edit: Nedarb, you're making the same mistake. "All_inf_rifleman" as a reference is a string, not a variable.).
With the code he had, I was just explaining what would need to be fixed.
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 2:09 pm
by Maveritchell
Nedarb7 wrote:
Maveritchell wrote:Edit: Nedarb, you're making the same mistake. "All_inf_rifleman" as a reference is a string, not a variable.).
With the code he had, I was just explaining what would need to be fixed.
That shouldn't cause a crash, though - a variable that's not set just returns nil, which he's already checking against. Consequently, none of his classes are changing, because none of the "if" statements are met.
That said, "the code he had" is a good point. If there's more code to be seen, it'd be worth seeing, especially if he has other things he thinks are working and they're versions of this he's "done before."
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 2:44 pm
by [RDH]Zerted
All those if statements are false so none of the SetClassProperty lines are running so the problem is with the ff_AddCommand call or the ReadDataFile calls. Your ff_AddCommand arguments look fine* (and it's a RedMemory error), so the issue is with ReadDataFile. It looks like a memory pool is too small. I don't know which pools you need to add or increase, but look into doing that. There's also a ReadDataFileInGame function. I don't know how it differs from ReadDataFile.
You can use uf_isKnownClass(<class string>) to check if a unit class has been added to a side or not. uf_isKnownClass() returns false if the class hasn't been added to a side and a number if it has.
if uf_isKnownClass('all_inf_rifleman') ~= false then
SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_snowtrooper")
end
Rewriting all those if statements into a loop would be even better:
Hidden/Spoiler:
[code]--class properties to reconfigure
--format: <unit class> = { {<first property to change>}, {<second property to change>}, {etc...} ,}
---- format of <# property to change>
---- * table of 3 elements
---- ** 1st element: class name
---- ** 2nd element: property name
---- ** 3rd element: new property value
local changes = {
all_inf_rifleman = {{"all_inf_rifleman", "GeometryName", "all_inf_snowtrooper"},},
all_inf_rocketeer = {{"all_inf_rocketeer", "OverrideTexture", "all_inf_vanguard_hoth"}, {"all_inf_rocketeer", "OverrideTexture2", "Rebel_face02"},},
}
--apply all the property changes
for key, value in pairs(changes) do
if uf_isKnownClass(key) ~= false then
for _,arguments in ipairs(value) do
SetClassProperty(arguments[1], arguments[2], arguments[3])
end
end
end[/code]
*It's better to localize your strings, but when the localization key doesn't exist the game simple outputs the key it was looking for. Thus using text in any key location does work, but you won't be able to translate it (which doesn't matter for personal projects).
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 8:29 pm
by commanderawesome
Maveritchell wrote:if everything in the code you showed us worked (or had already stopped working before you added it), why are you showing us this?
The code that works is a different command, which changes Phase 2 clones to Phase 1 clones. Though obviously there are less variants of clones then there are rebels, so there wasn't a problem. Sorry for the confusion.
Maveritchell wrote:You're trying to check to see (assuming you're working with SetupTeams) what class is assigned to the soldier table, and to do that you'd want to do something like:
if soldier[1] == "all_inf_rifleman" then
SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_snowtrooper")
end
I don't know offhand if that's local to the SetupTeams .lua, but you should be able to check and verify that.
[RDH]Zerted wrote:
You can use uf_isKnownClass(<class string>) to check if a unit class has been added to a side or not. uf_isKnownClass() returns false if the class hasn't been added to a side and a number if it has.
if uf_isKnownClass('all_inf_rifleman') ~= false then
SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_snowtrooper")
end
Rewriting all those if statements into a loop would be even better:
Hidden/Spoiler:
[code]--class properties to reconfigure
--format: <unit class> = { {<first property to change>}, {<second property to change>}, {etc...} ,}
---- format of <# property to change>
---- * table of 3 elements
---- ** 1st element: class name
---- ** 2nd element: property name
---- ** 3rd element: new property value
local changes = {
all_inf_rifleman = {{"all_inf_rifleman", "GeometryName", "all_inf_snowtrooper"},},
all_inf_rocketeer = {{"all_inf_rocketeer", "OverrideTexture", "all_inf_vanguard_hoth"}, {"all_inf_rocketeer", "OverrideTexture2", "Rebel_face02"},},
}
--apply all the property changes
for key, value in pairs(changes) do
if uf_isKnownClass(key) ~= false then
for _,arguments in ipairs(value) do
SetClassProperty(arguments[1], arguments[2], arguments[3])
end
end
end[/code]
I'll see which (and if) one of those works and report back.
[RDH]Zerted wrote: *It's better to localize your strings, but when the localization key doesn't exist the game simple outputs the key it was looking for. Thus using text in any key location does work, but you won't be able to translate it (which doesn't matter for personal projects).
I'll localize it when it's finished and ready for public release.
Re: Custom FC Command Crashes Game
Posted: Sun Mar 29, 2015 9:55 pm
by Teancum
Try running the memory command ("mem" ? ) in the console in the debug executable. The redMemory error implies that there wasn't enough room in the pool to fit all the required elements. Check the memory pools prior to running the command to be sure you have room.
Re: Custom FC Command Crashes Game
Posted: Mon Mar 30, 2015 1:26 pm
by Nedarb7
You also might want to consider preventing the user from loading a level file more than once. Right now your code is setup to load the lvl file every time the button is pressed which is completely (from what I see) unnecessary.
Maveritchell wrote:That shouldn't cause a crash, though - a variable that's not set just returns nil, which he's already checking against. Consequently, none of his classes are changing, because none of the "if" statements are met.
Ah, right. My bad, I was confused due to a past experience.
Re: Custom FC Command Crashes Game
Posted: Fri Apr 03, 2015 10:36 pm
by commanderawesome
Mav's solution didn't work. I will try Zerted's next.
Re: Custom FC Command Crashes Game
Posted: Fri Apr 03, 2015 11:24 pm
by Maveritchell
commanderawesome wrote:Mav's solution didn't work. I will try Zerted's next.
I just checked for you, and like I warned you - the list of soldier classes (as an array) is local to SetupTeams. You'll need to modify that so that typeList isn't local. I also gave you pseudocode (soldier[1] doesn't mean anything in the context of an unchanged mission script), which will obviously make things "not work."
Zerted's solution is probably simpler (given that it comes from the utility functions he made for the 1.3 patch), but no matter what you do, you'll have to read the instruction.
for key, value in pairs(changes) do
if uf_isKnownClass(key) ~= false then
for _,arguments in ipairs(value) do
SetClassProperty(arguments[1], arguments[2], arguments[3])
end
end
end
I'm a bit confused by this part. Do I leave this as it is, or change the variables to that of each unit?
Re: Custom FC Command Crashes Game
Posted: Wed Apr 08, 2015 10:28 pm
by [RDH]Zerted
Leave it as is. Only edit the changes table.
Re: Custom FC Command Crashes Game
Posted: Wed Apr 08, 2015 10:34 pm
by commanderawesome
Ok, thought so. Just checking to make sure. Also, just to eliminate the possibility of it being a memory issue, what memory pool would I need to raise? And to what number? (BTW, Zerted, did you get my E-Mail?)