Lost + found

Post your scripting questions / solutions here

Moderator: Moderators

BatteryAziz
Moderator
Posts: 82
Joined: Tue Jun 15, 2010 4:44 pm

Post by BatteryAziz »

those lines you posted have a bad syntax ("local mycurtain" should be local.mycurtain) so the script probably didn't load and nothing happened. you'll know the script is running when you hear the ambient sound when you load the map. if there's no ambient sound, there's a typo somewhere in your script.

try this:

local.mycurtain = spawn script_model "model" "static/curtain.tik"
local.mycurtain.origin = (-615.75 -493.78 32.20)
local.mycurtain.angles = (9 90 0)
local.mycurtain.scale = 1.0
local.mycurtain notsolid
local.mycurtain nodamage
local.mycurtain show

i think animated .tik models won't show when using script_object, hence i suggest spawning a script_model instead. also to be sure, double-check if your origin coordinates are correct.

if it still doesn't work, narrow it down by trying to spawn some other model (ammo, machine gun, truck) and see if that works.
neillomax
Lieutenant General
Posts: 880
Joined: Thu Jun 23, 2005 6:57 am

Post by neillomax »

thanks for picking this up. I don't have time to play. remember when there's a negative ( - ) you have to put a space between it and the ( parentheses ) (99) vs ( -99)........ see ?
neillomax
Lieutenant General
Posts: 880
Joined: Thu Jun 23, 2005 6:57 am

Post by neillomax »

