Why won't this work?

Freeform discussion about anything related to modding Transcendence.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I am trying to look for any items with a "trap" modifier in the abondoned ship dock screen and then simply placing a charge on them- but the code isn't working, help!

Code: Select all

<DockScreen UNID="&dsAbandonedShip;"
		name=				"=(objGetName gSource)"
		>


	<Panes>
		<Default
				desc=		"You are docked with the wreck of a ship.">
<Initialize>
(block (trapCheck trapItem thisItem trapList)

		 (setq trapCheck (objEnumItems gSource "*U, +Trap" trapItem 			(block Nil
			(setq thisItem (shpRechargeItem gSource (itmAtCursor trapItem) 1))
			)
		  ))
)
</Initialize>
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

at first glace why do you have a comma in the "*U, +Trap"
I don't see where you got that format.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Code: Select all

	<OnDestroy>
(block (trapCheck trapItem thisItem trapList)

		 (objEnumItems gSource "*U, +Trap" trapItem 						
			(shpRechargeItem gSource (itmAtCursor trapItem) 1))
			
		  )
)
	</OnDestroy>
This works, partly- seems only 1 item in a group of items gets charged.

I suppose it should be "*U +Trap" but other criteria use , or ; to separate filters. Look at the systems.

But first- tell me why that same code works in <ondestroy> and not in <initialize>.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

hmm first guess would have to be gsource isn't set for initialize

as for criteria I think the systems criteria works differently than other criteria.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

But the <OnDestroy> worked with or without the comma, so perhaps it isn't set in stone there.

So, how could I set the gSource for this to work or otherwise get it to find the dang items?

EDIT- well it just doesn't seem like anything that effects the items can be done from a dockscreen that doesn't have the ItemListScreen. gSource IS defined, but it can't seem to put together a list of the items according to any filtering or not or perhaps it is due to the item pointer or item cursor being finicky, I even tried to simply output the items "*" to a list on gPlayerShip and got nothing from that screen.

Addit- however, the <OnDestroy> method seems to work fine, I just hate stacking effects up in the action part of the game where it is always a concern about lagging. I think that I can even get around the "only checks one of a stack of multiple items" problem. Which is kinda ridiculous, btw. A stack of same items shouldn't be treated as a single item like it is in the enum.

I still feel like there should be a way to access the list of items from dsAbandoned screens to manipulate them BEFORE the dsLoot is opened. Anyone have a clue about this?

Edit 2 - Well I was able to get the items to list, so it's possible to find the items and gSource is working for initialize tags. So, how can I set a charge on an item using shpRechargeItem from the initialize tags of a screen?
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

And more questions about <Initialize> and Dockscreens- when and where is gSource valid for the spaceobject?

I placed an <OnDestroy> event in a ship, which used (objSetData) to set a message in the ship (which is a spaceObject? Or what?).

Then I put a (objGetData) to the same message from the dsAbandonedShip <initialize> tag. It printed Nil. The message was: "A trap is sprung."

So... no way to access an object's data from a dockscreen called up by that object, or am I missing some tags? I mean, what is the point of having code in Initialize for a dockscreen if it can't even get a message stored on the object that the dockscreen is used by?

Code: Select all

<OnDestroy>
(block (trapCheck trapItem thisItem trapList)
	(setq trapCheck (objSetData gSource "Trap" "This is a trap in a dockscreen."))
       (objEnumItems gSource "*U +Trap" trapItem                   
         (shpRechargeItem gSource (itmAtCursor trapItem) 1))
         
        )
) 
	</OnDestroy>

<Initialize>
	(block (desc)
	(setq desc "You are docked with the wreck of a ship.")
	(setq desc (cat desc " " (objGetData gSource "Trap"))) 
		
		(scrSetDesc gScreen desc)
	)

</Initialize>
This <Initialize> behavior testing has been the equivalent of eight hours of non-productive head scratching. Why won't scripts run there like they do elsewhere? Or is it ObjSetData? All I wanted to do was pass a little info around, and this has been the most frustrating thing I have ever encountered.
GLOBALS

gPlayer: Object representing the player.
gPlayerShip: The player's ship.
gScreen: The current screen being displayed.
gSource: The station/ship that the player is docked at.
gTrans: Transcendence application object.

