Index / Last update: May 2002

Sample JotaCode

// BOTDEALCC1
// Deals 1 crew counter from location "arg1" to location "arg2".
//--------------------------------------------------------------
// - Field ccloc_XX has the location of crew member #XX.
// - Field ccpos_XX has the position of crew member #XX within the location.
// - Field ncc_LL has the number of crew counters in location #LL.
// - Note that the value of ccpos_XX should be from 0..ncc_{ccloc_XX}.
//--------------------------------------------------------------
// Eg: If "arg1" is 0, and "arg2" is 41,
//     Then search the cc fields for XX such that
//        ccloc_XX = 0 and ccpos_XX = ncc_0 - 1 (deal off bottom of loc0).
//     When you find XX, do this:
//        ccloc_XX = 41; ccpos_XX = ncc_41 (add to bottom of loc41). 
//     Then ncc_0--; ncc_41++.
//--------------------------------------------------------------
@field gamebot = botdealcc1 :
@fieldloop("2117","ccloc_",
  @switch( @and(@eq("%v",@g("arg1")),
       @eq(@g(@print("ccpos_",@substr("%f","6"))),
       @sub(@g(@print("ncc_",@g("arg1"))),"1"))),
     "1",
     @print(
	@s("%f",@g("arg2")),
	@s(@print("ccpos_",@substr("%f","6")),
	  @g(@print("ncc_",@g("arg2"))))
     )
  )	
);
@s(@print("ncc_",@g("arg1")), @sub(@g(@print("ncc_",@g("arg1"))),"1"));
@s(@print("ncc_",@g("arg2")), @add(@g(@print("ncc_",@g("arg2"))),"1"));

Proposal 1: @incr() and @decr()

@incr(dbref, fldname)

@decr(dbref, fldname)


Proposal 2: @setsub()

@setsub(var1, val1, ..., varX, valX)


Proposal 3: %k

%k


Sample JotaCode using Proposed Features

@field gamebot = botdealcc1 :
@setsub("x",@g("arg1"),"y",@g("arg2"));
@fieldloop("2117","ccloc_",
  @switch( @and(@eq("%v","%x"),
       @eq(@g("ccpos_%k"), @sub(@g("ncc_%x"),"1"))),
     "1",
     @print(
	@s("%f","%y"),
	@s("ccpos_%k", @g("ncc_%y"))
     )
  )	
);
@decr("2117","ncc_%x");
@incr("2117","ncc_%y");

Index / David Welbourn / last update: May 2002.

Valid XHTML 1.0! Valid CSS!