here's a working script....... you can see where I put in relation to the whole script. I had to change the upper last number to raise it out of the ground ( it's in the court yard just above ground.).... had yo change angle ( first number because it was laying flat not up and down ) you need to change the middle and last numbers to move it to the doorway you want it in and to get it to face the right direction...... do not change the first number or it will not stand upright....... making it harder to see and find. ( YOU ALSO NEED TO MAKE IT NOTSOLID OR YOU WON'T BE ABLE TO WALK THROUGH IT. You can forget about the "immune" stuff. just delete it. Doesn't work without bounding boxes.

// STALINGRAD
// ARCHITECTURE: ZIED, POWZER
// SCRIPTING: POWZER

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Stalingrad"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" "stuff"
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm6"

// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread

level waittill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr

exec global/door_locked.scr::lock
level.script = maps/dm/mohdm6.scr
exec global/ambient.scr mohdm6

level waittill spawn


local.fix1 = spawn script_model
local.fix1 model static/curtain.tik
local.fix1.origin = ( -295.56 102.98 -82.91 )
local.fix1.angles = ( 0.00 -165.45 0.00 )
local.fix1.scale = 1.0
local.fix1 solid
local.fix1 nodamage
local.fix1 immune bullet
local.fix1 immune fast_bullet
local.fix1 immune bash
local.fix1 immune mg
local.fix1 immune explosion
local.fix1 immune grenade




end

//-----------------------------------------------------------------------------

roundbasedthread:

// Can specify different scoreboard messages for round based games here.

level waitTill prespawn

level waittill spawn
neillomax
Lieutenant General
Posts: 880
Joined: Thu Jun 23, 2005 6:57 am

Post by neillomax »

so remember just change the upper last number to get altitude.... it's at -82 now... making it -62 will raise it....... and by the time you get it to the height of that door way you will not be in negative territory but positive ( no - sign. ) everything after that is with angles...... middle and las nubers only....... don't touch the 0.00..........
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

A little help is needed!

Post by SilentAngel »

Hi guys, since I do not remember anything about scripting I need help to fix this code:

Code: Select all

while(int(getcvar(InGameBuilder)) != 0)
	{
		if((getcvar(IGB_Display)) != "")
		{
			local.model = getcvar(IGB_Model)
			local.origin = waitexec global/strings.scr::split_line getcvar(Model_coords) 1 " "
			local.angles = waitexec global/strings.scr::split_line getcvar(Model_angles) 1 " "
			
			local.o1 = float(local.origin[1][1])
			local.o2 = float(local.origin[1][2])
			local.o3 = float(local.origin[1][3])
			local.v1 = float(local.angles[1][1])
			local.v2 = float(local.angles[1][2])
			local.v3 = float(local.angles[1][3])
		
			//add the object..
			local.obj = spawn script_model
			local.obj model local.model
			local.obj.origin = ( local.o1 local.o2 local.o3 )
			local.obj.angles = ( local.v1 local.v2 local.v3 )
			local.obj.scale = 1.0
			local.obj solid
			
			setcvar "IGB_Display" ""
			setcvar "Model_coords" ""
			setcvar "Model_angles" ""
		}
		wait 0.5
	}
let's suppose that I set ingame Model_coords as "111 222 333" and Model_angles as "0 0 0".
the console reports that local.origin[1][2], local.origin[1][3],local.angles[1][2] and local.angles[1][3] are NIL so I cannot cast them to float. I don't understand why they are NIL and not
local.origin[1][2] = 222
local.origin[1][3] = 333
local.angles[1][2] = 0
local.angles[1][3] = 0

Am I missing something? :?:
jefflev
Private
Posts: 7
Joined: Fri Oct 21, 2011 5:16 pm
Contact:

Post by jefflev »

Thanks Neil you're the man. I understand it a lot better now.

Thanks again
jeff
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Could you post the implementation of the global/strings.scr::split_line function here?
Image
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

it's the one from Elgan:

Code: Select all

// ----------------------------------------------------------------------------------------------------------------------
// Used to split a line of words into a array of words. return with word count
// localinfo == line to split
// local.say = say to admins input detected or not, set 1 usualy
// local.spacer = What to use to split the line. If none is set then " " will be used.
// usage local.wordarray = waitexec global/strings.scr::split_line ( STRING STRING , CONSOLE FEEDBACK, STRING SPACER)
//
//eg
//  local.wordarray = waitexec global/strings.scr::split_line "hello_mummy" 1 "_"
// local.wordarray is a const array
//
// local.wordarray[1] = array of words
// local.wordarray[2] word count
// local.wordarray[3] full string with " " spaces
//
// local.wordarray[1][1] is 'hello'
// local.wordarray[1][1] is 'mummy'
//
// local.wordarray[2] is 2 'two words'
//
// local.wordarray[3] is 'hello mummy'
// ----------------------------------------------------------------------------------------------------------------------

split_line local.info local.dont_say local.spacer:

	local.wordcount = 1

	if(local.spacer==NIL)
	{
		if(local.info[0] == "`")
		{
			local.spacer = "_"
			local.start = 1
		}
		else if(local.info[0] == " " || local.info[0] == "")
		{
			local.spacer = " "

			for(local.i = 0;local.i <= local.info.size;local.i++)
			{
				if(local.info[local.i] != " " && local.info[local.i] != "")
				{
					local.start = local.i
					break
				}
			}

		}
		else 
		{
			local.spacer = " "
			local.start = 0
		}
	}
	else
	{
		local.start = 0
		local.altcheck = 1
	}

	for(local.i=local.start;local.i<=local.info.size - 1;local.i++)
	{	
		if(local.info[local.i]!=local.spacer && local.info[local.i] != "`")
		{
			if(local.words[local.wordcount]==NIL)
			{
				local.words[local.wordcount]=""
			}

			local.words[local.wordcount] += local.info[local.i]
		}
		else
		{	
			if(local.altcheck != 1)
			{
				if(local.spacer == "_" && local.info[local.i + 1] == "`")	// if its like ui_hud 1. sud be ui_`hud so it knows:).
				{
					local.words[local.wordcount] += local.info[local.i]			
				}
				else if(local.spacer == "_" && local.info[local.i ] != "`")
				{
					local.wordcount++
				}
				else if(local.spacer == " " && local.info[local.i ] == " ")
				{
					if(local.i != local.info.size - 1)
					{
						if(local.info[local.i + 1] != " " && local.info[local.i + 1] != NIL)
						{
							local.wordcount++
						}
					}
				}
			}
			else
			{
				if(local.info[local.i ] == local.spacer)
				{
					local.wordcount++
				}
			}
		}
	}	

	if(local.spacer == "_")
	{
		local.actual = ""

		for(local.i=3;local.i<=local.words.size;local.i++)
		{
			if(local.i < local.words.size)
			{
				local.space = " "
			}
			else
			{
				local.space = ""
			}
			local.actual += ( local.words[local.i] + local.space )
		}

		if(local.dont_say != 1)
		{
			//exec global/ac/console_feedback.scr ( "> Input detected: " + local.actual )
		}
	}
	else
	{
		if(local.dont_say != 1)
		{
			//exec global/ac/console_feedback.scr ( "> Input detected: " + local.info)
			local.actual = local.info
		}
	}

end ( local.words::local.wordcount::local.actual) 
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

If can help this is what shows the console:

Code: Select all

]set IGB_Model "static/indycrate.tik"
]set Model_coords "111 222 333"
]set Model_angles "0 0 0"
]set IGB_Display 1
getcvarModel_coords
getcvar
			local.o2 = float(local.origin[1][2]) (global/igb.scr, 38)
			local.o2 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.o3 = float(local.origin[1][3]) (global/igb.scr, 39)
			local.o3 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.v2 = float(local.angles[1][2]) (global/igb.scr, 41)
			local.v2 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.v3 = float(local.angles[1][3]) (global/igb.scr, 42)
			local.v3 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.origin = ( local.o1 local.o2 local.o3 ) (global/igb.scr, 47)
			local.obj.origin = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.origin = ( local.o1 local.o2 local.o3 ) (global/igb.scr, 47)
			local.obj^