TEMPORARY GLOBALS

gBuyCriteria
gCost
gItem
gMargin
gPrevScreen
gPrevPane
gBonus
Seems to be telling me that gSource is the ship I am docked at. Yet it doesn't work with the code I wrote. Which is really a basic bit, nothing fancy there- when the object is destroyed, it sets up a little message on gSource and then when you dock the <initialize> looks for it.. and never ever finds it.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

it might be a bit of a workaround but why not make a screen before this screen (or pane) that when you go to the trap screen it stores the data that Initialize needs in custom globals. That way you don't have to worry about this.

Yes I know it isn't ideal but sometimes you have to work with what you have. 8)
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

SHIP!

Arrrrgh! gSource does NOT work because it is a SHIP!

All the code I wrote works perfectly well for a Station. But for some reason, because the spaceObject is a ship it won't work. (contrary to what seems to be stated in the comments, George)

In fact, gSource is used extensively all over the place for Teratons, Korolov, Raissermesser, and everything all in a Station. That is why I thought it should be working for a docked object. But not if that object is a wrecked ship!

Apparently Ships aren't able to access gSource, or something funky is going on with the wrecks that makes them less functional spaceObjects. I am not even sure that my <OnDestroy> event placed a bit of data on the ship.

All these special cases make me wonder about the objects- I mean, I thought that any spaceObject would be treated basically the same when it came to data- the ship has a lot of unique data already- inventory, position, condition- so what would be the issue with treating it like the other spaceObjects in regards to Get/Set?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

very odd gSource is used all the time in ships and it works (both with messages and with item invoking)
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

You know, I was wrong- it's not working right for stations.

This code:

Code: Select all

	<OnDestroy>

(block (trapCheck trapItem thisItem trapList)
	(setq trapCheck (objSetData gSource "trap" 2))
       (objEnumItems gSource "*U +Trap" trapItem                   
         (shpRechargeItem gSource (itmAtCursor trapItem) 1))
         
        )
) 
	</OnDestroy>
I placed in both a Corsair (ship) and Charon Pirate Stash (station).

When the code was on the ship, one test item of a stack got a charge.

When the code was on the station, NO items got a charge.

The code on the ship to set data "trap" as 2 did nothing.

The code on the station to set data "trap" as 2 actually worked.

:roll:
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

as I said before this can all be solved by making a screen before this screen that sets some globals for you, in action code gsource works fine so you can use the action code so you can set up for the Initialize :D (unless I am misunderstanding the problem)
Crying is not a proper retort!
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Periculi wrote:
When the code was on the ship, one test item of a stack got a charge.

When the code was on the station, NO items got a charge.

The code on the ship to set data "trap" as 2 did nothing.

The code on the station to set data "trap" as 2 actually worked.

:roll:
Not sure what's going on without seeing the whole code, but:

1. "one test item of a stack got a charge". That makes sense (I think). Right now setting a charge only really works on single items. That is, you can't set a charge on a bundle of 20 items (only one will get charged).

2. "...on the station, NO items got a charge": I can't explain that. Try adding (dbgOutput...) messages to see what is getting executed.

3. "The code on the ship to set data "trap"...did nothing": This might be because the ship was destroyed. The wreck of a ship is a totally different object from the ship itself. In 0.99 the OnDestroy event for a ship will also give you access to the wreck object (if any).

4. "The code on the station...actually worked": At least something worked!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

when you dock at a wrecked ship gsource should be that wrecked ship right?
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

So where does the ship get the items from, and how can they be referenced?

And it seems that you can't (shpRechargeItem just anywhere!

:lol: I found a way to use gPlayerShip in the Loot screen to set the trigger charges. I eventually ran out of choices for gSource, and jumped to where the item is transferred over to the playership- at that point I managed to place a function that would finally do what I wanted to do from the initialize.

A celebration is in order!

Now either stations or ships can trigger a trap on almost any usable item, without any concerns over who's hiding gSource.

Item traps are on the way, coming next is Ship and Station traps- poison gas, auto-destruct, killer nanobots- all kinds of defense systems could abound, thankfully countermeasures also abound.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

So you have a piece of code that can call events from any station or any ship dockscreen ?

Great job ! :)

I'm looking forward to get blasted by a nasty trap... :D
Post Reply