Mod Question Repository... Questions come in, answers go out - Page 56

Mod Question Repository... Questions come in, answers go out

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

Here is KDR's toggle gadget. It works great.
http://sl.pastebin.com/faC7aVHL

Lookes like this in unit files:

Code: Select all

    toggle1 = 3,
        toggle1a = [[Option 1a]],
        toggle1b = [[Option 1b]],
        toggle1c = [[Option 1c]],
        toggle1tooltip = [[1st Options]],
        toggle2 = 2,
        toggle2a = [[Option 2a]],
        toggle2b = [[Option 2b]],
        toggle2tooltip = [[2nd Option]],
        toggle3 = 1,
        toggle3a = [[Super D Gun]],
        toggle3tooltip = [[Fires super Dgun]],
and this in the cob:

Code: Select all

(t,value) 
{
if(t==1)
	{
	if(value==0)
		{
		opt1= 1;  //can really do anything here this just means the toggle settings a,b,c where a =0, b=1, c=2. Value is set to 0 when unit is created
	e	}
	if(value==1)
		{
		opt1= 2; //this is what well be slected the 1st time you hit the switch
		}
	if(value==2)
		{
		opt1= 3; 
		}
	}
if(t==2)
	{
	if(value==0)
		{
		opt2 = 1;
		}
	if(value==1)
		{
		opt2 = 2;  
		}
	}	
if(t==3)
	{
	if(value==0 )
		{
	        superdgun = true;
		}
	}
}

Now, back to bitching about units stopping to push instead of pushing and continuing to move. Are there any hacks around this?
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KingRaptor »

Is it me or can you not use gadget callins within a Lua unit script?
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

if I wanted to make a weapon only fire past a minimum range could I use GET SET_WEAPON_GROUND_TARGET weaponID xzCoord yCoord userTarget to find the targets range?
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

bobthedinosaur wrote:if I wanted to make a weapon only fire past a minimum range could I use GET SET_WEAPON_GROUND_TARGET weaponID xzCoord yCoord userTarget to find the targets range?
I'm probably misunderstanding but how about you just moving the flare-point, by witch i mean the origin of the weapon projectile?

On a completely different note:
Of all the problems I've encountered trying making a spring game, i believe this is a new one.
Image

the texture works fine on a different unit, and is 'properly flipped'
The texture is mostly team colour, but that can't be it, right? Works for Fibre if i recall correctly.
Anyone any ideas why my unit is black but transparent for trees?
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

probably bad model radius, check the hitsphere radius in upspring, if it is okay, then try adjusting the normals.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Mod Question Repository... Questions come in, answers go out

Post by Pressure Line »

id just use a fake weapon slaved to the weapon with the minimum range set to what you want the minimum range to be, and use CHANGE_TARGET and/or BlockShotX to get the desired result.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

since it was a ballistic i just limited the gun elevation. that seems to work.
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

bobthedinosaur wrote:probably bad model radius, check the hitsphere radius in upspring, if it is okay, then try adjusting the normals.
I feel a bit silly. Guess I was to tired to check basic stuff. But in any case:
Image
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Mod Question Repository... Questions come in, answers go out

Post by knorke »

Planet Express!
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

Ha ha, yes, kinda... I didn't noticed yet. Although I did worry about things not looking to Simpsons-like.
I guess this will be my favourite team colour, though. :-)
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

Cute ship. It would be some work but maybe you could have units stroll down the ramp with an invisible attachment arm.
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

Going a bit of topic but I promise i won't derail the Mod Question Repository any further after this post.

I didn't want to share my ideas already, because i don't have all the answers yet to questions that may arise in the community/on the forum, but the unit was already supposed to have a mechanical arm, with a resource reclamation device at the end.

Image
Large Image
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

bobthedinosaur wrote:invisible
Oh, wait i misunderstood. But yes, that is worth considering, perhaps also possible using Lua MoveCtrl stuff.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

What is the easiest way to send a mod option variable to a specific unittype's cob?
User avatar
Wombat
Posts: 3379
Joined: 15 Dec 2008, 15:53

Re: Mod Question Repository... Questions come in, answers go out

Post by Wombat »

question - is it possible to 'apply' unit limit to concrete type of unit ? like, lets say, u can have only 2 peewees alive at the same moment ? lua im right ?
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Mod Question Repository... Questions come in, answers go out

Post by SanadaUjiosan »

If you're asking what I think you're asking, it's a tag in the unit def:

Code: Select all

          unitRestricted      = 10,
If you're asking something else, I'm not sure.
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

I really just need to be sure, and feel it would take a lot of time if I had to accomplish that myself. So hopefully a question will solve it:
(To specify, this is about a Lua Unit script.)

About Signals and Signalmasks, callouts to mark and kill a running tread.
Spring.UnitScript.SetSignalMask ( number mask ) -> nil
Spring.UnitScript.Signal ( number signal ) -> nil
When i look at example scripts, I see the same typical names in all of them, for instance, "SIG_BUILD".
Is there is reason for this consistency? Or would the following work as well? :

Code: Select all

local function my_script()
    SetSignalMask( a_custom_signal_to_kill_the_myscript_tread  )
    Signal( a_custom_signal_to_kill_the_myscript_tread  )
    Spring.Echo('Executing my script')
end
(hope I encounter some noob-friendliness :-) )
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Mod Question Repository... Questions come in, answers go out

Post by Argh »

What is the easiest way to send a mod option variable to a specific unittype's cob?
Read the mod option, then call a script in the Unit, sending it the data it needs as a parameter:

Code: Select all

Spring.CallCOBScript(u, "ComScript", 0,X)
Where X is whatever you need to communicate.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Mod Question Repository... Questions come in, answers go out

Post by zwzsg »

The name of the signal doesn't matter at all. However it's very important that each signal is a power of 2 distinct from other signals (Do you speak binary? Ever worked with bitfields?)

Code: Select all

local function my_script()
    SetSignalMask( a_custom_signal_to_kill_the_myscript_tread  )
    Signal( a_custom_signal_to_kill_the_myscript_tread  )
    Spring.Echo('Executing my script')
end
You inverted Signal and SetSignalMask. You want to kill previous instance of my_script, not yourself! And don't forget to assign some 2^n number to a_custom_signal_to_kill_the_myscript_tread.

Then what I'm saying is from Cob, I assume it's the same for Lua unit scripts but I never tried.
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

Re: Mod Question Repository... Questions come in, answers go out

Post by FireStorm_ »

tanks zwzsg.
I now (think I) understand.
(and can carry on more confidently :-) )
Locked

Return to “Game Development Tutorials & Resources”