^~^~^ Script Error: Cannot cast 'NIL' to vector

			local.obj.angles = ( local.v1 local.v2 local.v3 ) (global/igb.scr, 48)
			local.obj.angles = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.angles = ( local.v1 local.v2 local.v3 ) (global/igb.scr, 48)
			local.obj^

^~^~^ Script Error: Cannot cast 'NIL' to vector

getcvarModel_coords
getcvar
			local.o2 = float(local.origin[1][2]) (global/igb.scr, 38)
			local.o2 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.o3 = float(local.origin[1][3]) (global/igb.scr, 39)
			local.o3 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.v2 = float(local.angles[1][2]) (global/igb.scr, 41)
			local.v2 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.v3 = float(local.angles[1][3]) (global/igb.scr, 42)
			local.v3 = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.origin = ( local.o1 local.o2 local.o3 ) (global/igb.scr, 47)
			local.obj.origin = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.origin = ( local.o1 local.o2 local.o3 ) (global/igb.scr, 47)
			local.obj^

^~^~^ Script Error: Cannot cast 'NIL' to vector

			local.obj.angles = ( local.v1 local.v2 local.v3 ) (global/igb.scr, 48)
			local.obj.angles = ^

^~^~^ Script Error: Cannot cast 'NIL' to float

			local.obj.angles = ( local.v1 local.v2 local.v3 ) (global/igb.scr, 48)
			local.obj^

^~^~^ Script Error: Cannot cast 'NIL' to vector

SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

PROBLEM SOLVED! :D
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Awesome, well done 8-).

So, how did you solve it?
Image
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

did this:

Code: Select all

local.coords = getcvar(Model_coords)
local.origin = waitexec global/strings.scr::split_line local.coords 1 " " 
instead of this:

Code: Select all

local.origin = waitexec global/strings.scr::split_line getcvar(Model_coords) 1 " " 
:wink:
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Break all breakable windows

Post by SilentAngel »

Someone have a idea to automatically break all windows on a stock map at start up?
BatteryAziz
Moderator
Posts: 82
Joined: Tue Jun 15, 2010 4:44 pm

Post by BatteryAziz »

i think the original line would've worked fine using waitthread, not waitexec

exec starts the script from scratch, but accessing a specific thread in another script file requires waitthread, at least that's been my experience.

anyway it's a moot point now ;)
neillomax
Lieutenant General
Posts: 880
Joined: Thu Jun 23, 2005 6:57 am

Post by neillomax »

don't know how to break them but this might do something

removeclass windowObject

OR

$removeclass windowObject
Locked