buildingproductionrun event wont pass vars threw customevent

Forum Archive - from http://theuniversal.net
Locked
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

buildingproductionrun event wont pass vars threw customevent

Post by zaroba »

Software:Universal Client
Version Number:
________________________________________________________________________
Location

________________________________________________________________________
Description:
If you access a building and it triggers a custom event, building vars still work properly for the building. However if you have buildingproductionrun events activate a custom event, buildingvars will not work.


The sad result of this is that instead of one 5000 line file for zorics building production, I need 18 identical files and any changes made are a real pain :(
________________________________________________________________________
Steps to Replicate:
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Customevents still exist?


functions are the future.

Code: Select all

event("&command","functionsFTW")
{
  
$thisVar = 2
$thatVar = 13

$what = the total($thisvar,$thatvar)


*say The answer is $wat
}

function($thisvar,$thatvar)
{
 
 $theAnswer = $thisvar + $thatvar

 return ($theanswer)
}

User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

damn that should be function functionsWTW($thisvar,$thatvar)
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

functionsFTW =) I type too fast and don't reread. This damn sub sure needs an edit button!
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

nevermind i totally blew that one XD

Code: Select all

event("&command","functionsFTW")
{
 
$thisVar = 2
$thatVar = 13

$what = TheTotal($thisvar,$thatvar)


*say The answer is $wat
}

function TheTotal($thisvar,$thatvar)
{
 
 $theAnswer = $thisvar + $thatvar

 return ($theanswer)
} 
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Code: Select all

event("&command","functionsFTW")
{
 
$thisVar = 2
$thatVar = 13

$what = TheTotall($thisVar,$thatVar)


*say The answer is $what
}

function TheTotal($thisvar,$thatvar)
{
 
 $theAnswer = $thisvar + $thatvar

 return ($theAnswer)
} 
ok i'll go back to my cave now.
=)
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

wtf i havn't hit it right on any of htem, i need to go back to bed.

between the 3 you should get the idea though.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

not really. lol


Can you provide an example that basically follows this? or yields the same output?

buildingvar x is #
make sure buildingvar y (up to 7 different ones, varied depending on what var x is) is over #
then increase building var z by #, decrease (upto 7) buildinvar y by #
otherwise set buildingvar q to #
if buildingvar g is under # and buildingvar b > 0, random chance of setting buildingvar q to #

if builgingvar z goes over buildingvar s set buildingvar q to #
if builgingvar z goes over buildingvar m set buildingvar q to #
unless buildingvar b = 2, then set buildingvar q to a different # and recheck next prod to possibly change q back to 0

all of the above replicated for up to 5 different vars, and for 150+ items
the question might be, would it more more worthwhile size-wise to do it with functions vs a single event?

hmm...might be easier to post one of the production scripts to see if it can be made into a function.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

post er up i'll see what i can make of it =)
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

most of the script is just setting vars to use, not even 1/4 of it is the actual production.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

indeed, functions ftw :) If nothing else, there's no problem losing state with functions (and they're dealt with more efficiently by the server).
Anyway, I've had a quick look at the custom event code and can't see anything that explains the different behaviour in BuildingProductionRun. Are/were you using *event or the CustomEvent function?
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

Code: Select all

Event("BuildingProductionRun", "69")
	{
	$gBuidlingVar1=123
	*say $gBuidlingVar1
	CustomEvent("testvar")
	}

Event ("custom","testvar")
	{
	*say $gBuidlingVar1
	}
Outputs:

123
0
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

lol, I just noticed the var is misstyped in the above example.

I will do some retesting tomorrow.
Locked