Game development to create a data-driven system based on Excel tables

Planning likes to use Excel, there are many formulas in it, which is very convenient.

Planning the written data, handwriting the program into the code, it is more troublesome to modify each time,

So we make a module that can automatically convert Excel data into data that the program can use directly.

The program is quick to use after each change of data.

1: Define an Excel format for planning and program communication

The program needs to parse Excel, and define the format requirements of the Excel table without affecting the planning and use, as follows:

(1) For each Excel table, we must make a table field description (as shown in Figure 1)

Field field type (string, int, extending your own type) field description

(2) For each data table, the first row must be a field, and the second row must be a type (as shown in Figure 2)

(3) Each data record must have a field id, which uniquely identifies each different record;

(figure 1)

(figure 2)

2: How to read data in an Excel table

  1. What data format to convert Excel table to?

Generally, many students choose Json, I choose to directly convert to JS module here, without considering asynchronous loading.

(2) Write an automatically generated tool to convert Excel tables into corresponding js codes in batches;

(3) After each js code is transferred, there are 3 large blocks:

Note: The name and type of the field are convenient for friends, please be happy when using data;

Data content: key_id: [element 1, element 2, …] , save memory, js save space;

Access function: automatically generate a get_record(id) return {field: value, field: value}

Figure 3

Posted on 2022-03-14 12:53

Guess you like

Origin blog.csdn.net/bycw666/article/details/123476142