Eoc modding newbie question
- GrandpaTrout
- Offline
- King of Space
You are trying to do too much. Don't add a new ship, a new cluster and a new script at the same time. It makes it impossible to know what is going wrong. If you take baby steps you will end up moving faster than big jumps (that don't work).
I think you are close with this script. You must set the players ship as not cullable before you place it into the game Sim.SetCullable(player, false); Do this before the Sim.PlaceNear command. The problem is that you are placing the ship, then the game is noticing the ship is not near the player and deleting it. Then you try to put the player into the deleted ship and end up in nowhere-land.
Second, you new ship might be failing to create. Use some script like this to test the ship was created properly
debug Debug.PrintHandle(player);
debug Debug.PrintString(" player ship\n");
put this directly after the iShip.Create() to test the ship INI files were not messed up in some way. Use the same debug code to make sure that Hoffers Gap was really found. Look in the flux.log and search for "player ship" and you should see a description of the player ship sim. If you see "none" then you know the ship did not create.
There is a lot to know to get started. But once over these early problems, it gets much easier. You will really like it. And we are looking forward to some mods from a great Iwar scripter!
Please Log in or Create an account to join the conversation.
For some reason, I seem to be unable to print debug messages on screen. The compiler accepts the script, but debug messages don't even show up if placed at the very beginning of the Main function. I've come to the believe that the main function isn't executed at all, no matter how I try to arrange, declare and start functions.
Moreover, I've reduced the PS script to a degree where I'm stuck with the very same problem as with my own script [xx(]
I've also come to the point where I went into the kitchen, started heating water and caught myself thinking that I had to "define" my food first. This incident finally convinced me to continue tomorrow...
Please Log in or Create an account to join the conversation.
POG is very confusing at first. Though I never mentioned this to GT before, I spent the first 4 weeks of the Sandbox wondering around in a daze, not knowing what I was doing. I was afraid to tell him my real status for fear he'd pull me off the project.
The way I learned was to find a mod which was close to what I wanted to do, and then start modifying the source. To begin with I'd only insert debug statements so I could figure out what was going on. After I began to see how it did what it did, then I began to modify it in small ways.
Then you're using the console? I can't be much help there... I stuck with the flux.log for my bug-hunts. I found it's a simpler process.For some reason, I seem to be unable to print debug messages on screen.
After a time it gets much, much easier.
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
Getting your debug setup is the very first thing:
Open the SDK and read the section Developing Scripts->Debugging POG scripts.
The short answer is that debug mode must be turned on in flux and you need the proper keybinds to open the console. There are many very cool keyboards commands described in there.
It is very possible that your main function is not running.
The package filename should be the same filename as your mod, i.e. for a mod called my_mod.zip use the package filename of my_mod.pkg. The package must be in a packages folder in the zip (just as in the resource.zip)
In addition the Scenario package should contain a function called ScenarioMain() This function is called when you select the scenario on the extras screen.
The naming is very critical. Oh, make sure your ScenarioMain is calling your main function. The main function is not called (not like C).
Post back if none of that works!
Please Log in or Create an account to join the conversation.
Note: I had changed the star system to Dagda of few tries ago, which was just to make sure the game REALLY recognized the right system and not just set me into Hoffer's Wake for a lack of better ideas
// Package name
package cutter_test;
// Imports
uses Debug, Task, Text, Global, iGame, iMapEntity, iFaction, Sim, iSim, iShip, iShipCreation, iInventory;
// Exports
provides Main, ScenarioMain;
// Prototypes - Functions defined for use in this package.
prototype ScenarioMain();
prototype Main();
prototype task MainTask ();
ScenarioMain()
{
iGame.SetGameType( IGT_Mod );
iGame.StartNewGame( "map:/geog/badlands/Dagda", "cutter_test" );
Text.Add( "csv:/cutter_test" );
}
Main()
{
debug Debug.PrintString( "On our way...\n");
start MainTask();
}
task MainTask()
{
hmapentity refstar = iMapEntity.FindByNameInSystem( "Dagda I", "map:/geog/badlands/Dagda" );
hship player = iShip.Create( "ini:/sims/ships/player/comsec_prefitted.ini", "player_name" );
Sim.SetCullable ( player, false );
iShip.InstallPlayerPilot( player );
Sim.PlaceNear( player, refstar, 100000000 );
if( player == none )
debug Debug.PrintString( "No player ship!\n" );
if( refstar == none )
debug Debug.PrintString( "Star not declared!\n" );
}
Alright - all of the debug messages have been printed - "On our way" indicating the Main function had been called, as well as "No player ship" and "no star declared". The first interesting part from the flux.log comes right after the "On our way" message, which means the following happens just after Main() started:
SCRIPT: [unknown] On our way...
SCRIPT: [unknown] iStartSystem.FinalSetup: Making Performing last minute pre-flight checks...
SCRIPT: [unknown] iStartSystem.check_player_ship: Story didn't give the player a ship - creating ship from loadout
SCRIPT: [unknown] iStartSystem.finish_loadout: Checking turret fighters, cargo etc...
SCRIPT: [unknown] iWingmen.AddTurretFighters: No turret fighters. EXITING
SCRIPT: [unknown] iStartSystem.finish_loadout: Completed
SCRIPT: [unknown] iStartSystem.FinalSetup: Completed
I just don't know what to do with that. I tried creating the player ship directly in the Main() function (i.e. BEFORE the engine tries to create a player ship from loadout, but that lead to the problem that any references to the player ship in the MainTask function didn't work: When I tried to compile that script, the compiler put out an error message claiming "player" was an undeclared identifier.
The last two debug messages finally informed me that neither the star had been the properly declared, nor the player ship found:
SCRIPT: [unknown] iGMTracker.GMTracker: checking count of existing missions.
SCRIPT: [unknown] iGMTracker.GMTracker: existing count 0 maximum is 1
SCRIPT: [unknown] iMusic.monitor: Changing suite (1)
SCRIPT: [unknown] iMusic.monitor: Changing mood (2)
SCRIPT: [unknown] iMusic.monitor: Changing to track sound:/audio/music/a2_discovery (suite=1 mood=2)
SCRIPT: [unknown] No player ship!
SCRIPT: [unknown] Star not declared!
However, I don't see any connection to what might have gone wrong in my script. I suppose it may have something to do with the engine's attempt to create some other player ship right after the "On our way" message. Or maybe the fact that MainTask() wouldn't recognize the handle to a player ship declared in an earlier function (namely Main()) is due to a similiar reason as the fact that no player ship shows up at all if I both declare AND refer to the player ship in the MainTask function. But then again, the latter idea is just pointless speculation.
Please Log in or Create an account to join the conversation.
Replace:
start MainTask();
with:
Task.Detach(start MainTask());
P.S. I don’t see why MainTask has to be a task in the first place, unless you plan on adding some timing in later.
Please Log in or Create an account to join the conversation.